* [PATCH v2 manager 17/20] vzdump: honor backup concurrency limits of storages
2026-11-18 13:18 14% [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-18 13:18 19% ` [PATCH v2 guest-common 04/20] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
2026-11-18 13:18 21% ` [PATCH v2 manager 11/20] vzdump: back up guests of a job in parallel Thomas Lamprecht
@ 2026-11-18 13:18 18% ` Thomas Lamprecht
2026-11-18 13:18 15% ` [PATCH v2 manager 19/20] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
2026-11-18 13:18 19% ` [PATCH v2 docs 20/20] vzdump: document concurrent backups and their limits Thomas Lamprecht
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-18 13:18 UTC (permalink / raw)
To: pve-devel
Guest backups now also count against the backup concurrency limit of
the storages they use, both the backup target and the storages of the
included guest disks. This protects a backup server or a Ceph cluster
from more parallel backups than it can handle, which a limit for the
whole cluster cannot express once several such systems are in use.
Limits of shared storages count for the whole cluster and use the
cluster-wide slots. Limits of local storages count on each node and
use slot locks like the node limit. A guest whose local storage has no
free slot lets other guests of the job go first.
With several limits, a waiting guest backup can be blocked by a full
storage while younger ones with room in their limits get slots. This
may happen a few times, then a slot of each limit it needs is kept
free for it, so it cannot starve.
The storages are taken from the guest configuration before the guest
gets locked for backup, so waiting for slots does not block changes to
the guest. If its disks moved to another storage with a limit by the
time it got locked, the backup fails instead of running without a slot
for that storage. If the storages cannot be determined, the guest is
skipped for the same reason. Nothing of this happens as long as no
storage has a limit. The task log tells which limit a guest waits for.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
changes v1 -> v2:
- log the wait for a storage slot once, not on every pass, if guests
wait for different storages
- the warning about limits that are not enforced names the shared
storage limits too
PVE/VZDump.pm | 113 +++++++++++++++++++++++++++---
PVE/VZDump/ClusterSlots.pm | 42 ++++++++++-
test/vzdump_cluster_slots_test.pl | 79 ++++++++++++++++++++-
3 files changed, 221 insertions(+), 13 deletions(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 867fe0b8f..10d0caf1b 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -951,6 +951,34 @@ sub get_backup_file_list {
return $bklist;
}
+my sub limited_backup_storages {
+ my ($self, $task) = @_;
+
+ my $storage_cfg = PVE::Storage::config();
+ my $limited = {
+ map { $_ => 1 }
+ grep { defined($storage_cfg->{ids}->{$_}->{'backup-concurrency'}) }
+ keys $storage_cfg->{ids}->%*
+ };
+ return [] if !scalar(keys $limited->%*);
+
+ my $storeids = {};
+ $storeids->{ $self->{opts}->{storage} } = 1 if $self->{opts}->{storage};
+
+ if (my $plugin = $task->{plugin}) {
+ my $config_class = $plugin->type() eq 'qemu' ? 'PVE::QemuConfig' : 'PVE::LXC::Config';
+ my $conf = $config_class->load_config($task->{vmid});
+ for my $volume ($config_class->get_backup_volumes($conf)->@*) {
+ next if !$volume->{included};
+ my $volid = $volume->{volume_config}->{file} // $volume->{volume_config}->{volume};
+ my ($storeid) = PVE::Storage::parse_volume_id($volid, 1);
+ $storeids->{$storeid} = 1 if defined($storeid);
+ }
+ }
+
+ return [sort grep { $limited->{$_} } keys $storeids->%*];
+}
+
sub exec_backup_task {
my ($self, $task) = @_;
@@ -1134,6 +1162,13 @@ sub exec_backup_task {
$cleanup->{unlock} = 1;
+ my $taken = { map { $_ => 1 } $task->{storages}->@* };
+ if (my @missing = grep { !$taken->{$_} } limited_backup_storages($self, $task)->@*) {
+ my $list = join(', ', map { "'$_'" } @missing);
+ die "no backup slot for storage $list - guest disks or storage limits changed while"
+ . " waiting for backup slots\n";
+ }
+
# prepare
my $mode = $running ? $task->{mode} : 'stop';
@@ -1783,6 +1818,25 @@ my sub try_node_slot {
return try_slot("$lockdir/slot", node_backup_concurrency());
}
+# Limits of local storages count on each node, shared ones are handled cluster-wide.
+my sub try_local_storage_slots {
+ my ($storeids) = @_;
+
+ my $storage_cfg = PVE::Storage::config();
+
+ my $locks = [];
+ for my $storeid ($storeids->@*) {
+ my $scfg = $storage_cfg->{ids}->{$storeid} or next;
+ my $limit = $scfg->{'backup-concurrency'};
+ next if $scfg->{shared} || !defined($limit);
+
+ my $lock = try_slot("$lockdir/storage-$storeid", $limit) or return (undef, $storeid);
+ push $locks->@*, $lock;
+ }
+
+ return ($locks);
+}
+
my sub log_wait {
my ($self, $reason) = @_;
@@ -1845,10 +1899,25 @@ my sub claim_next_guest {
skip_task($task, "guest moved to node '$node'");
next;
}
+
+ $task->{storages} = eval { limited_backup_storages($self, $task) };
+ if (my $err = $@) {
+ die $err if $err =~ m/interrupted by signal$/;
+ chomp($err);
+ splice($queue->@*, $i--, 1);
+ skip_task($task, "unable to check storage backup limits - $err");
+ next;
+ }
+
+ my ($storage_locks, $busy_storage) = try_local_storage_slots($task->{storages});
+ if (!$storage_locks) {
+ log_wait($self, "a free backup slot of storage '$busy_storage'");
+ next;
+ }
delete $self->{'waiting-for'};
splice($queue->@*, $i--, 1);
- return ($task, [$guest_lock, $slot]);
+ return ($task, [$guest_lock, $slot, $storage_locks->@*]);
}
return;
@@ -1864,7 +1933,7 @@ my sub skip_after_error {
}
my sub cluster_slot_resources {
- my ($self) = @_;
+ my ($self, $task) = @_;
my $limits = PVE::VZDump::ClusterSlots::limits();
return undef if !scalar(keys $limits->%*);
@@ -1873,13 +1942,31 @@ my sub cluster_slot_resources {
if (!$self->{'cluster-slots-unsupported'}++) {
debugmsg(
'warn',
- "cluster-wide backup limits are not enforced - not all online nodes support them",
+ "cluster-wide and shared storage backup limits are not enforced - not all online"
+ . " nodes support them",
);
}
return undef;
}
- return ['cluster'];
+ my $storage_cfg = PVE::Storage::config();
+ my $shared = [grep { $storage_cfg->{ids}->{$_}->{shared} } $task->{storages}->@*];
+
+ return ['cluster', map { "storage/$_" } $shared->@*];
+}
+
+my sub render_cluster_limits {
+ my ($resources) = @_;
+ return join(', ', map { m!^storage/(.*)$! ? "storage '$1'" : "the $_" } $resources->@*);
+}
+
+my sub reached_cluster_limits {
+ my ($key) = @_;
+
+ return [] if !defined($key);
+ my $reached = eval { PVE::VZDump::ClusterSlots::reached_limits($key) };
+ die $@ if $@ =~ m/interrupted by signal$/;
+ return $reached // [];
}
my sub release_cluster_slots {
@@ -1921,7 +2008,7 @@ my sub next_guest_to_start {
my $pending = $schedule->{pending};
if (!$pending) {
my ($task, $locks) = claim_next_guest($self, $queue, $schedule->{deferred}) or return;
- my $resources = eval { cluster_slot_resources($self) };
+ my $resources = eval { cluster_slot_resources($self, $task) };
if (my $err = $@) {
unshift $queue->@*, $task;
die $err;
@@ -1977,16 +2064,22 @@ my sub next_guest_to_start {
my $waited = $schedule->{'cluster-wait'} + time() - $pending->{since};
my $maxwait = $self->{opts}->{lockwait} * 60;
if ($waited >= $maxwait) {
+ # before the release, as that removes the request
+ my $offline = offline_slot_holders(reached_cluster_limits($pending->{key}));
release_cluster_slots($pending->{key});
delete $schedule->{pending};
$schedule->{'cluster-wait'} = $waited;
- my $reason =
- 'timeout waiting for cluster-wide backup slot' . offline_slot_holders(['cluster']);
+ my $reason = "timeout waiting for cluster-wide backup slot$offline";
$reason .= " - $pending->{'request-error'}" if defined($pending->{'request-error'});
skip_task($task, $reason);
- } elsif (!$pending->{logged}++) {
- my $offline = offline_slot_holders(['cluster']);
- debugmsg('info', "VM $task->{vmid} waits for a cluster-wide backup slot$offline");
+ } elsif (defined($pending->{key}) && !$pending->{logged}++) {
+ my $reached = reached_cluster_limits($pending->{key});
+ my $reason = "queued behind other guest backups";
+ if (scalar($reached->@*)) {
+ my $limits = render_cluster_limits($reached);
+ $reason = "limit reached for $limits" . offline_slot_holders($reached);
+ }
+ debugmsg('info', "VM $task->{vmid} waits for a cluster-wide backup slot, $reason");
}
return;
diff --git a/PVE/VZDump/ClusterSlots.pm b/PVE/VZDump/ClusterSlots.pm
index 7ba47a0eb..9d199481d 100644
--- a/PVE/VZDump/ClusterSlots.pm
+++ b/PVE/VZDump/ClusterSlots.pm
@@ -14,12 +14,16 @@ use PVE::Cluster qw(cfs_read_file);
use PVE::File;
use PVE::INotify;
use PVE::RPCEnvironment;
+use PVE::Storage;
my $state_file = '/etc/pve/backup-slots.json';
# first release of pve-manager that takes part in cluster-wide limits
my $min_version = [9, 2, 31];
+# How often younger requests may get ahead of a waiting one before its limits are reserved for it.
+use constant MAX_BYPASS => 3;
+
sub limits() {
my $limits = {};
@@ -28,6 +32,13 @@ sub limits() {
$limits->{cluster} = $cluster;
}
+ my $storage_cfg = PVE::Storage::config();
+ for my $storeid (keys $storage_cfg->{ids}->%*) {
+ my $scfg = $storage_cfg->{ids}->{$storeid};
+ next if !$scfg->{shared} || !defined($scfg->{'backup-concurrency'});
+ $limits->{"storage/$storeid"} = $scfg->{'backup-concurrency'};
+ }
+
return $limits;
}
@@ -130,19 +141,36 @@ my sub remove_entries($state, $match) {
# Moves waiters that fit into all limits they count against to the holders, oldest first. Only
# resources with a limit matter, the others are tracked for information. Waiters of offline nodes
-# neither get granted nor hold up others.
+# neither get granted nor hold up others. A waiter that younger ones got ahead of too often
+# reserves a slot of each limit it counts against, so it cannot starve.
sub grant_waiters($state, $limits, $members) {
remove_entries($state, sub($entry) { !$members->{ $entry->{node} } });
my $used = used_slots($state);
+ my $passed_over = [];
+
my $waiters = $state->{waiters};
for my $key (sort { $waiters->{$a}->{seq} <=> $waiters->{$b}->{seq} } keys $waiters->%*) {
my $waiter = $waiters->{$key};
next if !$members->{ $waiter->{node} }->{online};
my $limited = [grep { defined($limits->{$_}) } $waiter->{resources}->@*];
- next if grep { ($used->{$_} // 0) >= $limits->{$_} } $limited->@*;
+ my $fits = !grep { ($used->{$_} // 0) >= $limits->{$_} } $limited->@*;
+
+ if (!$fits) {
+ if (($waiter->{bypassed} // 0) >= MAX_BYPASS) {
+ $used->{$_}++ for $limited->@*;
+ }
+ push $passed_over->@*, [$waiter, $limited];
+ next;
+ }
+
+ my %mine = map { $_ => 1 } $limited->@*;
+ for my $older ($passed_over->@*) {
+ my ($older_waiter, $older_limited) = $older->@*;
+ $older_waiter->{bypassed}++ if grep { $mine{$_} } $older_limited->@*;
+ }
$used->{$_}++ for $waiter->{resources}->@*;
$state->{holders}->{$key} = delete $waiters->{$key};
@@ -216,6 +244,16 @@ sub offline_holders($resources) {
return [sort keys $nodes->%*];
}
+sub reached_limits($key) {
+ my $state = read_state();
+ my $waiter = $state->{waiters}->{$key} or return [];
+
+ my $used = used_slots($state);
+ my $limits = limits();
+ return [grep { defined($limits->{$_}) && ($used->{$_} // 0) >= $limits->{$_} }
+ $waiter->{resources}->@*];
+}
+
# Grants waiters that fit by now, for example after limits got raised.
sub refresh() {
update_state(sub { });
diff --git a/test/vzdump_cluster_slots_test.pl b/test/vzdump_cluster_slots_test.pl
index 51ca8341d..786bbe455 100755
--- a/test/vzdump_cluster_slots_test.pl
+++ b/test/vzdump_cluster_slots_test.pl
@@ -24,11 +24,12 @@ my sub make_state($holders, $waiters) {
$state->{holders}->{$key} = { node => $node, resources => $resources };
}
for my $waiter ($waiters->@*) {
- my ($key, $node, $resources) = $waiter->@*;
+ my ($key, $node, $resources, $bypassed) = $waiter->@*;
$state->{waiters}->{$key} = {
node => $node,
resources => $resources,
seq => ++$state->{seq},
+ bypassed => $bypassed // 0,
};
}
return $state;
@@ -81,6 +82,54 @@ my $tests = [
expected => ['b'],
'expected-waiters' => [],
},
+ {
+ description => 'younger waiter with free resources gets ahead of a blocked one',
+ limits => { x => 1, y => 1 },
+ holders => [['h', 'node1', ['x']]],
+ waiters => [['a', 'node1', ['x', 'y']], ['b', 'node2', ['y']]],
+ expected => ['b', 'h'],
+ bypassed => { a => 1 },
+ },
+ {
+ description => 'waiter passed over too often reserves its resources',
+ limits => { x => 1, y => 1 },
+ holders => [['h', 'node1', ['x']]],
+ waiters => [['a', 'node1', ['x', 'y'], 3], ['b', 'node2', ['y']]],
+ expected => ['h'],
+ },
+ {
+ description => 'waiter passed over too often reserves only one slot of each resource',
+ limits => { cluster => 3, x => 1 },
+ holders => [['h', 'node1', ['cluster', 'x']]],
+ waiters => [
+ ['a', 'node1', ['cluster', 'x'], 3],
+ ['b', 'node2', ['cluster']],
+ ['c', 'node2', ['cluster']],
+ ],
+ expected => ['b', 'h'],
+ },
+ {
+ description => 'reserved resources do not hold up unrelated waiters',
+ limits => { x => 1, y => 1, z => 1 },
+ holders => [['h', 'node1', ['x']]],
+ waiters => [['a', 'node1', ['x', 'y'], 3], ['b', 'node2', ['z']]],
+ expected => ['b', 'h'],
+ },
+ {
+ description => 'resources without limit do not count as passed over',
+ limits => { x => 1 },
+ holders => [['h', 'node1', ['cluster', 'x']]],
+ waiters => [['a', 'node1', ['cluster', 'x']], ['b', 'node2', ['cluster']]],
+ expected => ['b', 'h'],
+ bypassed => { a => 0 },
+ },
+ {
+ description => 'resources without limit do not get reserved',
+ limits => { x => 1 },
+ holders => [['h', 'node1', ['cluster', 'x']]],
+ waiters => [['a', 'node1', ['cluster', 'x'], 3], ['b', 'node2', ['cluster', 'y']]],
+ expected => ['b', 'h'],
+ },
];
for my $test ($tests->@*) {
@@ -97,6 +146,34 @@ for my $test ($tests->@*) {
"$test->{description} (waiters)",
);
}
+ for my $key (sort keys(($test->{bypassed} // {})->%*)) {
+ is(
+ $state->{waiters}->{$key}->{bypassed},
+ $test->{bypassed}->{$key},
+ "$test->{description} ($key bypassed)",
+ );
+ }
+}
+
+{
+ my $limits = { cluster => 2, x => 1 };
+ my $state = make_state([['h', 'node1', ['cluster', 'x']]], [['a', 'node1', ['cluster', 'x']]]);
+ my $add_younger = sub {
+ my ($key) = @_;
+ $state->{waiters}->{$key} =
+ { node => 'node2', resources => ['cluster'], seq => ++$state->{seq} };
+ PVE::VZDump::ClusterSlots::grant_waiters($state, $limits, $members);
+ };
+ for my $younger (qw(b c d)) {
+ $add_younger->($younger);
+ delete $state->{holders}->{$younger};
+ }
+ $add_younger->('e');
+ is_deeply(granted($state), ['h'], 'younger waiters stop getting ahead after a few times');
+
+ delete $state->{holders}->{h};
+ PVE::VZDump::ClusterSlots::grant_waiters($state, $limits, $members);
+ is_deeply(granted($state), ['a', 'e'], 'passed over waiter gets its slots once they are free');
}
# Request, grant, release and cleanup against an in-memory table.
--
2.47.3
^ permalink raw reply related [relevance 18%]
* [PATCH v2 manager 11/20] vzdump: back up guests of a job in parallel
2026-11-18 13:18 14% [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-18 13:18 19% ` [PATCH v2 guest-common 04/20] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
@ 2026-11-18 13:18 21% ` Thomas Lamprecht
2026-11-18 13:18 18% ` [PATCH v2 manager 17/20] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
` (2 subsequent siblings)
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-18 13:18 UTC (permalink / raw)
To: pve-devel
Each node backed up the guests of a job strictly one after the other.
How long a job took thus depended on how its guests were spread over
the nodes: guests all on one node were backed up in series, even if
that node and the backup target could handle more.
Allow backing up several guests at the same time, up to the backup
concurrency of the node. It comes from the new node configuration
option or the datacenter-wide default, and stays at one guest unless
configured. A job can lower it with its 'concurrency' option.
Each guest backup then runs in a forked process. The job process
collects the results, prefixes the guest output in the task log with
the guest ID, keeps the warning count, and sends a single notification
as before. A guest backup process that ends without a result is
reported as failed.
Stopping the task signals all its processes, so the guest backups stop
on their own while the job process waits for them. It does not signal
them again, which could interrupt their cleanup. A stop request that
arrives while a guest backup process is being forked does not reach
that process. The new process therefore starts its backup only after
the job process confirmed that no stop request came in; otherwise the
guest counts as not started. A signal that only reached the job
process keeps it from starting further guests.
A guest listed more than once is backed up once, as its backups would
otherwise run at the same time.
Backups to external providers stay sequential, as providers are not
known to cope with backups from multiple processes. With a concurrency
of one, guests are backed up in the job process as before.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
changes v1 -> v2:
- comment why a backup process without start byte ends as interrupted
[Fiona]
- flush the output of a guest backup only once [Fiona]
- report a guest backup process that fails before its backup begins as
failed with the error, it was left as not started
Not changed [Fiona]:
- no separate message for a canceled start: end-of-file means do not
start, both after a stop request while forking and if the job process
is gone, and in the latter case nothing reads the output anymore
- no separate exit status check. The result is written once the backup
and its cleanup finished, so a non-zero exit with a result is either
an interrupted backup that the result records as failed, or a process
killed while exiting after a finished backup
PVE/NodeConfig.pm | 7 +
PVE/VZDump.pm | 257 +++++++++++++++++++++++++++++++-
test/Makefile | 6 +-
test/vzdump_concurrency_test.pl | 89 +++++++++++
4 files changed, 353 insertions(+), 6 deletions(-)
create mode 100755 test/vzdump_concurrency_test.pl
diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm
index cc1a2a296..fbd7ecf87 100644
--- a/PVE/NodeConfig.pm
+++ b/PVE/NodeConfig.pm
@@ -108,6 +108,13 @@ my $confdesc = {
default => 80,
optional => 1,
},
+ 'backup-concurrency' => {
+ description => "Maximal number of guests backed up at the same time on this node."
+ . " Overrides the datacenter-wide default.",
+ type => 'integer',
+ minimum => 1,
+ optional => 1,
+ },
};
my $wakeonlan_desc = {
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index fd2a74ab9..054665430 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -11,6 +11,7 @@ use IO::File;
use IO::Select;
use IPC::Open3;
use POSIX qw(strftime);
+use Storable;
use Time::Local;
use PVE::Cluster qw(cfs_read_file);
@@ -19,6 +20,7 @@ use PVE::Exception qw(raise_param_exc);
use PVE::HA::Config;
use PVE::HA::Env::PVE2;
use PVE::JSONSchema qw(get_standard_option);
+use PVE::NodeConfig;
use PVE::Notify;
use PVE::RPCEnvironment;
use PVE::Storage;
@@ -289,10 +291,11 @@ sub check_vmids {
my (@vmids) = @_;
my $res = [];
+ my $seen = {};
for my $vmid (sort { $a <=> $b } @vmids) {
die "ERROR: strange VM ID '${vmid}'\n" if $vmid !~ m/^\d+$/;
$vmid = int($vmid); # remove leading zeros
- next if !$vmid;
+ next if !$vmid || $seen->{$vmid}++;
push @$res, $vmid;
}
@@ -1470,6 +1473,245 @@ sub skip_all_guests {
return $tasklist;
}
+my sub fail_task {
+ my ($task, $err) = @_;
+
+ $task->{state} = 'err';
+ $task->{msg} = $err;
+ debugmsg('err', "Backup of VM $task->{vmid} failed - $err");
+}
+
+sub node_backup_concurrency {
+ my $node_conf = PVE::NodeConfig::load_config(PVE::INotify::nodename());
+
+ return $node_conf->{'backup-concurrency'}
+ // cfs_read_file('datacenter.cfg')->{'backup-concurrency'}->{node} // 1;
+}
+
+sub guest_backup_concurrency {
+ my ($self) = @_;
+
+ # external providers are not known to cope with backups from multiple processes
+ return 1 if $self->{'backup-provider'};
+
+ my $node_limit = node_backup_concurrency();
+ my $limit = $self->{opts}->{concurrency} // $node_limit;
+
+ return $limit < $node_limit ? $limit : $node_limit;
+}
+
+my $guest_result_keys = [qw(backuptime hostname log msg size state target tmplog vmtype)];
+
+my sub fork_guest_backup {
+ my ($self, $task, $running, $interrupted) = @_;
+
+ pipe(my $output_reader, my $output_writer) or die "unable to create pipe - $!\n";
+ pipe(my $result_reader, my $result_writer) or die "unable to create pipe - $!\n";
+ pipe(my $start_reader, my $start_writer) or die "unable to create pipe - $!\n";
+
+ # Until the child set up its own handlers, a signal would only reach the inherited one of the
+ # job process and get lost.
+ my $signals = POSIX::SigSet->new(
+ POSIX::SIGINT(),
+ POSIX::SIGTERM(),
+ POSIX::SIGQUIT(),
+ POSIX::SIGHUP(),
+ POSIX::SIGPIPE(),
+ );
+ my $old_mask = POSIX::SigSet->new();
+ POSIX::sigprocmask(POSIX::SIG_BLOCK(), $signals, $old_mask)
+ or die "unable to block signals - $!\n";
+
+ my $pid = fork();
+ if (!defined($pid)) {
+ my $err = $!;
+ POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old_mask);
+ die "unable to fork guest backup - $err\n";
+ }
+
+ if (!$pid) {
+ my $interrupted = 0;
+ $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
+ # a second signal must not abort the cleanup the first one started
+ die "interrupted by signal\n" if !$interrupted++;
+ };
+
+ my $exitcode = 1;
+ eval {
+ POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old_mask);
+ close($output_reader);
+ close($result_reader);
+ close($start_writer);
+ # only the job process reads the output of the other guest backups
+ for my $sibling (values $running->%*) {
+ close($_) for grep { defined } $sibling->@{qw(output result)};
+ }
+ open(STDOUT, '>&', $output_writer) or die "unable to redirect STDOUT - $!\n";
+ open(STDERR, '>&', $output_writer) or die "unable to redirect STDERR - $!\n";
+ close($output_writer);
+
+ # The job process closes the pipe without writing if it got a stop request while
+ # forking, which this process missed, so end as if it got that signal.
+ sysread($start_reader, my $start, 1) or die "interrupted by signal\n";
+ close($start_reader);
+
+ PVE::INotify::inotify_close();
+
+ eval { $self->exec_backup_task($task) };
+ my $err = $@;
+ # errors of the backup itself are handled there, so this one came up before it began
+ if ($err && $err !~ m/^interrupted by signal$/ && $task->{state} eq 'todo') {
+ chomp($err);
+ fail_task($task, $err);
+ undef $err;
+ }
+
+ my $result = { map { $_ => $task->{$_} } $guest_result_keys->@* };
+ print $result_writer Storable::nfreeze($result);
+ close($result_writer);
+
+ die $err if $err;
+ $exitcode = 0;
+ };
+ warn $@ if $@ && $@ !~ m/^interrupted by signal$/;
+ STDOUT->flush();
+ POSIX::_exit($exitcode);
+ }
+
+ POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old_mask);
+
+ close($output_writer);
+ close($result_writer);
+ close($start_reader);
+
+ # A stop request that came in while forking reached only the job process, so the backup
+ # process must not start then.
+ my $cancelled = $$interrupted;
+ if (!$cancelled) {
+ local $SIG{PIPE} = 'IGNORE';
+ syswrite($start_writer, '1');
+ }
+ close($start_writer);
+
+ return {
+ pid => $pid,
+ cancelled => $cancelled,
+ task => $task,
+ output => $output_reader,
+ result => $result_reader,
+ 'output-buffer' => '',
+ 'result-data' => '',
+ };
+}
+
+my sub forward_guest_output {
+ my ($child, $data, $final) = @_;
+
+ my $vmid = $child->{task}->{vmid};
+
+ $child->{'output-buffer'} .= $data;
+ $child->{'output-buffer'} .= "\n" if $final && length($child->{'output-buffer'});
+
+ while ($child->{'output-buffer'} =~ s/^(.*)\n//) {
+ my $line = $1;
+ # a guest backup process counts its own warnings, and that count is lost when it exits
+ PVE::RPCEnvironment::get()->{warning_count}++ if $line =~ m/^WARN: /;
+ print STDERR "$vmid: $line\n";
+ }
+}
+
+my sub close_guest_backup_pipe {
+ my ($child, $kind) = @_;
+
+ close(delete $child->{$kind});
+ forward_guest_output($child, '', 1) if $kind eq 'output';
+}
+
+my sub read_guest_backup_pipe {
+ my ($child, $kind) = @_;
+
+ my $count = sysread($child->{$kind}, my $data, 64 * 1024);
+ return if !defined($count) && ($!{EINTR} || $!{EAGAIN});
+
+ if (!$count) {
+ close_guest_backup_pipe($child, $kind);
+ } elsif ($kind eq 'output') {
+ forward_guest_output($child, $data);
+ } else {
+ $child->{'result-data'} .= $data;
+ }
+}
+
+my sub finish_guest_backup {
+ my ($child, $status) = @_;
+
+ # the backup process is gone, but helpers it started might still hold the output pipe
+ for my $kind (qw(result output)) {
+ while ($child->{$kind} && IO::Select->new($child->{$kind})->can_read(0)) {
+ read_guest_backup_pipe($child, $kind);
+ }
+ close_guest_backup_pipe($child, $kind) if $child->{$kind};
+ }
+ return if $child->{cancelled};
+
+ my $task = $child->{task};
+ my $result = eval { Storable::thaw($child->{'result-data'}) };
+ if (ref($result) eq 'HASH') {
+ $task->{$_} = $result->{$_} for keys $result->%*;
+ } else {
+ my $reason = $status & 127 ? "signal " . ($status & 127) : "exit code " . ($status >> 8);
+ fail_task($task, "backup process ended unexpectedly ($reason)");
+ }
+}
+
+my sub exec_parallel_backup_tasks {
+ my ($self, $tasklist, $concurrency) = @_;
+
+ my @queue = $tasklist->@*;
+ my $running = {};
+ my $interrupted = 0;
+ my $job_pid = $$;
+
+ # Stopping a task signals all its processes, so the guest backups stop on their own. Signalling
+ # them again could interrupt their cleanup.
+ local $SIG{INT} = local $SIG{TERM} = local $SIG{QUIT} = local $SIG{HUP} = local $SIG{PIPE} =
+ sub { $interrupted = 1; };
+
+ while (scalar(@queue) || scalar(keys $running->%*)) {
+ while (!$interrupted && scalar(@queue) && scalar(keys $running->%*) < $concurrency) {
+ my $task = shift @queue;
+ my $child = eval { fork_guest_backup($self, $task, $running, \$interrupted) };
+ # a guest backup process signalled while it exits dies into this eval
+ POSIX::_exit(1) if $$ != $job_pid;
+ if (my $err = $@) {
+ fail_task($task, $err);
+ next;
+ }
+ $running->{ $child->{pid} } = $child;
+ unshift @queue, $task if $child->{cancelled};
+ }
+
+ last if $interrupted && !scalar(keys $running->%*);
+
+ my $handles = {};
+ for my $child (values $running->%*) {
+ $handles->{ fileno($child->{$_}) } = [$child, $_]
+ for grep { $child->{$_} } qw(output result);
+ }
+ my $select = IO::Select->new(map { $_->[0]->{ $_->[1] } } values $handles->%*);
+ for my $fh ($select->can_read(1)) {
+ read_guest_backup_pipe($handles->{ fileno($fh) }->@*);
+ }
+
+ for my $pid (keys $running->%*) {
+ next if waitpid($pid, POSIX::WNOHANG()) != $pid;
+ finish_guest_backup(delete $running->{$pid}, $?);
+ }
+ }
+
+ die "interrupted by signal\n" if $interrupted;
+}
+
sub exec_backup {
my ($self, $rpcenv, $authuser) = @_;
@@ -1490,22 +1732,27 @@ sub exec_backup {
open my $job_start_fd, '>', \$job_start_log;
open my $job_end_fd, '>', \$job_end_log;
+ my $concurrency = $self->guest_backup_concurrency();
+ $concurrency = scalar($tasklist->@*) if scalar($tasklist->@*) < $concurrency;
+
my $starttime = time();
- my $errcount = 0;
eval {
$self->{'backup-provider'}->job_init($starttime) if $self->{'backup-provider'};
$self->run_hook_script('job-start', undef, $job_start_fd);
- foreach my $task (@$tasklist) {
- $self->exec_backup_task($task);
- $errcount += 1 if $task->{state} ne 'ok';
+ if ($concurrency > 1) {
+ debugmsg('info', "running up to $concurrency guest backups at the same time");
+ exec_parallel_backup_tasks($self, $tasklist, $concurrency);
+ } else {
+ $self->exec_backup_task($_) for $tasklist->@*;
}
$self->{'backup-provider'}->job_cleanup() if $self->{'backup-provider'};
$self->run_hook_script('job-end', undef, $job_end_fd);
};
my $err = $@;
+ my $errcount = grep { $_->{state} ne 'ok' } $tasklist->@*;
if ($err) {
if ($self->{'backup-provider'}) {
diff --git a/test/Makefile b/test/Makefile
index 91761579d..bbe87a7c3 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -18,7 +18,7 @@ replication%.t: replication_test%.pl
./$<
.PHONY: test-vzdump
-test-vzdump: test-vzdump-guest-included test-vzdump-new
+test-vzdump: test-vzdump-guest-included test-vzdump-new test-vzdump-concurrency
.PHONY: test-vzdump-guest-included
test-vzdump-guest-included:
@@ -28,6 +28,10 @@ test-vzdump-guest-included:
test-vzdump-new:
./vzdump_new_test.pl
+.PHONY: test-vzdump-concurrency
+test-vzdump-concurrency:
+ ./vzdump_concurrency_test.pl
+
.PHONY: test-osd
test-osd:
./OSD_test.pl
diff --git a/test/vzdump_concurrency_test.pl b/test/vzdump_concurrency_test.pl
new file mode 100755
index 000000000..46d679490
--- /dev/null
+++ b/test/vzdump_concurrency_test.pl
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib '..';
+
+use Test::More;
+use Test::MockModule;
+
+use PVE::VZDump;
+
+my $node_config = {};
+my $datacenter_config = {};
+
+my $node_config_module = Test::MockModule->new('PVE::NodeConfig');
+$node_config_module->mock(load_config => sub { return $node_config; });
+
+my $vzdump_module = Test::MockModule->new('PVE::VZDump');
+$vzdump_module->mock(
+ cfs_read_file => sub {
+ my ($filename) = @_;
+ die "unexpected file '$filename'\n" if $filename ne 'datacenter.cfg';
+ return $datacenter_config;
+ },
+);
+
+my $tests = [
+ {
+ description => 'defaults keep backing up one guest at a time',
+ expected => 1,
+ },
+ {
+ description => 'datacenter default applies to the node',
+ datacenter => 4,
+ expected => 4,
+ },
+ {
+ description => 'node configuration overrides datacenter default',
+ datacenter => 4,
+ node => 2,
+ expected => 2,
+ },
+ {
+ description => 'node configuration applies without datacenter default',
+ node => 3,
+ expected => 3,
+ },
+ {
+ description => 'job limit lowers node limit',
+ node => 4,
+ job => 2,
+ expected => 2,
+ },
+ {
+ description => 'job limit cannot raise node limit',
+ node => 2,
+ job => 8,
+ expected => 2,
+ },
+ {
+ description => 'job limit does not raise the default',
+ job => 8,
+ expected => 1,
+ },
+ {
+ description => 'external backup providers back up one guest at a time',
+ node => 4,
+ job => 4,
+ provider => 1,
+ expected => 1,
+ },
+];
+
+for my $test ($tests->@*) {
+ $datacenter_config =
+ defined($test->{datacenter})
+ ? { 'backup-concurrency' => { node => $test->{datacenter} } }
+ : {};
+ $node_config = defined($test->{node}) ? { 'backup-concurrency' => $test->{node} } : {};
+
+ my $self = bless { opts => {} }, 'PVE::VZDump';
+ $self->{opts}->{concurrency} = $test->{job} if defined($test->{job});
+ $self->{'backup-provider'} = {} if $test->{provider};
+
+ is($self->guest_backup_concurrency(), $test->{expected}, $test->{description});
+}
+
+done_testing();
--
2.47.3
^ permalink raw reply related [relevance 21%]
* [PATCH v2 docs 20/20] vzdump: document concurrent backups and their limits
2026-11-18 13:18 14% [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits Thomas Lamprecht
` (3 preceding siblings ...)
2026-11-18 13:18 15% ` [PATCH v2 manager 19/20] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
@ 2026-11-18 13:18 19% ` Thomas Lamprecht
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-18 13:18 UTC (permalink / raw)
To: pve-devel
Describe how many guests a node backs up at the same time and that the
bandwidth limit applies to each of them, how jobs can run alongside
each other, and the cluster-wide and storage limits, including how to
size them and what happens with slots of an offline node.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
changes v1 -> v2:
- jobs to an external backup provider ignore 'concurrency' and 'overlap'
- a job starts no other guests while one waits for cluster-wide slots
- say what happens once a wait ends, which limits need all nodes to be
upgraded, and that overlapping jobs share the node limit
vzdump.adoc | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
diff --git a/vzdump.adoc b/vzdump.adoc
index 44db027..241c38c 100644
--- a/vzdump.adoc
+++ b/vzdump.adoc
@@ -308,6 +308,122 @@ the `performance` setting, `max-workers` (affects VM backups only) and
`pbs-entries-max` (affects container backups only). See the
xref:vzdump_configuration[configuration options] for details.
+[[vzdump_concurrency]]
+Concurrent Backups
+------------------
+
+By default, a node runs one backup job at a time and backs up its guests one
+after the other. A job that is due while another one runs waits for it, up to
+the `lockwait` time. As each node backs up its own guests, how long a job takes
+and how much load it puts on the backup target depend on how its guests are
+spread over the nodes. The settings described here allow backing up several
+guests of a node at the same time, running jobs alongside each other, and
+limiting the load on shared storages and backup servers.
+
+Node Limit and Job Concurrency
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The backup concurrency of a node limits how many guests it backs up at the same
+time, across all jobs. Set the default for all nodes in the datacenter options
+(`backup-concurrency` in `datacenter.cfg`), and override it for single nodes in
+their options (`backup-concurrency` in the node configuration):
+
+----
+# pvesh set /cluster/options --backup-concurrency 4
+# pvenode config set --backup-concurrency 8
+----
+
+A job backs up as many guests at the same time as its node allows. With the
+`concurrency` job option ('Concurrency' in the 'Advanced' tab), a job can use
+fewer, but not more.
+
+Size the node limit by what the node itself can handle, that is, its CPU,
+memory, network connection, and local disks. Each parallel guest backup runs its
+own compressor or Proxmox Backup Server client. The `bwlimit` setting applies to
+each guest backup on its own, so the bandwidth of a node can add up to the
+configured limit times the number of guests backed up at the same time.
+
+Jobs Running Alongside Each Other
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Jobs with the `overlap` option ('Overlap' in the 'Advanced' tab) run at the same
+time as other jobs that have it enabled, for example, a short hourly job
+alongside a long nightly one. Together, they stay within the backup concurrency
+of the node, so with the default of one, still only one guest is backed up at a
+time. A job without the option still runs alone, and while it waits for running
+jobs to finish, overlapping jobs that are due later do not start before it.
+Waiting for a free backup slot of the node is not limited by `lockwait`.
+
+If two running jobs include the same guest, the second one backs it up once the
+first one is done with it, or skips it after waiting `lockwait` minutes.
+
+Jobs to an external backup provider ignore the `concurrency` and `overlap`
+options. They back up one guest at a time and always run alone.
+
+NOTE: The job phases of hook scripts can overlap for overlapping jobs. For
+example, a hook script that mounts a disk in the `job-start` phase and unmounts
+it in the `job-end` phase must not be used for overlapping jobs. With a job
+concurrency above one, the phases of different guests of a job overlap as well.
+
+Cluster-wide and Storage Limits
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Each node runs its part of a job on its own, so in a cluster, shared storages
+and backup servers get the backups of all nodes at the same time. To protect
+them, you can limit how many guest backups run at the same time:
+
+* for the whole cluster, with the `cluster` key of `backup-concurrency` in the
+ datacenter options ('Cluster-Wide' in the UI),
+* for a storage, with its `backup-concurrency` option ('Backup Concurrency' in
+ the advanced storage settings). It counts guest backups that use the storage
+ as backup target or for included guest disks, but not for fleecing or
+ temporary files. For a shared storage, the limit applies to the whole cluster,
+ for a local storage to each node.
+
+----
+# pvesh set /cluster/options --backup-concurrency node=8,cluster=12
+# pvesm set pbs-main --backup-concurrency 6
+----
+
+A guest backup only starts once all limits it counts against have room. Size
+the cluster-wide and storage limits by what the shared systems can handle,
+independent of the node limits. With such limits in place, raising the node
+limits cannot overload the shared systems.
+
+TIP: Several storage entries can refer to the same system, for example,
+namespaces of a Proxmox Backup Server or pools of a Ceph cluster. Their limits
+count separately, so use the cluster-wide limit to bound their sum.
+
+The cluster-wide limit and the limits of shared storages are counted in
+cluster-wide slots, which guest backups get in the order they started waiting.
+One that waits for a storage at its limit lets others with room go first, but
+only a few times. A job has at most one guest waiting for cluster-wide slots at
+a time and starts no other guests meanwhile. It waits for these slots at most
+`lockwait` minutes in total and skips guests that did not get them by then. Like
+for node slots, waiting for free slots of a local storage is not limited by
+`lockwait`. The task log tells which limit a guest waits for.
+
+To see which guest backups hold or wait for cluster-wide slots, use:
+
+----
+# pvesh get /cluster/backup-info/slots
+----
+
+Granting cluster-wide slots requires quorum, and the cluster-wide and shared
+storage limits are only enforced once all online nodes of the cluster run a
+version that supports them. Until then, the task log warns that they are not
+enforced. Guest backups that started before that, or while neither a
+cluster-wide limit nor a limit on a shared storage was set, do not count against
+them. Slots of a node that goes offline stay taken, as its guest backups might
+still be running, and the node releases them once it is back. Guest backups that
+wait for such slots name the node in the task log. Once you made sure that its
+backups stopped, for example because the node is powered off, you can release
+its slots manually:
+
+----
+# pvesh delete /cluster/backup-info/slots/NODE
+----
+
[[vzdump_retention]]
Backup Retention
----------------
--
2.47.3
^ permalink raw reply related [relevance 19%]
* [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits
@ 2026-11-18 13:18 14% Thomas Lamprecht
2026-11-18 13:18 19% ` [PATCH v2 guest-common 04/20] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
` (4 more replies)
0 siblings, 5 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-18 13:18 UTC (permalink / raw)
To: pve-devel
This is v2 of the series [0], addressing Fiona's review (thanks!) and
some additional findings since v1. Patch 16 now uses
node_pvecfg_version_at_least() from pve-cluster [1], which got applied
in the meantime.
changes v1 -> v2:
- drop the container patch, it got applied
- new patches 5 and 15
- fix the node version check, which failed jobs with a cluster-wide or
shared storage limit on clusters with qemu-server 9.2.15 or newer
- after lowering a limit, guest backups start again as soon as fewer
than the new limit run, and waiting jobs pick up changed limits
- less noise in the task log while waiting, and better handling of
quorum loss, offline nodes and an unparsable slot table
- rebase onto current master
- details are in the per-patch changelogs, those of patches 6 and 11
also explain the review points not followed
[0]: https://lore.proxmox.com/pve-devel/20261101225849.884587-1-t.lamprecht@proxmox.com/
[1]: https://lore.proxmox.com/pve-devel/20261103124831.139399-3-f.ebner@proxmox.com/
Original cover letter
=====================
A node runs one backup job at a time, and that job backs up its guests one
after the other. This leads to odd load distributions depending on how the
guests of a job are distributed in a cluster. The extreme cases: If all are
on one node all get backed up in series, adding potentially a lot of delay
but being rather lenient on the backup target (storage/server). If all are
spread such that each guest is on a different node all will get backed up
concurrently, being potentially much faster but also putting a lot of load
towards the target. There is no real control over that so depending on
current guest distribution a job might run slow, ok or fast, overload or
underuse targets.
This series adds:
- parallel guest backups within a job, up to a per-node backup
concurrency, set as datacenter default or per node; a job can lower
it with its new 'concurrency' option,
- the 'overlap' job option to run alongside other such jobs, together
within the node's backup concurrency,
- cluster-wide and per-storage limits that protect shared storages and
backup servers from too many guest backups at the same time.
The new settings are opt-in: without them, each node still backs up one
guest at a time and jobs do not overlap.
The node limit and the limits of local storages use file locks on each
node. The cluster-wide limit and those of shared storages use a slot
table on pmxcfs, changed under a cluster lock. Waiting guest backups
get their slots in order, and one held up by a full storage cannot
starve. The slot table is only used once all online nodes run a version
that supports it; until then, the cluster-wide and shared storage limits
are not enforced and the task log warns.
Patches 5 to 10 fix or improve existing behavior, for example stopping
all backup jobs of a node, and naming the error and the skipped guests
of a job that could not start. They could be applied ahead of the rest.
Repo (build-)dependencies:
pve-manager -> pve-guest-common, pve-cluster, pve-storage
A separate series on top adds a start window option for backup jobs.
Besides the unit tests, I tested this end to end on nested clusters
and on a three node cluster with Ceph and HA, also with PBS and NFS
targets, guests that keep writing during their backup, node failures,
quorum loss, stopped jobs and a rolling upgrade.
pve-cluster:
Thomas Lamprecht (2):
datacenter config: add backup concurrency setting
datacenter config: backup concurrency: add cluster-wide limit
src/PVE/DataCenterConfig.pm | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
pve-storage:
Thomas Lamprecht (1):
add backup concurrency option to storages
src/PVE/Storage/BTRFSPlugin.pm | 1 +
src/PVE/Storage/CIFSPlugin.pm | 1 +
src/PVE/Storage/CephFSPlugin.pm | 1 +
src/PVE/Storage/DirPlugin.pm | 1 +
src/PVE/Storage/ISCSIDirectPlugin.pm | 1 +
src/PVE/Storage/ISCSIPlugin.pm | 1 +
src/PVE/Storage/LVMPlugin.pm | 1 +
src/PVE/Storage/LvmThinPlugin.pm | 1 +
src/PVE/Storage/NFSPlugin.pm | 1 +
src/PVE/Storage/PBSPlugin.pm | 1 +
src/PVE/Storage/Plugin.pm | 9 +++++++++
src/PVE/Storage/RBDPlugin.pm | 1 +
src/PVE/Storage/ZFSPlugin.pm | 1 +
src/PVE/Storage/ZFSPoolPlugin.pm | 1 +
src/test/plugin_properties_test.pm | 5 +++--
15 files changed, 25 insertions(+), 2 deletions(-)
pve-guest-common:
Thomas Lamprecht (1):
vzdump: add options for parallel guest backups and overlapping jobs
src/PVE/VZDump/Common.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
pve-manager:
Thomas Lamprecht (15):
vzdump: drop never-set fallback for the lock wait time
vzdump: notification: capture guest logs right after each backup
vzdump: stop all running backup jobs of the node
vzdump: show the error if a job could not get the global lock
vzdump: run job-init hook and set up target once the job may start
vzdump: list guests as skipped if the job could not start
vzdump: back up guests of a job in parallel
vzdump: allow jobs to run alongside each other
ui: options: add backup concurrency for datacenter and nodes
ui: backup job: add concurrency and overlap options
ui: backup now: add overlap option
vzdump: limit concurrent guest backups cluster-wide
vzdump: honor backup concurrency limits of storages
api: backup info: add endpoints for cluster-wide backup slots
ui: add cluster-wide and storage backup concurrency limits
PVE/API2/Cluster/BackupInfo.pm | 106 ++-
PVE/API2/VZDump.pm | 14 +-
PVE/Makefile | 2 +-
PVE/NodeConfig.pm | 7 +
PVE/Service/pvescheduler.pm | 4 +
PVE/VZDump.pm | 893 ++++++++++++++++++--
PVE/VZDump/ClusterSlots.pm | 296 +++++++
PVE/VZDump/Makefile | 15 +
debian/tmpfiles | 5 +-
test/Makefile | 10 +-
test/vzdump_cluster_slots_test.pl | 282 +++++++
test/vzdump_concurrency_test.pl | 89 ++
test/vzdump_new_test.pl | 1 +
www/manager6/dc/OptionView.js | 22 +
www/manager6/node/NodeOptionsView.js | 8 +
www/manager6/panel/BackupAdvancedOptions.js | 40 +-
www/manager6/storage/Base.js | 17 +
www/manager6/window/Backup.js | 28 +-
18 files changed, 1773 insertions(+), 66 deletions(-)
pve-docs:
Thomas Lamprecht (1):
vzdump: document concurrent backups and their limits
vzdump.adoc | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
--
2.47.3
^ permalink raw reply [relevance 14%]
* [PATCH v2 manager 19/20] ui: add cluster-wide and storage backup concurrency limits
2026-11-18 13:18 14% [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits Thomas Lamprecht
` (2 preceding siblings ...)
2026-11-18 13:18 18% ` [PATCH v2 manager 17/20] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
@ 2026-11-18 13:18 15% ` Thomas Lamprecht
2026-11-18 13:18 19% ` [PATCH v2 docs 20/20] vzdump: document concurrent backups and their limits Thomas Lamprecht
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-18 13:18 UTC (permalink / raw)
To: pve-devel
Expose the cluster-wide limit next to the per-node one in the
datacenter options, and the limit of a storage in the advanced section
of the storage edit window, so admins can protect shared systems from
too many parallel backups without editing configuration files.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
changes v1 -> v2:
- use title case for the 'Cluster-Wide' label
www/manager6/dc/OptionView.js | 8 ++++++++
www/manager6/storage/Base.js | 17 +++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index 4a7e9692a..8f10cba2b 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -372,6 +372,14 @@ Ext.define('PVE.dc.OptionView', {
minValue: 1,
submitValue: true,
},
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'cluster',
+ fieldLabel: gettext('Cluster-Wide'),
+ emptyText: gettext('Unlimited'),
+ minValue: 1,
+ submitValue: true,
+ },
],
});
me.add_inputpanel_row('next-id', gettext('Next Free Guest ID'), {
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 439cfeb88..753e9406b 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -109,6 +109,23 @@ Ext.define('PVE.panel.StorageBase', {
}
};
+ if (me.type !== 'esxi') {
+ addAdvancedWidget({
+ xtype: 'proxmoxintegerfield',
+ name: 'backup-concurrency',
+ fieldLabel: gettext('Backup Concurrency'),
+ emptyText: gettext('Unlimited'),
+ minValue: 1,
+ deleteEmpty: !me.isCreate,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext(
+ 'Guest backups using this storage at the same time, as target or for guest disks. Counted for the whole cluster if the storage is shared, otherwise on each node.',
+ ),
+ },
+ });
+ }
+
const qemuImgStorageTypes = ['dir', 'btrfs', 'nfs', 'cifs'];
if (qemuImgStorageTypes.includes(me.type)) {
--
2.47.3
^ permalink raw reply related [relevance 15%]
* [PATCH v2 guest-common 04/20] vzdump: add options for parallel guest backups and overlapping jobs
2026-11-18 13:18 14% [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits Thomas Lamprecht
@ 2026-11-18 13:18 19% ` Thomas Lamprecht
2026-11-18 13:18 21% ` [PATCH v2 manager 11/20] vzdump: back up guests of a job in parallel Thomas Lamprecht
` (3 subsequent siblings)
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-18 13:18 UTC (permalink / raw)
To: pve-devel
A node only ever runs one backup job, and that job backs up its guests
one after the other. How long a job takes thus depends on how its
guests happen to be spread over the nodes, and a short job has to wait
until a long one finishes, failing once the lock wait time is
exceeded.
The new 'concurrency' option allows backing up several guests of a job
at the same time, up to the backup concurrency of the node. The
bandwidth limit then applies to each of them, as its description now
says. The 'overlap' option lets a job run alongside other jobs that
allow it as well. It is off by default, as existing hook scripts may
rely on job phases never overlapping.
With overlapping jobs the same guest can be part of two running
backups, and with cluster-wide limits a guest backup can wait for a
slot, so the lock wait now also bounds these waits.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
changes v1 -> v2:
- reword the commit message
src/PVE/VZDump/Common.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/PVE/VZDump/Common.pm b/src/PVE/VZDump/Common.pm
index 2cb48a3..26d7799 100644
--- a/src/PVE/VZDump/Common.pm
+++ b/src/PVE/VZDump/Common.pm
@@ -298,7 +298,7 @@ my $confdesc = {
},
bwlimit => {
type => 'integer',
- description => "Limit I/O bandwidth (in KiB/s).",
+ description => "Limit I/O bandwidth of each guest backup (in KiB/s).",
optional => 1,
minimum => 0,
default => 0,
@@ -328,11 +328,27 @@ my $confdesc = {
},
lockwait => {
type => 'integer',
- description => "Maximal time to wait for the global lock (minutes).",
+ description =>
+ "Maximal time to wait for the global lock, for guests that another backup"
+ . " is currently processing, and for cluster-wide backup slots (minutes).",
optional => 1,
minimum => 0,
default => 3 * 60, # 3 hours
},
+ concurrency => {
+ type => 'integer',
+ description => "Maximal number of guests to back up at the same time on each node."
+ . " Defaults to, and is limited by, the backup concurrency configured for the node.",
+ optional => 1,
+ minimum => 1,
+ },
+ overlap => {
+ type => 'boolean',
+ description => "Allow running at the same time as other backups on the same node that"
+ . " also allow it. The job phases of their hook scripts can then overlap.",
+ optional => 1,
+ default => 0,
+ },
stopwait => {
type => 'integer',
description => "Maximal time to wait until a guest system is stopped (minutes).",
--
2.47.3
^ permalink raw reply related [relevance 19%]
* [PATCH guest-common,manager,docs 0/5] backup jobs: add a start window
@ 2026-11-01 23:20 10% Thomas Lamprecht
0 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-01 23:20 UTC (permalink / raw)
To: pve-devel
A backup job can run into business hours, for example when it has to
wait for other jobs first or backing up its guests takes longer than
planned, and nothing stops it from starting further guest backups then.
The new 'start-window' job option sets how many minutes after the
scheduled start guest backups may still begin. Running guest backups
finish, and guests not started in time are reported as skipped. The
window also bounds waiting for the global lock and for backup slots.
It counts from the scheduled time, so a missed run repeated later only
gets what is left of it.
This applies on top of the series "parallel guest backups and backup
concurrency limits" [0].
[0]: https://lore.proxmox.com/pve-devel/20261101225849.884587-1-t.lamprecht@proxmox.com/
Repo (build-)dependencies:
pve-manager -> pve-guest-common
pve-guest-common must be released first, see the note on patch 3.
pve-guest-common:
Thomas Lamprecht (1):
vzdump: add option to stop starting guest backups after a time window
src/PVE/VZDump/Common.pm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
pve-manager:
Thomas Lamprecht (3):
jobs: pass scheduled run time to job plugins
vzdump: honor start window for guest backups
ui: backup job: add start window option
PVE/API2/Backup.pm | 2 +-
PVE/API2/VZDump.pm | 18 ++++++--
PVE/Jobs.pm | 2 +-
PVE/Jobs/VZDump.pm | 3 +-
PVE/VZDump.pm | 51 +++++++++++++++++----
www/manager6/panel/BackupAdvancedOptions.js | 21 +++++++++
6 files changed, 81 insertions(+), 16 deletions(-)
pve-docs:
Thomas Lamprecht (1):
vzdump: document the start window
vzdump.adoc | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
--
2.47.3
^ permalink raw reply [relevance 10%]
* [PATCH manager 11/19] vzdump: back up guests of a job in parallel
2026-11-01 22:58 15% [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-01 22:58 19% ` [PATCH guest-common 04/19] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
@ 2026-11-01 22:58 21% ` Thomas Lamprecht
2026-11-01 22:58 19% ` [PATCH manager 16/19] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
` (2 subsequent siblings)
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-01 22:58 UTC (permalink / raw)
To: pve-devel
Each node backed up the guests of a job strictly one after the other.
How long a job took thus depended on how its guests were spread over
the nodes: guests all on one node were backed up in series, even if
that node and the backup target could handle more.
Allow backing up several guests at the same time, up to the backup
concurrency of the node. It comes from the new node configuration
option or the datacenter-wide default, and stays at one guest unless
configured. A job can lower it with its 'concurrency' option.
Each guest backup then runs in a forked process. The job process
collects the results, prefixes the guest output in the task log with
the guest ID, keeps the warning count, and sends a single notification
as before. A guest backup process that ends without a result is
reported as failed.
Stopping the task signals all its processes, so the guest backups stop
on their own while the job process waits for them. It does not signal
them again, which could interrupt their cleanup. A stop request that
arrives while a guest backup process is forked does not reach that
process, so it only starts its backup once the job process confirmed
that there was none; otherwise the guest counts as not started. A
signal that only reached the job process keeps it from starting
further guests.
A guest listed more than once is backed up once, as its backups would
otherwise run at the same time.
Backups to external providers stay sequential, as providers are not
known to cope with backups from multiple processes. With a concurrency
of one, guests are backed up in the job process as before.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
PVE/NodeConfig.pm | 7 +
PVE/VZDump.pm | 244 +++++++++++++++++++++++++++++++-
test/Makefile | 6 +-
test/vzdump_concurrency_test.pl | 89 ++++++++++++
4 files changed, 340 insertions(+), 6 deletions(-)
create mode 100755 test/vzdump_concurrency_test.pl
diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm
index cc1a2a296..fbd7ecf87 100644
--- a/PVE/NodeConfig.pm
+++ b/PVE/NodeConfig.pm
@@ -108,6 +108,13 @@ my $confdesc = {
default => 80,
optional => 1,
},
+ 'backup-concurrency' => {
+ description => "Maximal number of guests backed up at the same time on this node."
+ . " Overrides the datacenter-wide default.",
+ type => 'integer',
+ minimum => 1,
+ optional => 1,
+ },
};
my $wakeonlan_desc = {
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index b12281790..33fe8793e 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -11,6 +11,7 @@ use IO::File;
use IO::Select;
use IPC::Open3;
use POSIX qw(strftime);
+use Storable;
use Time::Local;
use PVE::Cluster qw(cfs_read_file);
@@ -19,6 +20,7 @@ use PVE::Exception qw(raise_param_exc);
use PVE::HA::Config;
use PVE::HA::Env::PVE2;
use PVE::JSONSchema qw(get_standard_option);
+use PVE::NodeConfig;
use PVE::Notify;
use PVE::RPCEnvironment;
use PVE::Storage;
@@ -288,10 +290,11 @@ sub check_vmids {
my (@vmids) = @_;
my $res = [];
+ my $seen = {};
for my $vmid (sort { $a <=> $b } @vmids) {
die "ERROR: strange VM ID '${vmid}'\n" if $vmid !~ m/^\d+$/;
$vmid = int($vmid); # remove leading zeros
- next if !$vmid;
+ next if !$vmid || $seen->{$vmid}++;
push @$res, $vmid;
}
@@ -1454,6 +1457,232 @@ sub skip_all_guests {
return $tasklist;
}
+my sub fail_task {
+ my ($task, $err) = @_;
+
+ $task->{state} = 'err';
+ $task->{msg} = $err;
+ debugmsg('err', "Backup of VM $task->{vmid} failed - $err");
+}
+
+sub node_backup_concurrency {
+ my $node_conf = PVE::NodeConfig::load_config(PVE::INotify::nodename());
+
+ return $node_conf->{'backup-concurrency'}
+ // cfs_read_file('datacenter.cfg')->{'backup-concurrency'}->{node} // 1;
+}
+
+sub guest_backup_concurrency {
+ my ($self) = @_;
+
+ # external providers are not known to cope with backups from multiple processes
+ return 1 if $self->{'backup-provider'};
+
+ my $node_limit = node_backup_concurrency();
+ my $limit = $self->{opts}->{concurrency} // $node_limit;
+
+ return $limit < $node_limit ? $limit : $node_limit;
+}
+
+my $guest_result_keys = [qw(backuptime hostname log msg size state target tmplog vmtype)];
+
+my sub fork_guest_backup {
+ my ($self, $task, $running, $interrupted) = @_;
+
+ pipe(my $output_reader, my $output_writer) or die "unable to create pipe - $!\n";
+ pipe(my $result_reader, my $result_writer) or die "unable to create pipe - $!\n";
+ pipe(my $start_reader, my $start_writer) or die "unable to create pipe - $!\n";
+
+ # Until the child set up its own handlers, a signal would only reach the inherited one of the
+ # job process and get lost.
+ my $signals = POSIX::SigSet->new(
+ POSIX::SIGINT(),
+ POSIX::SIGTERM(),
+ POSIX::SIGQUIT(),
+ POSIX::SIGHUP(),
+ POSIX::SIGPIPE(),
+ );
+ my $old_mask = POSIX::SigSet->new();
+ POSIX::sigprocmask(POSIX::SIG_BLOCK(), $signals, $old_mask)
+ or die "unable to block signals - $!\n";
+
+ my $pid = fork();
+ if (!defined($pid)) {
+ my $err = $!;
+ POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old_mask);
+ die "unable to fork guest backup - $err\n";
+ }
+
+ if (!$pid) {
+ my $interrupted = 0;
+ $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
+ # a second signal must not abort the cleanup the first one started
+ die "interrupted by signal\n" if !$interrupted++;
+ };
+
+ my $exitcode = 1;
+ eval {
+ POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old_mask);
+ close($output_reader);
+ close($result_reader);
+ close($start_writer);
+ # only the job process reads the output of the other guest backups
+ for my $sibling (values $running->%*) {
+ close($_) for grep { defined } $sibling->@{qw(output result)};
+ }
+ open(STDOUT, '>&', $output_writer) or die "unable to redirect STDOUT - $!\n";
+ open(STDERR, '>&', $output_writer) or die "unable to redirect STDERR - $!\n";
+ close($output_writer);
+
+ sysread($start_reader, my $start, 1) or die "interrupted by signal\n";
+ close($start_reader);
+
+ PVE::INotify::inotify_close();
+
+ eval { $self->exec_backup_task($task) };
+ my $err = $@;
+
+ my $result = { map { $_ => $task->{$_} } $guest_result_keys->@* };
+ print $result_writer Storable::nfreeze($result);
+ close($result_writer);
+
+ die $err if $err;
+ $exitcode = 0;
+ };
+ warn $@ if $@ && $@ !~ m/^interrupted by signal$/;
+ STDOUT->flush();
+ POSIX::_exit($exitcode);
+ }
+
+ POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old_mask);
+
+ close($output_writer);
+ close($result_writer);
+ close($start_reader);
+
+ # A stop request that came in while forking reached only the job process, so the backup
+ # process must not start then.
+ my $cancelled = $$interrupted;
+ if (!$cancelled) {
+ local $SIG{PIPE} = 'IGNORE';
+ syswrite($start_writer, '1');
+ }
+ close($start_writer);
+
+ return {
+ pid => $pid,
+ cancelled => $cancelled,
+ task => $task,
+ output => $output_reader,
+ result => $result_reader,
+ 'output-buffer' => '',
+ 'result-data' => '',
+ };
+}
+
+my sub forward_guest_output {
+ my ($child, $data, $final) = @_;
+
+ my $vmid = $child->{task}->{vmid};
+
+ $child->{'output-buffer'} .= $data;
+ $child->{'output-buffer'} .= "\n" if $final && length($child->{'output-buffer'});
+
+ while ($child->{'output-buffer'} =~ s/^(.*)\n//) {
+ my $line = $1;
+ # warnings of a guest backup process count for the task, but its counter ends with it
+ PVE::RPCEnvironment::get()->{warning_count}++ if $line =~ m/^WARN: /;
+ print STDERR "$vmid: $line\n";
+ }
+}
+
+my sub read_guest_backup_pipe {
+ my ($child, $kind) = @_;
+
+ my $count = sysread($child->{$kind}, my $data, 64 * 1024);
+ return if !defined($count) && ($!{EINTR} || $!{EAGAIN});
+
+ if (!$count) {
+ close(delete $child->{$kind});
+ forward_guest_output($child, '', 1) if $kind eq 'output';
+ } elsif ($kind eq 'output') {
+ forward_guest_output($child, $data);
+ } else {
+ $child->{'result-data'} .= $data;
+ }
+}
+
+my sub finish_guest_backup {
+ my ($child, $status) = @_;
+
+ # the backup process is gone, but helpers it started might still hold the output pipe
+ for my $kind (qw(result output)) {
+ while ($child->{$kind} && IO::Select->new($child->{$kind})->can_read(0)) {
+ read_guest_backup_pipe($child, $kind);
+ }
+ close(delete $child->{$kind}) if $child->{$kind};
+ }
+ forward_guest_output($child, '', 1);
+ return if $child->{cancelled};
+
+ my $task = $child->{task};
+ my $result = eval { Storable::thaw($child->{'result-data'}) };
+ if (ref($result) eq 'HASH') {
+ $task->{$_} = $result->{$_} for keys $result->%*;
+ } else {
+ my $reason = $status & 127 ? "signal " . ($status & 127) : "exit code " . ($status >> 8);
+ fail_task($task, "backup process ended unexpectedly ($reason)");
+ }
+}
+
+my sub exec_parallel_backup_tasks {
+ my ($self, $tasklist, $concurrency) = @_;
+
+ my @queue = $tasklist->@*;
+ my $running = {};
+ my $interrupted = 0;
+ my $job_pid = $$;
+
+ # Stopping a task signals all its processes, so the guest backups stop on their own. Signalling
+ # them again could interrupt their cleanup.
+ local $SIG{INT} = local $SIG{TERM} = local $SIG{QUIT} = local $SIG{HUP} = local $SIG{PIPE} =
+ sub { $interrupted = 1; };
+
+ while (scalar(@queue) || scalar(keys $running->%*)) {
+ while (!$interrupted && scalar(@queue) && scalar(keys $running->%*) < $concurrency) {
+ my $task = shift @queue;
+ my $child = eval { fork_guest_backup($self, $task, $running, \$interrupted) };
+ # a guest backup process signalled while it exits dies into this eval
+ POSIX::_exit(1) if $$ != $job_pid;
+ if (my $err = $@) {
+ fail_task($task, $err);
+ next;
+ }
+ $running->{ $child->{pid} } = $child;
+ unshift @queue, $task if $child->{cancelled};
+ }
+
+ last if $interrupted && !scalar(keys $running->%*);
+
+ my $handles = {};
+ for my $child (values $running->%*) {
+ $handles->{ fileno($child->{$_}) } = [$child, $_]
+ for grep { $child->{$_} } qw(output result);
+ }
+ my $select = IO::Select->new(map { $_->[0]->{ $_->[1] } } values $handles->%*);
+ for my $fh ($select->can_read(1)) {
+ read_guest_backup_pipe($handles->{ fileno($fh) }->@*);
+ }
+
+ for my $pid (keys $running->%*) {
+ next if waitpid($pid, POSIX::WNOHANG()) != $pid;
+ finish_guest_backup(delete $running->{$pid}, $?);
+ }
+ }
+
+ die "interrupted by signal\n" if $interrupted;
+}
+
sub exec_backup {
my ($self, $rpcenv, $authuser) = @_;
@@ -1474,22 +1703,27 @@ sub exec_backup {
open my $job_start_fd, '>', \$job_start_log;
open my $job_end_fd, '>', \$job_end_log;
+ my $concurrency = $self->guest_backup_concurrency();
+ $concurrency = scalar($tasklist->@*) if scalar($tasklist->@*) < $concurrency;
+
my $starttime = time();
- my $errcount = 0;
eval {
$self->{'backup-provider'}->job_init($starttime) if $self->{'backup-provider'};
$self->run_hook_script('job-start', undef, $job_start_fd);
- foreach my $task (@$tasklist) {
- $self->exec_backup_task($task);
- $errcount += 1 if $task->{state} ne 'ok';
+ if ($concurrency > 1) {
+ debugmsg('info', "running up to $concurrency guest backups at the same time");
+ exec_parallel_backup_tasks($self, $tasklist, $concurrency);
+ } else {
+ $self->exec_backup_task($_) for $tasklist->@*;
}
$self->{'backup-provider'}->job_cleanup() if $self->{'backup-provider'};
$self->run_hook_script('job-end', undef, $job_end_fd);
};
my $err = $@;
+ my $errcount = grep { $_->{state} ne 'ok' } $tasklist->@*;
if ($err) {
if ($self->{'backup-provider'}) {
diff --git a/test/Makefile b/test/Makefile
index 2dfd20a41..1eb94f4e0 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -18,7 +18,7 @@ replication%.t: replication_test%.pl
./$<
.PHONY: test-vzdump
-test-vzdump: test-vzdump-guest-included test-vzdump-new
+test-vzdump: test-vzdump-guest-included test-vzdump-new test-vzdump-concurrency
.PHONY: test-vzdump-guest-included
test-vzdump-guest-included:
@@ -28,6 +28,10 @@ test-vzdump-guest-included:
test-vzdump-new:
./vzdump_new_test.pl
+.PHONY: test-vzdump-concurrency
+test-vzdump-concurrency:
+ ./vzdump_concurrency_test.pl
+
.PHONY: test-osd
test-osd:
./OSD_test.pl
diff --git a/test/vzdump_concurrency_test.pl b/test/vzdump_concurrency_test.pl
new file mode 100755
index 000000000..46d679490
--- /dev/null
+++ b/test/vzdump_concurrency_test.pl
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib '..';
+
+use Test::More;
+use Test::MockModule;
+
+use PVE::VZDump;
+
+my $node_config = {};
+my $datacenter_config = {};
+
+my $node_config_module = Test::MockModule->new('PVE::NodeConfig');
+$node_config_module->mock(load_config => sub { return $node_config; });
+
+my $vzdump_module = Test::MockModule->new('PVE::VZDump');
+$vzdump_module->mock(
+ cfs_read_file => sub {
+ my ($filename) = @_;
+ die "unexpected file '$filename'\n" if $filename ne 'datacenter.cfg';
+ return $datacenter_config;
+ },
+);
+
+my $tests = [
+ {
+ description => 'defaults keep backing up one guest at a time',
+ expected => 1,
+ },
+ {
+ description => 'datacenter default applies to the node',
+ datacenter => 4,
+ expected => 4,
+ },
+ {
+ description => 'node configuration overrides datacenter default',
+ datacenter => 4,
+ node => 2,
+ expected => 2,
+ },
+ {
+ description => 'node configuration applies without datacenter default',
+ node => 3,
+ expected => 3,
+ },
+ {
+ description => 'job limit lowers node limit',
+ node => 4,
+ job => 2,
+ expected => 2,
+ },
+ {
+ description => 'job limit cannot raise node limit',
+ node => 2,
+ job => 8,
+ expected => 2,
+ },
+ {
+ description => 'job limit does not raise the default',
+ job => 8,
+ expected => 1,
+ },
+ {
+ description => 'external backup providers back up one guest at a time',
+ node => 4,
+ job => 4,
+ provider => 1,
+ expected => 1,
+ },
+];
+
+for my $test ($tests->@*) {
+ $datacenter_config =
+ defined($test->{datacenter})
+ ? { 'backup-concurrency' => { node => $test->{datacenter} } }
+ : {};
+ $node_config = defined($test->{node}) ? { 'backup-concurrency' => $test->{node} } : {};
+
+ my $self = bless { opts => {} }, 'PVE::VZDump';
+ $self->{opts}->{concurrency} = $test->{job} if defined($test->{job});
+ $self->{'backup-provider'} = {} if $test->{provider};
+
+ is($self->guest_backup_concurrency(), $test->{expected}, $test->{description});
+}
+
+done_testing();
--
2.47.3
^ permalink raw reply related [relevance 21%]
* [PATCH manager 16/19] vzdump: honor backup concurrency limits of storages
2026-11-01 22:58 15% [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-01 22:58 19% ` [PATCH guest-common 04/19] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
2026-11-01 22:58 21% ` [PATCH manager 11/19] vzdump: back up guests of a job in parallel Thomas Lamprecht
@ 2026-11-01 22:58 19% ` Thomas Lamprecht
2026-11-01 22:58 13% ` [PATCH manager 18/19] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
2026-11-01 22:58 17% ` [PATCH docs 19/19] vzdump: document concurrent backups and their limits Thomas Lamprecht
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-01 22:58 UTC (permalink / raw)
To: pve-devel
Guest backups now also count against the backup concurrency limit of
the storages they use, both the backup target and the storages of the
included guest disks. This protects a backup server or a Ceph cluster
from more parallel backups than it can handle, which a limit for the
whole cluster cannot express once several such systems are in use.
Limits of shared storages count for the whole cluster and use the
cluster-wide slots. Limits of local storages count on each node and
use slot locks like the node limit. A guest whose local storage has no
free slot lets other guests of the job go first.
With several limits, a waiting guest backup can be blocked by a full
storage while younger ones with room in their limits get slots. This
may happen a few times, then a slot of each limit it needs is kept
free for it, so it cannot starve.
The storages are taken from the guest configuration before the guest
gets locked for backup, so waiting for slots does not block changes to
the guest. If its disks moved to another storage with a limit by the
time it got locked, the backup fails instead of running without a slot
for that storage. If the storages cannot be determined, the guest is
skipped for the same reason. Nothing of this happens as long as no
storage has a limit. The task log tells which limit a guest waits for.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
PVE/VZDump.pm | 95 +++++++++++++++++++++++++++++--
PVE/VZDump/ClusterSlots.pm | 44 +++++++++++++-
test/vzdump_cluster_slots_test.pl | 79 ++++++++++++++++++++++++-
3 files changed, 209 insertions(+), 9 deletions(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 525a593c6..59809d85c 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -933,6 +933,34 @@ sub get_backup_file_list {
return $bklist;
}
+my sub limited_backup_storages {
+ my ($self, $task) = @_;
+
+ my $storage_cfg = PVE::Storage::config();
+ my $limited = {
+ map { $_ => 1 }
+ grep { defined($storage_cfg->{ids}->{$_}->{'backup-concurrency'}) }
+ keys $storage_cfg->{ids}->%*
+ };
+ return [] if !scalar(keys $limited->%*);
+
+ my $storeids = {};
+ $storeids->{ $self->{opts}->{storage} } = 1 if $self->{opts}->{storage};
+
+ if (my $plugin = $task->{plugin}) {
+ my $config_class = $plugin->type() eq 'qemu' ? 'PVE::QemuConfig' : 'PVE::LXC::Config';
+ my $conf = $config_class->load_config($task->{vmid});
+ for my $volume ($config_class->get_backup_volumes($conf)->@*) {
+ next if !$volume->{included};
+ my $volid = $volume->{volume_config}->{file} // $volume->{volume_config}->{volume};
+ my ($storeid) = PVE::Storage::parse_volume_id($volid, 1);
+ $storeids->{$storeid} = 1 if defined($storeid);
+ }
+ }
+
+ return [sort grep { $limited->{$_} } keys $storeids->%*];
+}
+
sub exec_backup_task {
my ($self, $task) = @_;
@@ -1116,6 +1144,13 @@ sub exec_backup_task {
$cleanup->{unlock} = 1;
+ my $taken = { map { $_ => 1 } $task->{storages}->@* };
+ if (my @missing = grep { !$taken->{$_} } limited_backup_storages($self, $task)->@*) {
+ my $list = join(', ', map { "'$_'" } @missing);
+ die "no backup slot for storage $list - guest disks or storage limits changed while"
+ . " waiting for backup slots\n";
+ }
+
# prepare
my $mode = $running ? $task->{mode} : 'stop';
@@ -1717,6 +1752,25 @@ my sub try_node_slot {
return try_slot("$lockdir/slot", node_backup_concurrency());
}
+# Limits of local storages count on each node, shared ones are handled cluster-wide.
+my sub try_local_storage_slots {
+ my ($storeids) = @_;
+
+ my $storage_cfg = PVE::Storage::config();
+
+ my $locks = [];
+ for my $storeid ($storeids->@*) {
+ my $scfg = $storage_cfg->{ids}->{$storeid} or next;
+ my $limit = $scfg->{'backup-concurrency'};
+ next if $scfg->{shared} || !defined($limit);
+
+ my $lock = try_slot("$lockdir/storage-$storeid", $limit) or return (undef, $storeid);
+ push $locks->@*, $lock;
+ }
+
+ return ($locks);
+}
+
my sub log_wait {
my ($self, $reason) = @_;
@@ -1766,10 +1820,25 @@ my sub claim_next_guest {
skip_task($task, "guest moved to node '$node'");
next;
}
+
+ $task->{storages} = eval { limited_backup_storages($self, $task) };
+ if (my $err = $@) {
+ die $err if $err =~ m/interrupted by signal$/;
+ chomp($err);
+ splice($queue->@*, $i--, 1);
+ skip_task($task, "unable to check storage backup limits - $err");
+ next;
+ }
+
+ my ($storage_locks, $busy_storage) = try_local_storage_slots($task->{storages});
+ if (!$storage_locks) {
+ log_wait($self, "a free backup slot of storage '$busy_storage'");
+ next;
+ }
delete $self->{'waiting-for'};
splice($queue->@*, $i--, 1);
- return ($task, [$guest_lock, $slot]);
+ return ($task, [$guest_lock, $slot, $storage_locks->@*]);
}
return;
@@ -1785,7 +1854,7 @@ my sub skip_after_error {
}
my sub cluster_slot_resources {
- my ($self) = @_;
+ my ($self, $task) = @_;
my $limits = PVE::VZDump::ClusterSlots::limits();
return undef if !scalar(keys $limits->%*);
@@ -1798,7 +1867,15 @@ my sub cluster_slot_resources {
return undef;
}
- return ['cluster'];
+ my $storage_cfg = PVE::Storage::config();
+ my $shared = [grep { $storage_cfg->{ids}->{$_}->{shared} } $task->{storages}->@*];
+
+ return ['cluster', map { "storage/$_" } $shared->@*];
+}
+
+my sub render_cluster_limits {
+ my ($resources) = @_;
+ return join(', ', map { m!^storage/(.*)$! ? "storage '$1'" : "the $_" } $resources->@*);
}
my sub release_cluster_slots {
@@ -1824,7 +1901,7 @@ my sub next_guest_to_start {
my $pending = $schedule->{pending};
if (!$pending) {
my ($task, $locks) = claim_next_guest($self, $queue, $schedule->{deferred}) or return;
- my $resources = eval { cluster_slot_resources($self) };
+ my $resources = eval { cluster_slot_resources($self, $task) };
if (my $err = $@) {
unshift $queue->@*, $task;
die $err;
@@ -1880,8 +1957,14 @@ my sub next_guest_to_start {
my $reason = 'timeout waiting for cluster-wide backup slot';
$reason .= " - $pending->{'request-error'}" if defined($pending->{'request-error'});
skip_task($task, $reason);
- } elsif (!$pending->{logged}++) {
- debugmsg('info', "VM $task->{vmid} waits for a cluster-wide backup slot");
+ } elsif (defined($pending->{key}) && !$pending->{logged}++) {
+ my $reached = eval { PVE::VZDump::ClusterSlots::reached_limits($pending->{key}) };
+ die $@ if $@ =~ m/interrupted by signal$/;
+ my $reason =
+ scalar(($reached // [])->@*)
+ ? "limit reached for " . render_cluster_limits($reached)
+ : "queued behind other guest backups";
+ debugmsg('info', "VM $task->{vmid} waits for a cluster-wide backup slot, $reason");
}
return;
diff --git a/PVE/VZDump/ClusterSlots.pm b/PVE/VZDump/ClusterSlots.pm
index 6537bdce5..f4cac71c7 100644
--- a/PVE/VZDump/ClusterSlots.pm
+++ b/PVE/VZDump/ClusterSlots.pm
@@ -14,6 +14,7 @@ use JSON;
use PVE::Cluster qw(cfs_read_file);
use PVE::INotify;
use PVE::QemuServer::Helpers;
+use PVE::Storage;
use PVE::Tools;
my $state_file = '/etc/pve/priv/backup-slots.json';
@@ -21,6 +22,9 @@ my $state_file = '/etc/pve/priv/backup-slots.json';
# first release of pve-manager that takes part in cluster-wide limits
my $min_version = [9, 2, 26];
+# How often younger requests may get ahead of a waiting one before its limits are reserved for it.
+use constant MAX_BYPASS => 3;
+
sub limits {
my $limits = {};
@@ -29,6 +33,13 @@ sub limits {
$limits->{cluster} = $cluster;
}
+ my $storage_cfg = PVE::Storage::config();
+ for my $storeid (keys $storage_cfg->{ids}->%*) {
+ my $scfg = $storage_cfg->{ids}->{$storeid};
+ next if !$scfg->{shared} || !defined($scfg->{'backup-concurrency'});
+ $limits->{"storage/$storeid"} = $scfg->{'backup-concurrency'};
+ }
+
return $limits;
}
@@ -127,7 +138,8 @@ my sub remove_entries {
# Moves waiters that fit into all limits they count against to the holders, oldest first. Only
# resources with a limit matter, the others are tracked for information. Waiters of offline nodes
-# neither get granted nor hold up others.
+# neither get granted nor hold up others. A waiter that younger ones got ahead of too often
+# reserves a slot of each limit it counts against, so it cannot starve.
sub grant_waiters {
my ($state, $limits, $members) = @_;
@@ -135,13 +147,29 @@ sub grant_waiters {
my $used = used_slots($state);
+ my $passed_over = [];
+
my $waiters = $state->{waiters};
for my $key (sort { $waiters->{$a}->{seq} <=> $waiters->{$b}->{seq} } keys $waiters->%*) {
my $waiter = $waiters->{$key};
next if !$members->{ $waiter->{node} }->{online};
my $limited = [grep { defined($limits->{$_}) } $waiter->{resources}->@*];
- next if grep { ($used->{$_} // 0) >= $limits->{$_} } $limited->@*;
+ my $fits = !grep { ($used->{$_} // 0) >= $limits->{$_} } $limited->@*;
+
+ if (!$fits) {
+ if (($waiter->{bypassed} // 0) >= MAX_BYPASS) {
+ $used->{$_}++ for $limited->@*;
+ }
+ push $passed_over->@*, [$waiter, $limited];
+ next;
+ }
+
+ my %mine = map { $_ => 1 } $limited->@*;
+ for my $older ($passed_over->@*) {
+ my ($older_waiter, $older_limited) = $older->@*;
+ $older_waiter->{bypassed}++ if grep { $mine{$_} } $older_limited->@*;
+ }
$used->{$_}++ for $waiter->{resources}->@*;
$state->{holders}->{$key} = delete $waiters->{$key};
@@ -208,6 +236,18 @@ sub granted {
return undef;
}
+sub reached_limits {
+ my ($key) = @_;
+
+ my $state = read_state();
+ my $waiter = $state->{waiters}->{$key} or return [];
+
+ my $used = used_slots($state);
+ my $limits = limits();
+ return [grep { defined($limits->{$_}) && ($used->{$_} // 0) >= $limits->{$_} }
+ $waiter->{resources}->@*];
+}
+
# Grants waiters that fit by now, for example after limits got raised.
sub refresh {
update_state(sub { });
diff --git a/test/vzdump_cluster_slots_test.pl b/test/vzdump_cluster_slots_test.pl
index 85608b5be..5e13512b2 100755
--- a/test/vzdump_cluster_slots_test.pl
+++ b/test/vzdump_cluster_slots_test.pl
@@ -27,11 +27,12 @@ my sub make_state {
$state->{holders}->{$key} = { node => $node, resources => $resources };
}
for my $waiter ($waiters->@*) {
- my ($key, $node, $resources) = $waiter->@*;
+ my ($key, $node, $resources, $bypassed) = $waiter->@*;
$state->{waiters}->{$key} = {
node => $node,
resources => $resources,
seq => ++$state->{seq},
+ bypassed => $bypassed // 0,
};
}
return $state;
@@ -85,6 +86,54 @@ my $tests = [
expected => ['b'],
'expected-waiters' => [],
},
+ {
+ description => 'younger waiter with free resources gets ahead of a blocked one',
+ limits => { x => 1, y => 1 },
+ holders => [['h', 'node1', ['x']]],
+ waiters => [['a', 'node1', ['x', 'y']], ['b', 'node2', ['y']]],
+ expected => ['b', 'h'],
+ bypassed => { a => 1 },
+ },
+ {
+ description => 'waiter passed over too often reserves its resources',
+ limits => { x => 1, y => 1 },
+ holders => [['h', 'node1', ['x']]],
+ waiters => [['a', 'node1', ['x', 'y'], 3], ['b', 'node2', ['y']]],
+ expected => ['h'],
+ },
+ {
+ description => 'waiter passed over too often reserves only one slot of each resource',
+ limits => { cluster => 3, x => 1 },
+ holders => [['h', 'node1', ['cluster', 'x']]],
+ waiters => [
+ ['a', 'node1', ['cluster', 'x'], 3],
+ ['b', 'node2', ['cluster']],
+ ['c', 'node2', ['cluster']],
+ ],
+ expected => ['b', 'h'],
+ },
+ {
+ description => 'reserved resources do not hold up unrelated waiters',
+ limits => { x => 1, y => 1, z => 1 },
+ holders => [['h', 'node1', ['x']]],
+ waiters => [['a', 'node1', ['x', 'y'], 3], ['b', 'node2', ['z']]],
+ expected => ['b', 'h'],
+ },
+ {
+ description => 'resources without limit do not count as passed over',
+ limits => { x => 1 },
+ holders => [['h', 'node1', ['cluster', 'x']]],
+ waiters => [['a', 'node1', ['cluster', 'x']], ['b', 'node2', ['cluster']]],
+ expected => ['b', 'h'],
+ bypassed => { a => 0 },
+ },
+ {
+ description => 'resources without limit do not get reserved',
+ limits => { x => 1 },
+ holders => [['h', 'node1', ['cluster', 'x']]],
+ waiters => [['a', 'node1', ['cluster', 'x'], 3], ['b', 'node2', ['cluster', 'y']]],
+ expected => ['b', 'h'],
+ },
];
for my $test ($tests->@*) {
@@ -101,6 +150,34 @@ for my $test ($tests->@*) {
"$test->{description} (waiters)",
);
}
+ for my $key (sort keys(($test->{bypassed} // {})->%*)) {
+ is(
+ $state->{waiters}->{$key}->{bypassed},
+ $test->{bypassed}->{$key},
+ "$test->{description} ($key bypassed)",
+ );
+ }
+}
+
+{
+ my $limits = { cluster => 2, x => 1 };
+ my $state = make_state([['h', 'node1', ['cluster', 'x']]], [['a', 'node1', ['cluster', 'x']]]);
+ my $add_younger = sub {
+ my ($key) = @_;
+ $state->{waiters}->{$key} =
+ { node => 'node2', resources => ['cluster'], seq => ++$state->{seq} };
+ PVE::VZDump::ClusterSlots::grant_waiters($state, $limits, $members);
+ };
+ for my $younger (qw(b c d)) {
+ $add_younger->($younger);
+ delete $state->{holders}->{$younger};
+ }
+ $add_younger->('e');
+ is_deeply(granted($state), ['h'], 'younger waiters stop getting ahead after a few times');
+
+ delete $state->{holders}->{h};
+ PVE::VZDump::ClusterSlots::grant_waiters($state, $limits, $members);
+ is_deeply(granted($state), ['a', 'e'], 'passed over waiter gets its slots once they are free');
}
# Request, grant, release and cleanup against an in-memory table.
--
2.47.3
^ permalink raw reply related [relevance 19%]
* [PATCH docs 19/19] vzdump: document concurrent backups and their limits
2026-11-01 22:58 15% [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits Thomas Lamprecht
` (3 preceding siblings ...)
2026-11-01 22:58 13% ` [PATCH manager 18/19] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
@ 2026-11-01 22:58 17% ` Thomas Lamprecht
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-01 22:58 UTC (permalink / raw)
To: pve-devel
Describe how many guests a node backs up at the same time and that the
bandwidth limit applies to each of them, how jobs can run alongside
each other, and the cluster-wide and storage limits, including how to
size them and what happens with slots of an offline node.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
vzdump.adoc | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
diff --git a/vzdump.adoc b/vzdump.adoc
index 44db027..6e65c29 100644
--- a/vzdump.adoc
+++ b/vzdump.adoc
@@ -308,6 +308,114 @@ the `performance` setting, `max-workers` (affects VM backups only) and
`pbs-entries-max` (affects container backups only). See the
xref:vzdump_configuration[configuration options] for details.
+[[vzdump_concurrency]]
+Concurrent Backups
+------------------
+
+By default, a node runs one backup job at a time and backs up its guests one
+after the other. A job that is due while another one runs waits for it, up to
+the `lockwait` time. As each node backs up its own guests, how long a job takes
+and how much load it puts on the backup target depend on how its guests are
+spread over the nodes. The settings described here allow backing up several
+guests of a node at the same time, running jobs alongside each other, and
+limiting the load on shared storages and backup servers.
+
+Node Limit and Job Concurrency
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The backup concurrency of a node limits how many guests it backs up at the same
+time, across all jobs. Set the default for all nodes in the datacenter options
+(`backup-concurrency` in `datacenter.cfg`), and override it for single nodes in
+their options (`backup-concurrency` in the node configuration):
+
+----
+# pvesh set /cluster/options --backup-concurrency 4
+# pvenode config set --backup-concurrency 8
+----
+
+A job backs up as many guests at the same time as its node allows. With the
+`concurrency` job option ('Concurrency' in the 'Advanced' tab), a job can use
+fewer, but not more.
+
+Size the node limit by what the node itself can handle, that is, its CPU,
+memory, network connection, and local disks. Each parallel guest backup runs its
+own compressor or Proxmox Backup Server client. The `bwlimit` setting applies to
+each guest backup on its own, so the bandwidth of a node can add up to the
+configured limit times the number of guests backed up at the same time.
+
+Jobs Running Alongside Each Other
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Jobs with the `overlap` option ('Overlap' in the 'Advanced' tab) run at the same
+time as other jobs that have it enabled, for example, a short hourly job
+alongside a long nightly one. Together, they stay within the backup concurrency
+of the node. A job without the option still runs alone, and while it waits for
+running jobs to finish, overlapping jobs that are due later do not start before
+it. Waiting for a free backup slot of the node is not limited by `lockwait`.
+
+If two running jobs include the same guest, the second one backs it up once the
+first one is done with it, waiting at most `lockwait` minutes.
+
+NOTE: The job phases of hook scripts can overlap for overlapping jobs. For
+example, a hook script that mounts a disk in the `job-start` phase and unmounts
+it in the `job-end` phase must not be used for overlapping jobs. With a job
+concurrency above one, the phases of different guests of a job overlap as well.
+
+Cluster-wide and Storage Limits
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Each node runs its part of a job on its own, so in a cluster, shared storages
+and backup servers get the backups of all nodes at the same time. To protect
+them, you can limit how many guest backups run at the same time:
+
+* for the whole cluster, with the `cluster` key of `backup-concurrency` in the
+ datacenter options ('Cluster-wide' in the UI),
+* for a storage, with its `backup-concurrency` option ('Backup Concurrency' in
+ the advanced storage settings). It counts guest backups that use the storage
+ as backup target or for included guest disks, but not for fleecing or
+ temporary files. For a shared storage, the limit applies to the whole cluster,
+ for a local storage to each node.
+
+----
+# pvesh set /cluster/options --backup-concurrency node=8,cluster=12
+# pvesm set pbs-main --backup-concurrency 6
+----
+
+A guest backup only starts once all limits it counts against have room. Size
+the cluster-wide and storage limits by what the shared systems can handle,
+independent of the node limits. With such limits in place, raising the node
+limits cannot overload the shared systems, so the node limits only need to fit
+what each node can handle.
+
+TIP: Several storage entries can refer to the same system, for example,
+namespaces of a Proxmox Backup Server or pools of a Ceph cluster. Their limits
+count separately, so use the cluster-wide limit to bound their sum.
+
+Guest backups get cluster-wide slots in the order they started waiting. One that
+waits for a storage at its limit lets others with room go first, but only a few
+times. A job has at most one guest waiting for cluster-wide slots at a time, and
+waits for them at most `lockwait` minutes in total. Like for node slots, waiting
+for free slots of a local storage is not limited by `lockwait`. The task log
+tells which limit a guest waits for.
+To see which guest backups hold or wait for cluster-wide slots, use:
+
+----
+# pvesh get /cluster/backup-info/slots
+----
+
+Granting cluster-wide slots requires quorum, and the limits are only enforced
+once all online nodes of the cluster run a version that supports them. Guest
+backups that started before that, or while neither a cluster-wide limit nor a
+limit on a shared storage was set, do not count against them. Slots of a node
+that goes offline stay taken, as its guest backups might still be running, and
+the node releases them once it is back. Once you made sure that these backups
+stopped, for example because the node is powered off, you can release its slots
+manually:
+
+----
+# pvesh delete /cluster/backup-info/slots/NODE
+----
+
[[vzdump_retention]]
Backup Retention
----------------
--
2.47.3
^ permalink raw reply related [relevance 17%]
* [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits
@ 2026-11-01 22:58 15% Thomas Lamprecht
2026-11-01 22:58 19% ` [PATCH guest-common 04/19] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
` (4 more replies)
0 siblings, 5 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-01 22:58 UTC (permalink / raw)
To: pve-devel
A node runs one backup job at a time, and that job backs up its guests one
after the other. This leads to odd load distributions depending on how the
guests of a job are distributed in a cluster. The extreme cases: If all are
on one node all get backed up in series, adding potentially a lot of delay
but being rather lenient on the backup target (storage/server). If all are
spread such that each guest is on a different node all will get backed up
concurrently, being potentially much faster but also putting a lot of load
towards the target. There is no real control over that so depending on
current guest distribution a job might run slow, ok or fast, overload or
underuse targets.
This series adds:
- parallel guest backups within a job, up to a per-node backup
concurrency, set as datacenter default or per node; a job can lower
it with its new 'concurrency' option,
- the 'overlap' job option to run alongside other such jobs, together
within the node's backup concurrency,
- cluster-wide and per-storage limits that protect shared storages and
backup servers from too many guest backups at the same time.
Without configuration nothing changes: each node backs up one guest at
a time and jobs do not overlap.
The node limit and the limits of local storages use file locks on each
node. The cluster-wide limit and those of shared storages use a slot
table on pmxcfs, changed under a cluster lock. Waiting guest backups
get their slots in order, and one held up by a full storage cannot
starve. These limits are only enforced once all online nodes run a
version that supports them; until then the task log warns.
Patches 5 to 10 fix or improve existing behavior and could be applied
ahead of the rest, for example stopping all backup jobs of a node, and
naming the error and the skipped guests of a job that could not start.
Repo (build-)dependencies:
pve-manager -> pve-guest-common, pve-cluster, pve-storage
A separate series on top adds a start window option for backup jobs.
Besides the unit tests, I tested this end to end on nested clusters
and on a three node cluster with Ceph and HA, also with PBS and NFS
targets, guests that keep writing during their backup, node failures,
quorum loss, stopped jobs and a rolling upgrade.
pve-cluster:
Thomas Lamprecht (2):
datacenter config: add backup concurrency setting
datacenter config: backup concurrency: add cluster-wide limit
src/PVE/DataCenterConfig.pm | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
pve-storage:
Thomas Lamprecht (1):
add backup concurrency option to storages
src/PVE/Storage/BTRFSPlugin.pm | 1 +
src/PVE/Storage/CIFSPlugin.pm | 1 +
src/PVE/Storage/CephFSPlugin.pm | 1 +
src/PVE/Storage/DirPlugin.pm | 1 +
src/PVE/Storage/ISCSIDirectPlugin.pm | 1 +
src/PVE/Storage/ISCSIPlugin.pm | 1 +
src/PVE/Storage/LVMPlugin.pm | 1 +
src/PVE/Storage/LvmThinPlugin.pm | 1 +
src/PVE/Storage/NFSPlugin.pm | 1 +
src/PVE/Storage/PBSPlugin.pm | 1 +
src/PVE/Storage/Plugin.pm | 9 +++++++++
src/PVE/Storage/RBDPlugin.pm | 1 +
src/PVE/Storage/ZFSPlugin.pm | 1 +
src/PVE/Storage/ZFSPoolPlugin.pm | 1 +
14 files changed, 22 insertions(+)
pve-guest-common:
Thomas Lamprecht (1):
vzdump: add options for parallel guest backups and overlapping jobs
src/PVE/VZDump/Common.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
pve-container:
Thomas Lamprecht (1):
vzdump: honor bandwidth limit for backups to Proxmox Backup Server
src/PVE/VZDump/LXC.pm | 1 +
1 file changed, 1 insertion(+)
pve-manager:
Thomas Lamprecht (13):
vzdump: notification: capture guest logs right after each backup
vzdump: stop all backup jobs of the node
vzdump: show the error if a job could not get the global lock
vzdump: run job-init hook and set up target once the job may start
vzdump: list guests as skipped if the job could not start
vzdump: back up guests of a job in parallel
vzdump: allow jobs to run alongside each other
ui: options: add backup concurrency for datacenter and nodes
ui: backup job: add concurrency and overlap options
vzdump: limit concurrent guest backups cluster-wide
vzdump: honor backup concurrency limits of storages
api: backup info: add endpoints for cluster-wide backup slots
ui: add cluster-wide and storage backup concurrency limits
PVE/API2/Cluster/BackupInfo.pm | 106 ++-
PVE/API2/VZDump.pm | 10 +-
PVE/Makefile | 2 +-
PVE/NodeConfig.pm | 7 +
PVE/Service/pvescheduler.pm | 4 +
PVE/VZDump.pm | 783 ++++++++++++++++++--
PVE/VZDump/ClusterSlots.pm | 299 ++++++++
PVE/VZDump/Makefile | 15 +
test/Makefile | 10 +-
test/vzdump_cluster_slots_test.pl | 271 +++++++
test/vzdump_concurrency_test.pl | 89 +++
test/vzdump_new_test.pl | 1 +
www/manager6/dc/OptionView.js | 22 +
www/manager6/node/NodeOptionsView.js | 8 +
www/manager6/panel/BackupAdvancedOptions.js | 40 +-
www/manager6/storage/Base.js | 17 +
16 files changed, 1623 insertions(+), 61 deletions(-)
pve-docs:
Thomas Lamprecht (1):
vzdump: document concurrent backups and their limits
vzdump.adoc | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
--
2.47.3
^ permalink raw reply [relevance 15%]
* [PATCH manager 18/19] ui: add cluster-wide and storage backup concurrency limits
2026-11-01 22:58 15% [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits Thomas Lamprecht
` (2 preceding siblings ...)
2026-11-01 22:58 19% ` [PATCH manager 16/19] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
@ 2026-11-01 22:58 13% ` Thomas Lamprecht
2026-11-01 22:58 17% ` [PATCH docs 19/19] vzdump: document concurrent backups and their limits Thomas Lamprecht
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-01 22:58 UTC (permalink / raw)
To: pve-devel
Expose the cluster-wide limit next to the per-node one in the
datacenter options, and the limit of a storage in the advanced section
of the storage edit window, so admins can protect shared systems from
too many parallel backups without editing configuration files.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
www/manager6/dc/OptionView.js | 8 ++++++++
www/manager6/storage/Base.js | 17 +++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index ac0f0bdd1..851288a96 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -372,6 +372,14 @@ Ext.define('PVE.dc.OptionView', {
minValue: 1,
submitValue: true,
},
+ {
+ xtype: 'proxmoxintegerfield',
+ name: 'cluster',
+ fieldLabel: gettext('Cluster-wide'),
+ emptyText: gettext('Unlimited'),
+ minValue: 1,
+ submitValue: true,
+ },
],
});
me.add_inputpanel_row('next-id', gettext('Next Free VMID Range'), {
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 8961460b0..c66e0b20f 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -62,6 +62,23 @@ Ext.define('PVE.panel.StorageBase', {
}
};
+ if (me.type !== 'esxi') {
+ addAdvancedWidget({
+ xtype: 'proxmoxintegerfield',
+ name: 'backup-concurrency',
+ fieldLabel: gettext('Backup Concurrency'),
+ emptyText: gettext('Unlimited'),
+ minValue: 1,
+ deleteEmpty: !me.isCreate,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext(
+ 'Guest backups using this storage at the same time, as target or for guest disks. Counted for the whole cluster if the storage is shared, otherwise on each node.',
+ ),
+ },
+ });
+ }
+
const qemuImgStorageTypes = ['dir', 'btrfs', 'nfs', 'cifs'];
if (qemuImgStorageTypes.includes(me.type)) {
--
2.47.3
^ permalink raw reply related [relevance 13%]
* [PATCH guest-common 04/19] vzdump: add options for parallel guest backups and overlapping jobs
2026-11-01 22:58 15% [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits Thomas Lamprecht
@ 2026-11-01 22:58 19% ` Thomas Lamprecht
2026-11-01 22:58 21% ` [PATCH manager 11/19] vzdump: back up guests of a job in parallel Thomas Lamprecht
` (3 subsequent siblings)
4 siblings, 0 replies; 23+ results
From: Thomas Lamprecht @ 2026-11-01 22:58 UTC (permalink / raw)
To: pve-devel
A node only ever runs one backup job, and that job backs up its guests
one after the other. How long a job takes thus depends on how its
guests happen to be spread over the nodes, and a short job has to wait
until a long one finished, failing once the lock wait time is
exceeded.
The new 'concurrency' option allows backing up several guests of a job
at the same time, up to the backup concurrency of the node. The
bandwidth limit then applies to each of them, as its description now
says. The 'overlap' option lets a job run alongside other jobs that
allow it as well. It is off by default, as existing hook scripts may
rely on job phases never overlapping.
With overlapping jobs the same guest can be part of two running
backups, and with cluster-wide limits a guest backup can wait for a
slot, so the lock wait now also bounds these waits.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
src/PVE/VZDump/Common.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/PVE/VZDump/Common.pm b/src/PVE/VZDump/Common.pm
index 67a4cf4..f98c9ae 100644
--- a/src/PVE/VZDump/Common.pm
+++ b/src/PVE/VZDump/Common.pm
@@ -297,7 +297,7 @@ my $confdesc = {
},
bwlimit => {
type => 'integer',
- description => "Limit I/O bandwidth (in KiB/s).",
+ description => "Limit I/O bandwidth of each guest backup (in KiB/s).",
optional => 1,
minimum => 0,
default => 0,
@@ -327,11 +327,27 @@ my $confdesc = {
},
lockwait => {
type => 'integer',
- description => "Maximal time to wait for the global lock (minutes).",
+ description =>
+ "Maximal time to wait for the global lock, for guests that another backup"
+ . " is currently processing, and for cluster-wide backup slots (minutes).",
optional => 1,
minimum => 0,
default => 3 * 60, # 3 hours
},
+ concurrency => {
+ type => 'integer',
+ description => "Maximal number of guests to back up at the same time on each node."
+ . " Defaults to, and is limited by, the backup concurrency configured for the node.",
+ optional => 1,
+ minimum => 1,
+ },
+ overlap => {
+ type => 'boolean',
+ description => "Allow running at the same time as other backups on the same node that"
+ . " also allow it. The job phases of their hook scripts can then overlap.",
+ optional => 1,
+ default => 0,
+ },
stopwait => {
type => 'integer',
description => "Maximal time to wait until a guest system is stopped (minutes).",
--
2.47.3
^ permalink raw reply related [relevance 19%]
* [PATCH qemu v3 1/2] update submodule and patches to QEMU 11.1.3
@ 2026-10-28 15:08 5% ` Fiona Ebner
0 siblings, 0 replies; 23+ results
From: Fiona Ebner @ 2026-10-28 15:08 UTC (permalink / raw)
To: pve-devel
Picking up fixes for KVM, x86 and ARM emulation, QXL display, USB
emulation, IDE emulation, NBD, VirtIO, VirtIO-GPU and VirtIO-net.
For the block layer, a corruption fix, fixes to improve flush error
reporting upon close and for qemu-img, and a fix for iterating block
nodes.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
Changes in v3:
* Use 11.1.3 as a base.
...d-support-for-sync-bitmap-mode-never.patch | 6 +-
...alidate-primary-surface-stride-again.patch | 81 ---------
...5a-gracefully-handle-re-entrant-DMA.patch} | 0
...ix-text-mode-OOB-write-after-a-graph.patch | 164 ------------------
...-fix-out-of-bound-read-in-WRITE-SAME.patch | 71 --------
...ELECT-block-size-change-behind-a-qui.patch | 89 ----------
...-the-VAPIC-region-to-0xc0000.0xe0000.patch | 75 --------
...-MemoryRegion-if-vapic_map_rom_writa.patch | 36 ----
...t-do-not-treat-a-zero-length-write-a.patch | 54 ------
...k-file-change-locking-default-to-off.patch | 6 +-
...he-CPU-model-to-kvm64-32-instead-of-.patch | 4 +-
...return-success-on-info-without-snaps.patch | 4 +-
...dd-add-osize-and-read-from-to-stdin-.patch | 12 +-
...E-Up-qemu-img-dd-add-isize-parameter.patch | 14 +-
...PVE-Up-qemu-img-dd-add-n-skip_create.patch | 10 +-
...-add-l-option-for-loading-a-snapshot.patch | 14 +-
...virtio-balloon-improve-query-balloon.patch | 4 +-
...async-for-background-state-snapshots.patch | 4 +-
...add-optional-buffer-size-to-QEMUFile.patch | 2 +-
...add-the-zeroinit-block-driver-filter.patch | 6 +-
...le-posix-make-locking-optiono-on-cre.patch | 20 +--
...-Backup-add-backup-dump-block-driver.patch | 4 +-
...d-sequential-job-transaction-support.patch | 6 +-
...ckup-Proxmox-backup-patches-for-QEMU.patch | 2 +-
...k-driver-to-map-backup-archives-into.patch | 8 +-
...igrate-dirty-bitmap-state-via-savevm.patch | 2 +-
...dirty-bitmap-migrate-other-bitmaps-e.patch | 4 +-
.../0035-block-add-alloc-track-driver.patch | 8 +-
.../0036-PVE-backup-add-fleecing-option.patch | 2 +-
...ment-backup-access-setup-and-teardow.patch | 8 +-
debian/patches/series | 9 +-
qemu | 2 +-
32 files changed, 77 insertions(+), 654 deletions(-)
delete mode 100644 debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
rename debian/patches/extra/{0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch => 0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch} (100%)
delete mode 100644 debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
delete mode 100644 debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
delete mode 100644 debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
delete mode 100644 debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
delete mode 100644 debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
delete mode 100644 debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
diff --git a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
index 40ec9887d7..8b0740a093 100644
--- a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
+++ b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
@@ -333,7 +333,7 @@ index e7c8f1a856..d5aa68caeb 100644
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 1f87b07850..c2f6139dea 100644
+index 199efc1e00..28d9c1e98e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2280,6 +2280,15 @@
@@ -363,7 +363,7 @@ index 1f87b07850..c2f6139dea 100644
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
-@@ -2598,6 +2609,15 @@
+@@ -2600,6 +2611,15 @@
# destination (all the disk, only the sectors allocated in the
# topmost image, or only new I/O).
#
@@ -379,7 +379,7 @@ index 1f87b07850..c2f6139dea 100644
# @granularity: granularity of the dirty bitmap, default is 64K if the
# image format doesn't have clusters, 4K if the clusters are
# smaller than that, else the cluster size. Must be a power of 2
-@@ -2650,7 +2670,8 @@
+@@ -2652,7 +2672,8 @@
{ 'command': 'blockdev-mirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*replaces': 'str',
diff --git a/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch b/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
deleted file mode 100644
index 299927cb83..0000000000
--- a/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
-Date: Mon, 20 Jul 2026 15:45:13 +0400
-Subject: [PATCH] hw/display/qxl: validate primary surface stride against width
-
-The existing validation in qxl_create_guest_primary() checks that
-abs(stride) * height fits in vgamem_size and that stride is 4-byte
-aligned, but never checks that abs(stride) is large enough to hold one
-row of pixels for the declared width and format.
-
-A malicious guest can create a primary surface with a stride much
-smaller than width * bytes_per_pixel (e.g. stride=4 for a 64-wide 32bpp
-surface). The spice server rejects this via red_validate_surface(), but
-the return is void and QEMU unconditionally proceeds to set up the local
-rendering state. On the next display refresh, VNC or SDL reads width *
-byptes_pp per scanline from a region backed by only stride bytes per
-row, causing a host-side out-of-bounds read.
-
-Add three checks before creating the surface:
- - reject unknown surface formats
- - reject zero width or height
- - reject surfaces where abs(stride) < width * bytes_per_pixel
-
-Fixes: CVE-2026-16271
-Fixes: 3761abb16784 ("hw/display/qxl: fix signed to unsigned comparison")
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3637
-Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
-Link: https://lore.kernel.org/qemu-devel/20260720114513.2500370-1-marcandre.lureau@redhat.com
-(picked from qemu-devel)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/display/qxl.c | 29 +++++++++++++++++++++++++++++
- 1 file changed, 29 insertions(+)
-
-diff --git a/hw/display/qxl.c b/hw/display/qxl.c
-index b7d871b9ee..41673c369b 100644
---- a/hw/display/qxl.c
-+++ b/hw/display/qxl.c
-@@ -1496,6 +1496,7 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
- QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
- uint32_t requested_height = le32_to_cpu(sc->height);
- int requested_stride = le32_to_cpu(sc->stride);
-+ uint32_t bytes_pp;
-
- if (requested_stride == INT32_MIN ||
- abs(requested_stride) * (uint64_t)requested_height
-@@ -1532,6 +1533,34 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
- return;
- }
-
-+ switch (surface.format) {
-+ case SPICE_SURFACE_FMT_16_555:
-+ case SPICE_SURFACE_FMT_16_565:
-+ bytes_pp = 2;
-+ break;
-+ case SPICE_SURFACE_FMT_32_xRGB:
-+ case SPICE_SURFACE_FMT_32_ARGB:
-+ bytes_pp = 4;
-+ break;
-+ default:
-+ qxl_set_guest_bug(qxl, "%s: unhandled format %d",
-+ __func__, surface.format);
-+ return;
-+ }
-+
-+ if (surface.width == 0 || surface.height == 0) {
-+ qxl_set_guest_bug(qxl, "%s: zero dimension %ux%u",
-+ __func__, surface.width, surface.height);
-+ return;
-+ }
-+
-+ if ((uint64_t)surface.width * bytes_pp > abs(surface.stride)) {
-+ qxl_set_guest_bug(qxl, "%s: stride too small for width:"
-+ " stride %d width %u bpp %u",
-+ __func__, surface.stride, surface.width, bytes_pp);
-+ return;
-+ }
-+
- surface.mouse_mode = true;
- surface.group_id = MEMSLOT_GROUP_GUEST;
- if (loadvm) {
diff --git a/debian/patches/extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch b/debian/patches/extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
similarity index 100%
rename from debian/patches/extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
rename to debian/patches/extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
diff --git a/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch b/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
deleted file mode 100644
index 9c7c7f6d32..0000000000
--- a/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
+++ /dev/null
@@ -1,164 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Warisjeet Singh <sinxx198@gmail.com>
-Date: Mon, 24 Aug 2026 12:47:26 -0400
-Subject: [PATCH] hw/display/vga: fix text-mode OOB write after a graphics
- surface switch
-
-vga_draw_text() decides whether the console surface needs a resize from
-its geometry cache, but none of the cache terms observe the graphics
-renderer having replaced the console surface in between:
-
-- last_width/last_height are shared with vga_draw_graphic(), which
- stores them in pixels while the text path stores characters;
-- last_depth stays 0 for legacy (non-VBE) graphics modes, because
- vga_get_bpp() only reports a depth when VBE is enabled, so the
- "s->last_depth" term that normally forces a resize after a graphics
- frame does not fire.
-
-So a graphics frame that shrinks the console surface (e.g. 80x25
-pixels) followed by a text frame with matching character geometry
-(80x25 chars) skips the resize, and the glyph loop then paints
-width*cw x height*cheight pixels into the smaller surface, out of
-bounds, with guest-controlled (DAC palette) values, on every display
-refresh.
-
-Separate the geometry cache per renderer: text paths (vga_draw_text,
-vga_update_text, and the text handling in vga_invalidate_display /
-vga_common_reset) now only manipulate last_text_{width,height}, in
-characters; last_{width,height} become graphics-only, in pixels.
-Additionally, make the text path compare the pixel size it is about
-to paint against the console surface's actual dimensions. The
-surface check is the load-bearing term: caches in either unit cannot
-see the other renderer swapping the surface, the surface can.
-
-Fixes: CVE-2026-77913
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4215
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Warisjeet Singh (sin99xx) <sinxx198@gmail.com>
-Message-ID: <vga-v3-20260824.sinxx198@gmail.com>
-(cherry picked from commit 418396be8013386a81f8d8d89ac0effcf03a64b6)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/display/vga.c | 37 ++++++++++++++++++++++---------------
- hw/display/vga_int.h | 3 ++-
- 2 files changed, 24 insertions(+), 16 deletions(-)
-
-diff --git a/hw/display/vga.c b/hw/display/vga.c
-index da0c331486..cb0e28b79b 100644
---- a/hw/display/vga.c
-+++ b/hw/display/vga.c
-@@ -1241,7 +1241,10 @@ static void vga_draw_text(VGACommonState *s, int full_update)
- return;
- }
-
-- if (width != s->last_width || height != s->last_height ||
-+ if (surface == NULL ||
-+ surface_width(surface) != width * cw ||
-+ surface_height(surface) != height * cheight ||
-+ width != s->last_text_width || height != s->last_text_height ||
- cw != s->last_cw || cheight != s->last_ch || s->last_depth) {
- s->last_scr_width = width * cw;
- s->last_scr_height = height * cheight;
-@@ -1249,8 +1252,8 @@ static void vga_draw_text(VGACommonState *s, int full_update)
- surface = qemu_console_surface(s->con);
- qemu_console_text_resize(s->con, width, height);
- s->last_depth = 0;
-- s->last_width = width;
-- s->last_height = height;
-+ s->last_text_width = width;
-+ s->last_text_height = height;
- s->last_ch = cheight;
- s->last_cw = cw;
- full_update = 1;
-@@ -1845,6 +1848,8 @@ static void vga_invalidate_display(void *opaque)
-
- s->last_width = -1;
- s->last_height = -1;
-+ s->last_text_width = -1;
-+ s->last_text_height = -1;
- }
-
- void vga_common_reset(VGACommonState *s)
-@@ -1887,6 +1892,8 @@ void vga_common_reset(VGACommonState *s)
- s->last_ch = 0;
- s->last_width = 0;
- s->last_height = 0;
-+ s->last_text_width = 0;
-+ s->last_text_height = 0;
- s->last_scr_width = 0;
- s->last_scr_height = 0;
- s->cursor_start = 0;
-@@ -1938,8 +1945,8 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- s->graphic_mode = graphic_mode;
- full_update = 1;
- }
-- if (s->last_width == -1) {
-- s->last_width = 0;
-+ if (s->last_text_width == -1) {
-+ s->last_text_width = 0;
- full_update = 1;
- }
-
-@@ -1978,15 +1985,15 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- break;
- }
-
-- if (width != s->last_width || height != s->last_height ||
-+ if (width != s->last_text_width || height != s->last_text_height ||
- cw != s->last_cw || cheight != s->last_ch) {
- s->last_scr_width = width * cw;
- s->last_scr_height = height * cheight;
- qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height);
- qemu_console_text_resize(s->con, width, height);
- s->last_depth = 0;
-- s->last_width = width;
-- s->last_height = height;
-+ s->last_text_width = width;
-+ s->last_text_height = height;
- s->last_ch = cheight;
- s->last_cw = cw;
- full_update = 1;
-@@ -2071,22 +2078,22 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- }
-
- /* Display a message */
-- s->last_width = 60;
-- s->last_height = height = 3;
-+ s->last_text_width = 60;
-+ s->last_text_height = height = 3;
- qemu_console_text_set_cursor(s->con, -1, -1);
-- qemu_console_text_resize(s->con, s->last_width, height);
-+ qemu_console_text_resize(s->con, s->last_text_width, height);
-
-- for (dst = chardata, i = 0; i < s->last_width * height; i ++)
-+ for (dst = chardata, i = 0; i < s->last_text_width * height; i ++)
- *dst++ = ' ';
-
- size = strlen(msg_buffer);
-- width = (s->last_width - size) / 2;
-- dst = chardata + s->last_width + width;
-+ width = (s->last_text_width - size) / 2;
-+ dst = chardata + s->last_text_width + width;
- for (i = 0; i < size; i ++)
- *dst++ = ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE,
- QEMU_COLOR_BLACK, 1);
-
-- qemu_console_text_update(s->con, 0, 0, s->last_width, height);
-+ qemu_console_text_update(s->con, 0, 0, s->last_text_width, height);
- }
-
- static uint64_t vga_mem_read(void *opaque, hwaddr addr,
-diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
-index 5664317ecd..ca69ae9815 100644
---- a/hw/display/vga_int.h
-+++ b/hw/display/vga_int.h
-@@ -122,7 +122,8 @@ typedef struct VGACommonState {
- uint32_t plane_updated;
- uint32_t last_line_offset;
- uint8_t last_cw, last_ch;
-- uint32_t last_width, last_height; /* in chars or pixels */
-+ uint32_t last_width, last_height; /* in pixels (graphics renderer) */
-+ uint32_t last_text_width, last_text_height; /* in chars (text renderer) */
- uint32_t last_scr_width, last_scr_height; /* in pixels */
- uint32_t last_depth; /* in bits */
- bool last_byteswap;
diff --git a/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch b/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
deleted file mode 100644
index ffab5481da..0000000000
--- a/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:22:41 +0200
-Subject: [PATCH] scsi-disk: fix out-of-bound read in WRITE SAME
-
-A guest with an attached scsi-hd can force QEMU's SCSI disk emulation
-to read roughly 60 KiB past the end of a heap buffer, copying that out
-of bounds host memory into the guest's own disk image.
-
-WRITE SAME computes the request transfer length at dev->blocksize
-when the request is prepared and sets cmd->xfer from dev->blocksize.
-scsi_disk_emulate_command() then uses cmd->xfer as the size of the
-request buffer.
-
-However, MODE SELECT can race with the WRITE SAME command and guest raise
-the logical block size to any value whose low bits fit 0xfe00, up to 65024.
-In the presence of this race, scsi_disk_emulate_write_same() will read
-from memory as many bytes as indicated by the *new* dev->blocksize,
-and write it to disk.
-
-The read length in WRITE SAME must be bounded by the buffer that was
-actually allocated, not by the mutable s->qdev.blocksize, so clamp the
-length used against inbuf to r->buflen. Re-validating req->cmd.xfer
-against the current block size would not work because the race is
-intrinsic in the SCSI protocol.
-
-I am not sure if this is exploitable with virtio-scsi and other SG-capable
-HBAs, because it should process the WRITE SAME input immediately,
-without letting the MODE SELECT command race with it.
-
-Fixes: 356c4c441ec ("scsi-disk: allow MODE SELECT block descriptor to set the block size", 2022-07-13)
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4365
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit d30254aec93141d6b89262986a62764b2ae07177)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/scsi/scsi-disk.c | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
-index 1b0cce128c..5bb7a974d6 100644
---- a/hw/scsi/scsi-disk.c
-+++ b/hw/scsi/scsi-disk.c
-@@ -1911,6 +1911,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- SCSIRequest *req = &r->req;
- SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
- uint32_t nb_sectors = scsi_data_cdb_xfer(r->req.cmd.buf);
-+ uint32_t buflen = MIN(s->qdev.blocksize, r->buflen);
- WriteSameCBData *data;
- uint8_t *buf;
- int i, l;
-@@ -1930,7 +1931,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- return;
- }
-
-- if ((req->cmd.buf[1] & 0x1) || buffer_is_zero(inbuf, s->qdev.blocksize)) {
-+ if ((req->cmd.buf[1] & 0x1) || buffer_is_zero(inbuf, buflen)) {
- int flags = (req->cmd.buf[1] & 0x8) ? BDRV_REQ_MAY_UNMAP : 0;
-
- /* The request is used as the AIO opaque value, so add a ref. */
-@@ -1956,7 +1957,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- qemu_iovec_init_external(&data->qiov, &data->iov, 1);
-
- for (i = 0; i < data->iov.iov_len; i += l) {
-- l = MIN(s->qdev.blocksize, data->iov.iov_len - i);
-+ l = MIN(buflen, data->iov.iov_len - i);
- memcpy(&buf[i], inbuf, l);
- }
-
diff --git a/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch b/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
deleted file mode 100644
index 28b60a97d2..0000000000
--- a/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:53:31 +0200
-Subject: [PATCH] scsi: hide MODE SELECT block size change behind a quirk
-
-This is a dangerous operation in that the block size is not
-protected by a lock, but it can be written concurrently if
-you have a multi-queue virtio-scsi HBA. Put it behind a quirk
-that is only enabled by the Q800 machine, since the MODE
-SELECT feature was added for A/UX.
-
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit 0f410adf6b0dead1f09938054da639954bda3bc1)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/m68k/q800.c | 2 ++
- hw/scsi/scsi-disk.c | 12 ++++++++++--
- include/hw/scsi/scsi.h | 1 +
- 3 files changed, 13 insertions(+), 2 deletions(-)
-
-diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
-index ab64250c47..1ad3f93b29 100644
---- a/hw/m68k/q800.c
-+++ b/hw/m68k/q800.c
-@@ -710,12 +710,14 @@ static void q800_init(Object *obj)
-
- static GlobalProperty hw_compat_q800[] = {
- { "scsi-hd", "quirk_mode_page_vendor_specific_apple", "on" },
-+ { "scsi-hd", "quirk_mode_page_set_block_size", "on" },
- { "scsi-hd", "vendor", " SEAGATE" },
- { "scsi-hd", "product", " ST225N" },
- { "scsi-hd", "ver", "1.0 " },
- { "scsi-cd", "quirk_mode_page_apple_vendor", "on" },
- { "scsi-cd", "quirk_mode_sense_rom_use_dbd", "on" },
- { "scsi-cd", "quirk_mode_page_vendor_specific_apple", "on" },
-+ { "scsi-cd", "quirk_mode_page_set_block_size", "on" },
- { "scsi-cd", "quirk_mode_page_truncated", "on" },
- { "scsi-cd", "vendor", "MATSHITA" },
- { "scsi-cd", "product", "CD-ROM CR-8005" },
-diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
-index 5bb7a974d6..a42f7d8e77 100644
---- a/hw/scsi/scsi-disk.c
-+++ b/hw/scsi/scsi-disk.c
-@@ -1673,8 +1673,12 @@ static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf)
- goto invalid_param;
- }
-
-- /* Allow changing the block size */
-- if (bd_len) {
-+ /*
-+ * Allow changing the block size only if the quirk is enabled for it.
-+ * Writing s->qdev.blocksize is not thread safe!
-+ */
-+ if (bd_len && (s->quirks &
-+ (1 << SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE))) {
- bs = p[5] << 16 | p[6] << 8 | p[7];
-
- /*
-@@ -3247,6 +3251,8 @@ static const Property scsi_hd_properties[] = {
- DEFINE_PROP_BIT("quirk_mode_page_vendor_specific_apple", SCSIDiskState,
- quirks, SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE,
- 0),
-+ DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState,
-+ quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0),
- DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf),
- };
-
-@@ -3352,6 +3358,8 @@ static const Property scsi_cd_properties[] = {
- 0),
- DEFINE_PROP_BIT("quirk_mode_page_truncated", SCSIDiskState, quirks,
- SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED, 0),
-+ DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState,
-+ quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0),
- };
-
- static void scsi_cd_class_initfn(ObjectClass *klass, const void *data)
-diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
-index c60c6e8810..3eab339b0d 100644
---- a/include/hw/scsi/scsi.h
-+++ b/include/hw/scsi/scsi.h
-@@ -262,5 +262,6 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error **errp);
- #define SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD 1
- #define SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE 2
- #define SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED 3
-+#define SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE 4
-
- #endif
diff --git a/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch b/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
deleted file mode 100644
index c0b17c6339..0000000000
--- a/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
+++ /dev/null
@@ -1,75 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 20:02:56 +0200
-Subject: [PATCH] vapic: confine the VAPIC region to 0xc0000..0xe0000
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The VAPIC region is mapped as writable RAM, at very high priority,
-above existing memory. If the guest is allowed to map it everywhere,
-it can overlap PCI BARs or even SMRAM. Ensure that the whole
-region first in the 128K of low memory that are reserved to
-option ROMs.
-
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4206
-Reported-by: Artem Dinaburg <https://gitlab.com/artem35>
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit d61c8a6fb7388486353aa267ba0d75b098f16662)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/i386/vapic.c | 16 +++++++++++++++-
- 1 file changed, 15 insertions(+), 1 deletion(-)
-
-diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
-index 8dd9188d96..9adce17262 100644
---- a/hw/i386/vapic.c
-+++ b/hw/i386/vapic.c
-@@ -34,6 +34,10 @@
- #define ROM_BLOCK_SIZE 512
- #define ROM_BLOCK_MASK (~(ROM_BLOCK_SIZE - 1))
-
-+/* Option ROM window on PC/Q35 machines; the vapic ROM must live in here. */
-+#define OPTION_ROM_START 0xc0000
-+#define OPTION_ROM_END 0xe0000
-+
- typedef enum VAPICMode {
- VAPIC_INACTIVE = 0,
- VAPIC_ACTIVE = 1,
-@@ -592,6 +596,14 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- size_t rom_size;
- uint8_t *ram;
-
-+ /*
-+ * The VAPIC region should be mapped in place, refuse mapping it
-+ * outside of the option ROM window.
-+ */
-+ if (rom_paddr < OPTION_ROM_START || rom_paddr >= OPTION_ROM_END) {
-+ return -1;
-+ }
-+
- if (s->rom_mapped_writable) {
- memory_region_del_subregion(mr, &s->rom);
- object_unparent(OBJECT(&s->rom));
-@@ -606,9 +618,10 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- }
- ram = memory_region_get_ram_ptr(section.mr);
- rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
-- if (rom_size == 0) {
-+ if (rom_size == 0 || rom_size > OPTION_ROM_END - rom_paddr) {
- return -1;
- }
-+
- s->rom_size = rom_size;
-
- /* We need to round to avoid creating subpages
-@@ -616,6 +629,7 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- rom_size += rom_paddr & ~TARGET_PAGE_MASK;
- rom_paddr &= TARGET_PAGE_MASK;
- rom_size = TARGET_PAGE_ALIGN(rom_size);
-+ assert(rom_paddr >= OPTION_ROM_START && rom_paddr + rom_size <= OPTION_ROM_END);
-
- memory_region_init_alias(&s->rom, OBJECT(s), "kvmvapic-rom", section.mr,
- rom_paddr, rom_size);
diff --git a/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch b/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
deleted file mode 100644
index c232e80930..0000000000
--- a/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:47:32 +0200
-Subject: [PATCH] i386/vapic: unref MemoryRegion if vapic_map_rom_writable
- fails
-
-memory_region_find returns the memory region with an elevated
-reference count. Drop the reference count also if the memory
-region cannot be mapped writable.
-
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit cfa6e2c52ca8f756461fe41f4ce40e61a82fd914)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/i386/vapic.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
-index 9adce17262..5c3911cf9c 100644
---- a/hw/i386/vapic.c
-+++ b/hw/i386/vapic.c
-@@ -614,11 +614,13 @@ static int vapic_map_rom_writable(VAPICROMState *s)
-
- /* read ROM size from RAM region */
- if (rom_paddr + 2 >= memory_region_size(section.mr)) {
-+ memory_region_unref(section.mr);
- return -1;
- }
- ram = memory_region_get_ram_ptr(section.mr);
- rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
- if (rom_size == 0 || rom_size > OPTION_ROM_END - rom_paddr) {
-+ memory_region_unref(section.mr);
- return -1;
- }
-
diff --git a/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch b/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
deleted file mode 100644
index 24834b364c..0000000000
--- a/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: "Denis V. Lunev" <den@openvz.org>
-Date: Mon, 31 Aug 2026 12:01:46 +0200
-Subject: [PATCH] io/channel-socket: do not treat a zero length write as an
- error
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-qio_channel_socket_writev() checks "ret <= 0" after sendmsg(). A zero
-length iovec is written successfully and returns 0, so the success
-falls into the errno switch, which acts on whatever the last failing
-syscall left in errno. A stale EAGAIN turns it into
-QIO_CHANNEL_ERR_BLOCK with errp untouched, and a caller which treats
-every negative return as fatal then passes a NULL Error to
-error_get_pretty(). The websocket handshake does exactly that, so an
-unauthenticated client crashes QEMU during the greeting.
-
-Returning 0 is safe for callers which loop until everything is
-written. qio_channel_writev_full_all() has no zero progress guard, but
-iov_copy() yields no entries for a zero length write, so that loop is
-never entered. A connected stream socket returns 0 only when there is
-nothing to send.
-
-The WIN32 implementation in the same file uses "ret < 0".
-
-Fixes: CVE-2026-84788
-Fixes: 559607ea173a ("io: add QIOChannelSocket class")
-Cc: qemu-stable@nongnu.org
-Cc: Daniel P. Berrangé <berrange@redhat.com>
-Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
-Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
-Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-Signed-off-by: Denis V. Lunev <den@openvz.org>
-Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-(cherry picked from commit a3de21bfa5d0c33110942d407ff5c7903965d3ad)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- io/channel-socket.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/io/channel-socket.c b/io/channel-socket.c
-index 12773b832c..7920cee639 100644
---- a/io/channel-socket.c
-+++ b/io/channel-socket.c
-@@ -667,7 +667,7 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
-
- retry:
- ret = sendmsg(sioc->fd, &msg, sflags);
-- if (ret <= 0) {
-+ if (ret < 0) {
- switch (errno) {
- case EAGAIN:
- return QIO_CHANNEL_ERR_BLOCK;
diff --git a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
index 3bb79c2ec0..cd951fb1a7 100644
--- a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
+++ b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index 3c985da94f..e5b942b6e4 100644
+index 90c086f1f8..2c29ee7819 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -581,7 +581,7 @@ static QemuOptsList raw_runtime_opts = {
+@@ -601,7 +601,7 @@ static QemuOptsList raw_runtime_opts = {
{
.name = "locking",
.type = QEMU_OPT_STRING,
@@ -26,7 +26,7 @@ index 3c985da94f..e5b942b6e4 100644
},
{
.name = "pr-manager",
-@@ -681,7 +681,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
+@@ -701,7 +701,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
s->use_lock = false;
break;
case ON_OFF_AUTO_AUTO:
diff --git a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
index 80d650b214..098945b4a6 100644
--- a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
+++ b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
@@ -10,10 +10,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
-index e6a197602d..0e09893d35 100644
+index 04ab0c84a3..e581fee334 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
-@@ -2792,9 +2792,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
+@@ -2791,9 +2791,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
#ifdef TARGET_X86_64
diff --git a/debian/patches/pve/0006-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch b/debian/patches/pve/0006-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
index e872eb361d..0c61285b6f 100644
--- a/debian/patches/pve/0006-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
+++ b/debian/patches/pve/0006-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 2f63d31141..2f9e8e77b8 100644
+index edf75e43ab..43f86aa773 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -3185,7 +3185,8 @@ static int img_info(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -3191,7 +3191,8 @@ static int img_info(const img_cmd_t *ccmd, int argc, char **argv)
list = collect_image_info_list(image_opts, filename, fmt, cache, chain,
limits, force_share);
if (!list) {
diff --git a/debian/patches/pve/0007-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch b/debian/patches/pve/0007-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
index 9184458394..355c333078 100644
--- a/debian/patches/pve/0007-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
+++ b/debian/patches/pve/0007-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
@@ -55,10 +55,10 @@ index 6bc8265cfb..85458ea2d8 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 2f9e8e77b8..dad04c865e 100644
+index 43f86aa773..82856a38a8 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -5320,10 +5320,12 @@ static int img_bitmap(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5326,10 +5326,12 @@ static int img_bitmap(const img_cmd_t *ccmd, int argc, char **argv)
#define C_IF 04
#define C_OF 010
#define C_SKIP 020
@@ -71,7 +71,7 @@ index 2f9e8e77b8..dad04c865e 100644
};
struct DdIo {
-@@ -5399,6 +5401,19 @@ static int img_dd_skip(const char *arg,
+@@ -5405,6 +5407,19 @@ static int img_dd_skip(const char *arg,
return 0;
}
@@ -91,7 +91,7 @@ index 2f9e8e77b8..dad04c865e 100644
static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
{
int ret = 0;
-@@ -5439,6 +5454,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5445,6 +5460,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
{ "if", img_dd_if, C_IF },
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
@@ -99,7 +99,7 @@ index 2f9e8e77b8..dad04c865e 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5536,91 +5552,112 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5542,91 +5558,112 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
arg = NULL;
}
@@ -276,7 +276,7 @@ index 2f9e8e77b8..dad04c865e 100644
}
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
-@@ -5637,20 +5674,43 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5643,20 +5680,43 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
in.buf = g_new(uint8_t, in.bsz);
for (out_pos = 0; in_pos < size; ) {
diff --git a/debian/patches/pve/0008-PVE-Up-qemu-img-dd-add-isize-parameter.patch b/debian/patches/pve/0008-PVE-Up-qemu-img-dd-add-isize-parameter.patch
index db3a1bfaa8..72dbb64ab3 100644
--- a/debian/patches/pve/0008-PVE-Up-qemu-img-dd-add-isize-parameter.patch
+++ b/debian/patches/pve/0008-PVE-Up-qemu-img-dd-add-isize-parameter.patch
@@ -17,10 +17,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
-index dad04c865e..f64a8cb3d3 100644
+index 82856a38a8..eaa143fe48 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -5321,11 +5321,13 @@ static int img_bitmap(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5327,11 +5327,13 @@ static int img_bitmap(const img_cmd_t *ccmd, int argc, char **argv)
#define C_OF 010
#define C_SKIP 020
#define C_OSIZE 040
@@ -34,7 +34,7 @@ index dad04c865e..f64a8cb3d3 100644
};
struct DdIo {
-@@ -5414,6 +5416,19 @@ static int img_dd_osize(const char *arg,
+@@ -5420,6 +5422,19 @@ static int img_dd_osize(const char *arg,
return 0;
}
@@ -54,7 +54,7 @@ index dad04c865e..f64a8cb3d3 100644
static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
{
int ret = 0;
-@@ -5428,12 +5443,14 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5434,12 +5449,14 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
int c, i;
const char *out_fmt = "raw";
const char *fmt = NULL;
@@ -70,7 +70,7 @@ index dad04c865e..f64a8cb3d3 100644
};
struct DdIo in = {
.bsz = 512, /* Block size is by default 512 bytes */
-@@ -5455,6 +5472,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5461,6 +5478,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
{ "osize", img_dd_osize, C_OSIZE },
@@ -78,7 +78,7 @@ index dad04c865e..f64a8cb3d3 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5673,9 +5691,10 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5679,9 +5697,10 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
in.buf = g_new(uint8_t, in.bsz);
@@ -91,7 +91,7 @@ index dad04c865e..f64a8cb3d3 100644
if (blk1) {
in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
if (in_ret == 0) {
-@@ -5684,6 +5703,9 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5690,6 +5709,9 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
} else {
in_ret = read(STDIN_FILENO, in.buf, bytes);
if (in_ret == 0) {
diff --git a/debian/patches/pve/0009-PVE-Up-qemu-img-dd-add-n-skip_create.patch b/debian/patches/pve/0009-PVE-Up-qemu-img-dd-add-n-skip_create.patch
index 5684d3c819..d42e207565 100644
--- a/debian/patches/pve/0009-PVE-Up-qemu-img-dd-add-n-skip_create.patch
+++ b/debian/patches/pve/0009-PVE-Up-qemu-img-dd-add-n-skip_create.patch
@@ -66,10 +66,10 @@ index 85458ea2d8..f97c2fa396 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index f64a8cb3d3..e8e2b0eb68 100644
+index eaa143fe48..25cf0babe4 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -5445,7 +5445,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5451,7 +5451,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
const char *fmt = NULL;
int64_t size = 0, readsize = 0;
int64_t out_pos, in_pos;
@@ -78,7 +78,7 @@ index f64a8cb3d3..e8e2b0eb68 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -5485,7 +5485,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5491,7 +5491,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -87,7 +87,7 @@ index f64a8cb3d3..e8e2b0eb68 100644
if (c == EOF) {
break;
}
-@@ -5526,6 +5526,9 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5532,6 +5532,9 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
case 'O':
out_fmt = optarg;
break;
@@ -97,7 +97,7 @@ index f64a8cb3d3..e8e2b0eb68 100644
case 'U':
force_share = true;
break;
-@@ -5655,13 +5658,15 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5661,13 +5664,15 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
size - in.bsz * in.offset, &error_abort);
}
diff --git a/debian/patches/pve/0010-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch b/debian/patches/pve/0010-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
index f3bd76dd6a..00a77964b6 100644
--- a/debian/patches/pve/0010-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
+++ b/debian/patches/pve/0010-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
@@ -48,10 +48,10 @@ index f97c2fa396..206ca7381c 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index e8e2b0eb68..8da92a63c0 100644
+index 25cf0babe4..21ec5615e2 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -5437,6 +5437,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5443,6 +5443,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
BlockDriver *drv = NULL, *proto_drv = NULL;
BlockBackend *blk1 = NULL, *blk2 = NULL;
QemuOpts *opts = NULL;
@@ -59,7 +59,7 @@ index e8e2b0eb68..8da92a63c0 100644
QemuOptsList *create_opts = NULL;
Error *local_err = NULL;
bool image_opts = false;
-@@ -5446,6 +5447,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5452,6 +5453,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
int64_t size = 0, readsize = 0;
int64_t out_pos, in_pos;
bool force_share = false, skip_create = false;
@@ -67,7 +67,7 @@ index e8e2b0eb68..8da92a63c0 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -5485,7 +5487,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5491,7 +5493,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -76,7 +76,7 @@ index e8e2b0eb68..8da92a63c0 100644
if (c == EOF) {
break;
}
-@@ -5529,6 +5531,19 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5535,6 +5537,19 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
case 'n':
skip_create = true;
break;
@@ -96,7 +96,7 @@ index e8e2b0eb68..8da92a63c0 100644
case 'U':
force_share = true;
break;
-@@ -5587,11 +5602,24 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5593,11 +5608,24 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
if (dd.flags & C_IF) {
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
force_share);
@@ -122,7 +122,7 @@ index e8e2b0eb68..8da92a63c0 100644
}
if (dd.flags & C_OSIZE) {
-@@ -5746,6 +5774,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
+@@ -5752,6 +5780,7 @@ static int img_dd(const img_cmd_t *ccmd, int argc, char **argv)
out:
g_free(arg);
qemu_opts_del(opts);
diff --git a/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch b/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
index c0e337a613..de48b8fe25 100644
--- a/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
+++ b/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
@@ -59,10 +59,10 @@ index 686304bafa..474afba207 100644
qapi_free_BalloonInfo(info);
}
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
-index 4c5f486ba2..58fa33fb4a 100644
+index 07d519cf6d..55c775bfe2 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
-@@ -793,8 +793,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+@@ -797,8 +797,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
diff --git a/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch b/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
index f04bc2896a..4bc6855b2e 100644
--- a/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
+++ b/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
@@ -883,10 +883,10 @@ index b1eaf7b054..0794a3a7a3 100644
# @query-migrate:
#
diff --git a/qapi/misc.json b/qapi/misc.json
-index 22b7afed9f..786aeb4d3c 100644
+index c71a5fe657..48359a8992 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
-@@ -455,6 +455,31 @@
+@@ -463,6 +463,31 @@
##
{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
diff --git a/debian/patches/pve/0016-PVE-add-optional-buffer-size-to-QEMUFile.patch b/debian/patches/pve/0016-PVE-add-optional-buffer-size-to-QEMUFile.patch
index 40ef2dcd26..fe00188373 100644
--- a/debian/patches/pve/0016-PVE-add-optional-buffer-size-to-QEMUFile.patch
+++ b/debian/patches/pve/0016-PVE-add-optional-buffer-size-to-QEMUFile.patch
@@ -21,7 +21,7 @@ Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
-index f30e13c66d..98acebce80 100644
+index eb0d63d54b..6a65f40bd6 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -34,8 +34,8 @@
diff --git a/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch b/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
index 93f0c8d78e..c88df54d03 100644
--- a/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
+++ b/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
@@ -247,10 +247,10 @@ index 0000000000..036edb17f5
+
+block_init(bdrv_zeroinit_init);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index c2f6139dea..c3204f5739 100644
+index 28d9c1e98e..07d16c4a04 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3375,7 +3375,7 @@
+@@ -3377,7 +3377,7 @@
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
@@ -259,7 +259,7 @@ index c2f6139dea..c3204f5739 100644
##
# @BlockdevOptionsFile:
-@@ -4909,7 +4909,8 @@
+@@ -4911,7 +4911,8 @@
'if': 'CONFIG_BLKIO' },
'vmdk': 'BlockdevOptionsGenericCOWFormat',
'vpc': 'BlockdevOptionsGenericFormat',
diff --git a/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch b/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
index c52036cfcc..a6a1076be7 100644
--- a/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+++ b/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
@@ -13,10 +13,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 46 insertions(+), 20 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index e5b942b6e4..adf9557428 100644
+index 2c29ee7819..73e7eb3cd2 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -2959,6 +2959,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2979,6 +2979,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
int fd;
uint64_t perm, shared;
int result = 0;
@@ -24,7 +24,7 @@ index e5b942b6e4..adf9557428 100644
/* Validate options and set default values */
assert(options->driver == BLOCKDEV_DRIVER_FILE);
-@@ -2999,19 +3000,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -3019,19 +3020,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
perm = BLK_PERM_WRITE | BLK_PERM_RESIZE;
shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
@@ -59,7 +59,7 @@ index e5b942b6e4..adf9557428 100644
}
/* Clear the file by truncating it to 0 */
-@@ -3065,13 +3069,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -3085,13 +3089,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
}
out_unlock:
@@ -82,7 +82,7 @@ index e5b942b6e4..adf9557428 100644
}
out_close:
-@@ -3095,6 +3101,7 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
+@@ -3115,6 +3121,7 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
PreallocMode prealloc;
char *buf = NULL;
Error *local_err = NULL;
@@ -90,7 +90,7 @@ index e5b942b6e4..adf9557428 100644
/* Skip file: protocol prefix */
strstart(filename, "file:", &filename);
-@@ -3117,6 +3124,18 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
+@@ -3137,6 +3144,18 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
return -EINVAL;
}
@@ -109,7 +109,7 @@ index e5b942b6e4..adf9557428 100644
options = (BlockdevCreateOptions) {
.driver = BLOCKDEV_DRIVER_FILE,
.u.file = {
-@@ -3128,6 +3147,8 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
+@@ -3148,6 +3167,8 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
.nocow = nocow,
.has_extent_size_hint = has_extent_size_hint,
.extent_size_hint = extent_size_hint,
@@ -119,10 +119,10 @@ index e5b942b6e4..adf9557428 100644
};
return raw_co_create(&options, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index c3204f5739..338675b98a 100644
+index 07d16c4a04..a12a1a2747 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -5128,6 +5128,10 @@
+@@ -5130,6 +5130,10 @@
# @extent-size-hint: Extent size hint to add to the image file; 0 for
# not adding an extent size hint (default: 1 MB, since 5.1)
#
@@ -133,7 +133,7 @@ index c3204f5739..338675b98a 100644
# Since: 2.12
##
{ 'struct': 'BlockdevCreateOptionsFile',
-@@ -5135,7 +5139,8 @@
+@@ -5137,7 +5141,8 @@
'size': 'size',
'*preallocation': 'PreallocMode',
'*nocow': 'bool',
diff --git a/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch b/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
index 98e5c0eee7..ba7324d481 100644
--- a/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
+++ b/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
@@ -259,7 +259,7 @@ index 83f858669f..d7ab3cb78f 100644
'blklogwrites.c',
'blkverify.c',
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
-index 147c08155f..41c82fc1ab 100644
+index 46428b034d..94b1dd347d 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -25,6 +25,7 @@
@@ -312,7 +312,7 @@ index 147c08155f..41c82fc1ab 100644
BDRV_TRACKED_READ,
BDRV_TRACKED_WRITE,
diff --git a/job.c b/job.c
-index e747908472..5120a01265 100644
+index d7220aaf30..40dd820fba 100644
--- a/job.c
+++ b/job.c
@@ -337,7 +337,8 @@ static bool job_started_locked(Job *job)
diff --git a/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch b/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
index 8f1b20151c..2f1c31a750 100644
--- a/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
+++ b/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
@@ -34,7 +34,7 @@ index 0e40e8b457..f4fff5fa0d 100644
* Release a reference that was previously acquired with job_txn_add_job or
* job_txn_new. If it's the last reference to the object, it will be freed.
diff --git a/job.c b/job.c
-index 5120a01265..353a0216cd 100644
+index 40dd820fba..6de4c7cfdb 100644
--- a/job.c
+++ b/job.c
@@ -94,6 +94,8 @@ struct JobTxn {
@@ -72,7 +72,7 @@ index 5120a01265..353a0216cd 100644
/* Called with job_mutex held. */
static void job_txn_ref_locked(JobTxn *txn)
{
-@@ -1048,6 +1069,12 @@ static void job_completed_txn_success_locked(Job *job)
+@@ -1055,6 +1076,12 @@ static void job_completed_txn_success_locked(Job *job)
*/
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
if (!job_is_completed_locked(other_job)) {
@@ -85,7 +85,7 @@ index 5120a01265..353a0216cd 100644
return;
}
assert(other_job->ret == 0);
-@@ -1259,6 +1286,13 @@ int job_finish_sync_locked(Job *job,
+@@ -1266,6 +1293,13 @@ int job_finish_sync_locked(Job *job,
return -EBUSY;
}
diff --git a/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch b/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
index 67bb0c2f10..e5d76c54c0 100644
--- a/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
+++ b/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
@@ -1685,7 +1685,7 @@ index 0000000000..177fb851b4
+ return ret;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 338675b98a..2a0cc0fd2a 100644
+index a12a1a2747..e66c455f6e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -952,6 +952,248 @@
diff --git a/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch b/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
index 1af35e10b7..0dbc77f807 100644
--- a/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+++ b/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
@@ -361,10 +361,10 @@ index 91de400570..b1cbaa100e 100644
summary_info += {'libdaxctl support': libdaxctl}
summary_info += {'libcbor support': libcbor}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 2a0cc0fd2a..d3349661ba 100644
+index e66c455f6e..ca18144902 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3613,6 +3613,7 @@
+@@ -3615,6 +3615,7 @@
'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
@@ -372,7 +372,7 @@ index 2a0cc0fd2a..d3349661ba 100644
'ssh', 'throttle', 'vdi', 'vhdx',
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
-@@ -3699,6 +3700,33 @@
+@@ -3701,6 +3702,33 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -406,7 +406,7 @@ index 2a0cc0fd2a..d3349661ba 100644
##
# @BlockdevOptionsNVMe:
#
-@@ -5122,6 +5150,7 @@
+@@ -5124,6 +5152,7 @@
'nfs': 'BlockdevOptionsNfs',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
diff --git a/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
index 407c9a7e2e..f14c756faa 100644
--- a/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+++ b/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
@@ -200,7 +200,7 @@ index 177fb851b4..7575abab7c 100644
ret->pbs_masterkey = true;
ret->backup_max_workers = true;
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index d3349661ba..5965a3c1f3 100644
+index ca18144902..91efb9922e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1112,6 +1112,11 @@
diff --git a/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch b/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
index d331b20701..837568d3f3 100644
--- a/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
+++ b/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
@@ -19,10 +19,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
-index cba54e25cd..23eb5f40b3 100644
+index 35623379eb..fb41949fe5 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
-@@ -539,7 +539,11 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
+@@ -540,7 +540,11 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
}
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
diff --git a/debian/patches/pve/0035-block-add-alloc-track-driver.patch b/debian/patches/pve/0035-block-add-alloc-track-driver.patch
index 1f566747f8..b54317dd3e 100644
--- a/debian/patches/pve/0035-block-add-alloc-track-driver.patch
+++ b/debian/patches/pve/0035-block-add-alloc-track-driver.patch
@@ -449,10 +449,10 @@ index d023753091..a777c8079c 100644
out:
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 5965a3c1f3..5a9ab23d5d 100644
+index 91efb9922e..80ffcc0547 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3606,7 +3606,8 @@
+@@ -3608,7 +3608,8 @@
# Since: 2.9
##
{ 'enum': 'BlockdevDriver',
@@ -462,7 +462,7 @@ index 5965a3c1f3..5a9ab23d5d 100644
'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg',
'file', 'snapshot-access', 'ftp', 'ftps',
{'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
-@@ -3706,6 +3707,21 @@
+@@ -3708,6 +3709,21 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -484,7 +484,7 @@ index 5965a3c1f3..5a9ab23d5d 100644
##
# @BlockdevOptionsPbs:
#
-@@ -5129,6 +5145,7 @@
+@@ -5131,6 +5147,7 @@
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
'discriminator': 'driver',
'data': {
diff --git a/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch b/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
index 0368018156..dbcf3bb65f 100644
--- a/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
+++ b/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
@@ -429,7 +429,7 @@ index 7575abab7c..8b83465ebd 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 5a9ab23d5d..2dd422aa03 100644
+index 80ffcc0547..62d7fb4e7a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1054,6 +1054,10 @@
diff --git a/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch b/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
index f74e82017a..ddd7b1ca3e 100644
--- a/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
+++ b/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
@@ -740,7 +740,7 @@ index 0000000000..9ebeef7c8f
+
+#endif /* PVE_BACKUP_H */
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 2dd422aa03..7ef1dd337c 100644
+index 62d7fb4e7a..5e50776664 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1128,6 +1128,9 @@
@@ -879,10 +879,10 @@ index 2dd422aa03..7ef1dd337c 100644
# @BlockDeviceTimedStats:
#
diff --git a/system/runstate.c b/system/runstate.c
-index 08acf801b0..22306e66bf 100644
+index 3c8693ccf3..b917da82e9 100644
--- a/system/runstate.c
+++ b/system/runstate.c
-@@ -64,6 +64,7 @@
+@@ -65,6 +65,7 @@
#include "ui/console.h"
#include "trace.h"
@@ -890,7 +890,7 @@ index 08acf801b0..22306e66bf 100644
static NotifierList exit_notifiers =
NOTIFIER_LIST_INITIALIZER(exit_notifiers);
-@@ -1036,6 +1037,11 @@ void qemu_cleanup(int status)
+@@ -1014,6 +1015,11 @@ void qemu_cleanup(int status)
* requests happening from here on anyway.
*/
bdrv_drain_all_begin();
diff --git a/debian/patches/series b/debian/patches/series
index a13019354d..3140ed6230 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,14 +1,7 @@
extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
extra/0002-fdmon-io_uring-avoid-idle-event-loop-being-accounted.patch
extra/0003-block-vmdk-tolerate-known-seSparse-reserved1-bit.patch
-extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
-extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
-extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
-extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
-extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
-extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
-extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
-extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
+extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
diff --git a/qemu b/qemu
index c3d48b7d1e..005c61c0ef 160000
--- a/qemu
+++ b/qemu
@@ -1 +1 @@
-Subproject commit c3d48b7d1e89604920e5b81b91140c2ad39a1943
+Subproject commit 005c61c0ef6f6ae615283440b4bb7be51b2c6ddd
--
2.47.3
^ permalink raw reply related [relevance 5%]
* [PATCH qemu v2 1/2] update submodule and patches to QEMU 11.1.2
@ 2026-10-13 8:38 6% ` Fiona Ebner
0 siblings, 0 replies; 23+ results
From: Fiona Ebner @ 2026-10-13 8:38 UTC (permalink / raw)
To: pve-devel
Picking up fixes for x86 and ARM emulation, QXL display, USB
emulation, IDE emulation, VirtIO and VirtIO-net.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
No changes in v2.
...d-support-for-sync-bitmap-mode-never.patch | 6 +-
...alidate-primary-surface-stride-again.patch | 81 ---------
...5a-gracefully-handle-re-entrant-DMA.patch} | 0
...ix-text-mode-OOB-write-after-a-graph.patch | 164 ------------------
...-fix-out-of-bound-read-in-WRITE-SAME.patch | 71 --------
...ELECT-block-size-change-behind-a-qui.patch | 89 ----------
...-the-VAPIC-region-to-0xc0000.0xe0000.patch | 75 --------
...-MemoryRegion-if-vapic_map_rom_writa.patch | 36 ----
...t-do-not-treat-a-zero-length-write-a.patch | 54 ------
...virtio-balloon-improve-query-balloon.patch | 4 +-
...async-for-background-state-snapshots.patch | 4 +-
...add-the-zeroinit-block-driver-filter.patch | 6 +-
...le-posix-make-locking-optiono-on-cre.patch | 6 +-
...-Backup-add-backup-dump-block-driver.patch | 2 +-
...d-sequential-job-transaction-support.patch | 6 +-
...ckup-Proxmox-backup-patches-for-QEMU.patch | 2 +-
...k-driver-to-map-backup-archives-into.patch | 8 +-
...igrate-dirty-bitmap-state-via-savevm.patch | 2 +-
...dirty-bitmap-migrate-other-bitmaps-e.patch | 2 +-
.../0035-block-add-alloc-track-driver.patch | 8 +-
.../0036-PVE-backup-add-fleecing-option.patch | 2 +-
...ment-backup-access-setup-and-teardow.patch | 2 +-
debian/patches/series | 9 +-
qemu | 2 +-
24 files changed, 32 insertions(+), 609 deletions(-)
delete mode 100644 debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
rename debian/patches/extra/{0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch => 0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch} (100%)
delete mode 100644 debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
delete mode 100644 debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
delete mode 100644 debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
delete mode 100644 debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
delete mode 100644 debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
delete mode 100644 debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
diff --git a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
index 40ec9887d7..8b0740a093 100644
--- a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
+++ b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
@@ -333,7 +333,7 @@ index e7c8f1a856..d5aa68caeb 100644
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 1f87b07850..c2f6139dea 100644
+index 199efc1e00..28d9c1e98e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2280,6 +2280,15 @@
@@ -363,7 +363,7 @@ index 1f87b07850..c2f6139dea 100644
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
-@@ -2598,6 +2609,15 @@
+@@ -2600,6 +2611,15 @@
# destination (all the disk, only the sectors allocated in the
# topmost image, or only new I/O).
#
@@ -379,7 +379,7 @@ index 1f87b07850..c2f6139dea 100644
# @granularity: granularity of the dirty bitmap, default is 64K if the
# image format doesn't have clusters, 4K if the clusters are
# smaller than that, else the cluster size. Must be a power of 2
-@@ -2650,7 +2670,8 @@
+@@ -2652,7 +2672,8 @@
{ 'command': 'blockdev-mirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*replaces': 'str',
diff --git a/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch b/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
deleted file mode 100644
index 299927cb83..0000000000
--- a/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
-Date: Mon, 20 Jul 2026 15:45:13 +0400
-Subject: [PATCH] hw/display/qxl: validate primary surface stride against width
-
-The existing validation in qxl_create_guest_primary() checks that
-abs(stride) * height fits in vgamem_size and that stride is 4-byte
-aligned, but never checks that abs(stride) is large enough to hold one
-row of pixels for the declared width and format.
-
-A malicious guest can create a primary surface with a stride much
-smaller than width * bytes_per_pixel (e.g. stride=4 for a 64-wide 32bpp
-surface). The spice server rejects this via red_validate_surface(), but
-the return is void and QEMU unconditionally proceeds to set up the local
-rendering state. On the next display refresh, VNC or SDL reads width *
-byptes_pp per scanline from a region backed by only stride bytes per
-row, causing a host-side out-of-bounds read.
-
-Add three checks before creating the surface:
- - reject unknown surface formats
- - reject zero width or height
- - reject surfaces where abs(stride) < width * bytes_per_pixel
-
-Fixes: CVE-2026-16271
-Fixes: 3761abb16784 ("hw/display/qxl: fix signed to unsigned comparison")
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3637
-Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
-Link: https://lore.kernel.org/qemu-devel/20260720114513.2500370-1-marcandre.lureau@redhat.com
-(picked from qemu-devel)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/display/qxl.c | 29 +++++++++++++++++++++++++++++
- 1 file changed, 29 insertions(+)
-
-diff --git a/hw/display/qxl.c b/hw/display/qxl.c
-index b7d871b9ee..41673c369b 100644
---- a/hw/display/qxl.c
-+++ b/hw/display/qxl.c
-@@ -1496,6 +1496,7 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
- QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
- uint32_t requested_height = le32_to_cpu(sc->height);
- int requested_stride = le32_to_cpu(sc->stride);
-+ uint32_t bytes_pp;
-
- if (requested_stride == INT32_MIN ||
- abs(requested_stride) * (uint64_t)requested_height
-@@ -1532,6 +1533,34 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
- return;
- }
-
-+ switch (surface.format) {
-+ case SPICE_SURFACE_FMT_16_555:
-+ case SPICE_SURFACE_FMT_16_565:
-+ bytes_pp = 2;
-+ break;
-+ case SPICE_SURFACE_FMT_32_xRGB:
-+ case SPICE_SURFACE_FMT_32_ARGB:
-+ bytes_pp = 4;
-+ break;
-+ default:
-+ qxl_set_guest_bug(qxl, "%s: unhandled format %d",
-+ __func__, surface.format);
-+ return;
-+ }
-+
-+ if (surface.width == 0 || surface.height == 0) {
-+ qxl_set_guest_bug(qxl, "%s: zero dimension %ux%u",
-+ __func__, surface.width, surface.height);
-+ return;
-+ }
-+
-+ if ((uint64_t)surface.width * bytes_pp > abs(surface.stride)) {
-+ qxl_set_guest_bug(qxl, "%s: stride too small for width:"
-+ " stride %d width %u bpp %u",
-+ __func__, surface.stride, surface.width, bytes_pp);
-+ return;
-+ }
-+
- surface.mouse_mode = true;
- surface.group_id = MEMSLOT_GROUP_GUEST;
- if (loadvm) {
diff --git a/debian/patches/extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch b/debian/patches/extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
similarity index 100%
rename from debian/patches/extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
rename to debian/patches/extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
diff --git a/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch b/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
deleted file mode 100644
index 9c7c7f6d32..0000000000
--- a/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
+++ /dev/null
@@ -1,164 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Warisjeet Singh <sinxx198@gmail.com>
-Date: Mon, 24 Aug 2026 12:47:26 -0400
-Subject: [PATCH] hw/display/vga: fix text-mode OOB write after a graphics
- surface switch
-
-vga_draw_text() decides whether the console surface needs a resize from
-its geometry cache, but none of the cache terms observe the graphics
-renderer having replaced the console surface in between:
-
-- last_width/last_height are shared with vga_draw_graphic(), which
- stores them in pixels while the text path stores characters;
-- last_depth stays 0 for legacy (non-VBE) graphics modes, because
- vga_get_bpp() only reports a depth when VBE is enabled, so the
- "s->last_depth" term that normally forces a resize after a graphics
- frame does not fire.
-
-So a graphics frame that shrinks the console surface (e.g. 80x25
-pixels) followed by a text frame with matching character geometry
-(80x25 chars) skips the resize, and the glyph loop then paints
-width*cw x height*cheight pixels into the smaller surface, out of
-bounds, with guest-controlled (DAC palette) values, on every display
-refresh.
-
-Separate the geometry cache per renderer: text paths (vga_draw_text,
-vga_update_text, and the text handling in vga_invalidate_display /
-vga_common_reset) now only manipulate last_text_{width,height}, in
-characters; last_{width,height} become graphics-only, in pixels.
-Additionally, make the text path compare the pixel size it is about
-to paint against the console surface's actual dimensions. The
-surface check is the load-bearing term: caches in either unit cannot
-see the other renderer swapping the surface, the surface can.
-
-Fixes: CVE-2026-77913
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4215
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Warisjeet Singh (sin99xx) <sinxx198@gmail.com>
-Message-ID: <vga-v3-20260824.sinxx198@gmail.com>
-(cherry picked from commit 418396be8013386a81f8d8d89ac0effcf03a64b6)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/display/vga.c | 37 ++++++++++++++++++++++---------------
- hw/display/vga_int.h | 3 ++-
- 2 files changed, 24 insertions(+), 16 deletions(-)
-
-diff --git a/hw/display/vga.c b/hw/display/vga.c
-index da0c331486..cb0e28b79b 100644
---- a/hw/display/vga.c
-+++ b/hw/display/vga.c
-@@ -1241,7 +1241,10 @@ static void vga_draw_text(VGACommonState *s, int full_update)
- return;
- }
-
-- if (width != s->last_width || height != s->last_height ||
-+ if (surface == NULL ||
-+ surface_width(surface) != width * cw ||
-+ surface_height(surface) != height * cheight ||
-+ width != s->last_text_width || height != s->last_text_height ||
- cw != s->last_cw || cheight != s->last_ch || s->last_depth) {
- s->last_scr_width = width * cw;
- s->last_scr_height = height * cheight;
-@@ -1249,8 +1252,8 @@ static void vga_draw_text(VGACommonState *s, int full_update)
- surface = qemu_console_surface(s->con);
- qemu_console_text_resize(s->con, width, height);
- s->last_depth = 0;
-- s->last_width = width;
-- s->last_height = height;
-+ s->last_text_width = width;
-+ s->last_text_height = height;
- s->last_ch = cheight;
- s->last_cw = cw;
- full_update = 1;
-@@ -1845,6 +1848,8 @@ static void vga_invalidate_display(void *opaque)
-
- s->last_width = -1;
- s->last_height = -1;
-+ s->last_text_width = -1;
-+ s->last_text_height = -1;
- }
-
- void vga_common_reset(VGACommonState *s)
-@@ -1887,6 +1892,8 @@ void vga_common_reset(VGACommonState *s)
- s->last_ch = 0;
- s->last_width = 0;
- s->last_height = 0;
-+ s->last_text_width = 0;
-+ s->last_text_height = 0;
- s->last_scr_width = 0;
- s->last_scr_height = 0;
- s->cursor_start = 0;
-@@ -1938,8 +1945,8 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- s->graphic_mode = graphic_mode;
- full_update = 1;
- }
-- if (s->last_width == -1) {
-- s->last_width = 0;
-+ if (s->last_text_width == -1) {
-+ s->last_text_width = 0;
- full_update = 1;
- }
-
-@@ -1978,15 +1985,15 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- break;
- }
-
-- if (width != s->last_width || height != s->last_height ||
-+ if (width != s->last_text_width || height != s->last_text_height ||
- cw != s->last_cw || cheight != s->last_ch) {
- s->last_scr_width = width * cw;
- s->last_scr_height = height * cheight;
- qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height);
- qemu_console_text_resize(s->con, width, height);
- s->last_depth = 0;
-- s->last_width = width;
-- s->last_height = height;
-+ s->last_text_width = width;
-+ s->last_text_height = height;
- s->last_ch = cheight;
- s->last_cw = cw;
- full_update = 1;
-@@ -2071,22 +2078,22 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- }
-
- /* Display a message */
-- s->last_width = 60;
-- s->last_height = height = 3;
-+ s->last_text_width = 60;
-+ s->last_text_height = height = 3;
- qemu_console_text_set_cursor(s->con, -1, -1);
-- qemu_console_text_resize(s->con, s->last_width, height);
-+ qemu_console_text_resize(s->con, s->last_text_width, height);
-
-- for (dst = chardata, i = 0; i < s->last_width * height; i ++)
-+ for (dst = chardata, i = 0; i < s->last_text_width * height; i ++)
- *dst++ = ' ';
-
- size = strlen(msg_buffer);
-- width = (s->last_width - size) / 2;
-- dst = chardata + s->last_width + width;
-+ width = (s->last_text_width - size) / 2;
-+ dst = chardata + s->last_text_width + width;
- for (i = 0; i < size; i ++)
- *dst++ = ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE,
- QEMU_COLOR_BLACK, 1);
-
-- qemu_console_text_update(s->con, 0, 0, s->last_width, height);
-+ qemu_console_text_update(s->con, 0, 0, s->last_text_width, height);
- }
-
- static uint64_t vga_mem_read(void *opaque, hwaddr addr,
-diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
-index 5664317ecd..ca69ae9815 100644
---- a/hw/display/vga_int.h
-+++ b/hw/display/vga_int.h
-@@ -122,7 +122,8 @@ typedef struct VGACommonState {
- uint32_t plane_updated;
- uint32_t last_line_offset;
- uint8_t last_cw, last_ch;
-- uint32_t last_width, last_height; /* in chars or pixels */
-+ uint32_t last_width, last_height; /* in pixels (graphics renderer) */
-+ uint32_t last_text_width, last_text_height; /* in chars (text renderer) */
- uint32_t last_scr_width, last_scr_height; /* in pixels */
- uint32_t last_depth; /* in bits */
- bool last_byteswap;
diff --git a/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch b/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
deleted file mode 100644
index ffab5481da..0000000000
--- a/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:22:41 +0200
-Subject: [PATCH] scsi-disk: fix out-of-bound read in WRITE SAME
-
-A guest with an attached scsi-hd can force QEMU's SCSI disk emulation
-to read roughly 60 KiB past the end of a heap buffer, copying that out
-of bounds host memory into the guest's own disk image.
-
-WRITE SAME computes the request transfer length at dev->blocksize
-when the request is prepared and sets cmd->xfer from dev->blocksize.
-scsi_disk_emulate_command() then uses cmd->xfer as the size of the
-request buffer.
-
-However, MODE SELECT can race with the WRITE SAME command and guest raise
-the logical block size to any value whose low bits fit 0xfe00, up to 65024.
-In the presence of this race, scsi_disk_emulate_write_same() will read
-from memory as many bytes as indicated by the *new* dev->blocksize,
-and write it to disk.
-
-The read length in WRITE SAME must be bounded by the buffer that was
-actually allocated, not by the mutable s->qdev.blocksize, so clamp the
-length used against inbuf to r->buflen. Re-validating req->cmd.xfer
-against the current block size would not work because the race is
-intrinsic in the SCSI protocol.
-
-I am not sure if this is exploitable with virtio-scsi and other SG-capable
-HBAs, because it should process the WRITE SAME input immediately,
-without letting the MODE SELECT command race with it.
-
-Fixes: 356c4c441ec ("scsi-disk: allow MODE SELECT block descriptor to set the block size", 2022-07-13)
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4365
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit d30254aec93141d6b89262986a62764b2ae07177)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/scsi/scsi-disk.c | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
-index 1b0cce128c..5bb7a974d6 100644
---- a/hw/scsi/scsi-disk.c
-+++ b/hw/scsi/scsi-disk.c
-@@ -1911,6 +1911,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- SCSIRequest *req = &r->req;
- SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
- uint32_t nb_sectors = scsi_data_cdb_xfer(r->req.cmd.buf);
-+ uint32_t buflen = MIN(s->qdev.blocksize, r->buflen);
- WriteSameCBData *data;
- uint8_t *buf;
- int i, l;
-@@ -1930,7 +1931,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- return;
- }
-
-- if ((req->cmd.buf[1] & 0x1) || buffer_is_zero(inbuf, s->qdev.blocksize)) {
-+ if ((req->cmd.buf[1] & 0x1) || buffer_is_zero(inbuf, buflen)) {
- int flags = (req->cmd.buf[1] & 0x8) ? BDRV_REQ_MAY_UNMAP : 0;
-
- /* The request is used as the AIO opaque value, so add a ref. */
-@@ -1956,7 +1957,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- qemu_iovec_init_external(&data->qiov, &data->iov, 1);
-
- for (i = 0; i < data->iov.iov_len; i += l) {
-- l = MIN(s->qdev.blocksize, data->iov.iov_len - i);
-+ l = MIN(buflen, data->iov.iov_len - i);
- memcpy(&buf[i], inbuf, l);
- }
-
diff --git a/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch b/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
deleted file mode 100644
index 28b60a97d2..0000000000
--- a/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:53:31 +0200
-Subject: [PATCH] scsi: hide MODE SELECT block size change behind a quirk
-
-This is a dangerous operation in that the block size is not
-protected by a lock, but it can be written concurrently if
-you have a multi-queue virtio-scsi HBA. Put it behind a quirk
-that is only enabled by the Q800 machine, since the MODE
-SELECT feature was added for A/UX.
-
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit 0f410adf6b0dead1f09938054da639954bda3bc1)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/m68k/q800.c | 2 ++
- hw/scsi/scsi-disk.c | 12 ++++++++++--
- include/hw/scsi/scsi.h | 1 +
- 3 files changed, 13 insertions(+), 2 deletions(-)
-
-diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
-index ab64250c47..1ad3f93b29 100644
---- a/hw/m68k/q800.c
-+++ b/hw/m68k/q800.c
-@@ -710,12 +710,14 @@ static void q800_init(Object *obj)
-
- static GlobalProperty hw_compat_q800[] = {
- { "scsi-hd", "quirk_mode_page_vendor_specific_apple", "on" },
-+ { "scsi-hd", "quirk_mode_page_set_block_size", "on" },
- { "scsi-hd", "vendor", " SEAGATE" },
- { "scsi-hd", "product", " ST225N" },
- { "scsi-hd", "ver", "1.0 " },
- { "scsi-cd", "quirk_mode_page_apple_vendor", "on" },
- { "scsi-cd", "quirk_mode_sense_rom_use_dbd", "on" },
- { "scsi-cd", "quirk_mode_page_vendor_specific_apple", "on" },
-+ { "scsi-cd", "quirk_mode_page_set_block_size", "on" },
- { "scsi-cd", "quirk_mode_page_truncated", "on" },
- { "scsi-cd", "vendor", "MATSHITA" },
- { "scsi-cd", "product", "CD-ROM CR-8005" },
-diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
-index 5bb7a974d6..a42f7d8e77 100644
---- a/hw/scsi/scsi-disk.c
-+++ b/hw/scsi/scsi-disk.c
-@@ -1673,8 +1673,12 @@ static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf)
- goto invalid_param;
- }
-
-- /* Allow changing the block size */
-- if (bd_len) {
-+ /*
-+ * Allow changing the block size only if the quirk is enabled for it.
-+ * Writing s->qdev.blocksize is not thread safe!
-+ */
-+ if (bd_len && (s->quirks &
-+ (1 << SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE))) {
- bs = p[5] << 16 | p[6] << 8 | p[7];
-
- /*
-@@ -3247,6 +3251,8 @@ static const Property scsi_hd_properties[] = {
- DEFINE_PROP_BIT("quirk_mode_page_vendor_specific_apple", SCSIDiskState,
- quirks, SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE,
- 0),
-+ DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState,
-+ quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0),
- DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf),
- };
-
-@@ -3352,6 +3358,8 @@ static const Property scsi_cd_properties[] = {
- 0),
- DEFINE_PROP_BIT("quirk_mode_page_truncated", SCSIDiskState, quirks,
- SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED, 0),
-+ DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState,
-+ quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0),
- };
-
- static void scsi_cd_class_initfn(ObjectClass *klass, const void *data)
-diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
-index c60c6e8810..3eab339b0d 100644
---- a/include/hw/scsi/scsi.h
-+++ b/include/hw/scsi/scsi.h
-@@ -262,5 +262,6 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error **errp);
- #define SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD 1
- #define SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE 2
- #define SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED 3
-+#define SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE 4
-
- #endif
diff --git a/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch b/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
deleted file mode 100644
index c0b17c6339..0000000000
--- a/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
+++ /dev/null
@@ -1,75 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 20:02:56 +0200
-Subject: [PATCH] vapic: confine the VAPIC region to 0xc0000..0xe0000
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The VAPIC region is mapped as writable RAM, at very high priority,
-above existing memory. If the guest is allowed to map it everywhere,
-it can overlap PCI BARs or even SMRAM. Ensure that the whole
-region first in the 128K of low memory that are reserved to
-option ROMs.
-
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4206
-Reported-by: Artem Dinaburg <https://gitlab.com/artem35>
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit d61c8a6fb7388486353aa267ba0d75b098f16662)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/i386/vapic.c | 16 +++++++++++++++-
- 1 file changed, 15 insertions(+), 1 deletion(-)
-
-diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
-index 8dd9188d96..9adce17262 100644
---- a/hw/i386/vapic.c
-+++ b/hw/i386/vapic.c
-@@ -34,6 +34,10 @@
- #define ROM_BLOCK_SIZE 512
- #define ROM_BLOCK_MASK (~(ROM_BLOCK_SIZE - 1))
-
-+/* Option ROM window on PC/Q35 machines; the vapic ROM must live in here. */
-+#define OPTION_ROM_START 0xc0000
-+#define OPTION_ROM_END 0xe0000
-+
- typedef enum VAPICMode {
- VAPIC_INACTIVE = 0,
- VAPIC_ACTIVE = 1,
-@@ -592,6 +596,14 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- size_t rom_size;
- uint8_t *ram;
-
-+ /*
-+ * The VAPIC region should be mapped in place, refuse mapping it
-+ * outside of the option ROM window.
-+ */
-+ if (rom_paddr < OPTION_ROM_START || rom_paddr >= OPTION_ROM_END) {
-+ return -1;
-+ }
-+
- if (s->rom_mapped_writable) {
- memory_region_del_subregion(mr, &s->rom);
- object_unparent(OBJECT(&s->rom));
-@@ -606,9 +618,10 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- }
- ram = memory_region_get_ram_ptr(section.mr);
- rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
-- if (rom_size == 0) {
-+ if (rom_size == 0 || rom_size > OPTION_ROM_END - rom_paddr) {
- return -1;
- }
-+
- s->rom_size = rom_size;
-
- /* We need to round to avoid creating subpages
-@@ -616,6 +629,7 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- rom_size += rom_paddr & ~TARGET_PAGE_MASK;
- rom_paddr &= TARGET_PAGE_MASK;
- rom_size = TARGET_PAGE_ALIGN(rom_size);
-+ assert(rom_paddr >= OPTION_ROM_START && rom_paddr + rom_size <= OPTION_ROM_END);
-
- memory_region_init_alias(&s->rom, OBJECT(s), "kvmvapic-rom", section.mr,
- rom_paddr, rom_size);
diff --git a/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch b/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
deleted file mode 100644
index c232e80930..0000000000
--- a/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:47:32 +0200
-Subject: [PATCH] i386/vapic: unref MemoryRegion if vapic_map_rom_writable
- fails
-
-memory_region_find returns the memory region with an elevated
-reference count. Drop the reference count also if the memory
-region cannot be mapped writable.
-
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit cfa6e2c52ca8f756461fe41f4ce40e61a82fd914)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/i386/vapic.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
-index 9adce17262..5c3911cf9c 100644
---- a/hw/i386/vapic.c
-+++ b/hw/i386/vapic.c
-@@ -614,11 +614,13 @@ static int vapic_map_rom_writable(VAPICROMState *s)
-
- /* read ROM size from RAM region */
- if (rom_paddr + 2 >= memory_region_size(section.mr)) {
-+ memory_region_unref(section.mr);
- return -1;
- }
- ram = memory_region_get_ram_ptr(section.mr);
- rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
- if (rom_size == 0 || rom_size > OPTION_ROM_END - rom_paddr) {
-+ memory_region_unref(section.mr);
- return -1;
- }
-
diff --git a/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch b/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
deleted file mode 100644
index 24834b364c..0000000000
--- a/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: "Denis V. Lunev" <den@openvz.org>
-Date: Mon, 31 Aug 2026 12:01:46 +0200
-Subject: [PATCH] io/channel-socket: do not treat a zero length write as an
- error
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-qio_channel_socket_writev() checks "ret <= 0" after sendmsg(). A zero
-length iovec is written successfully and returns 0, so the success
-falls into the errno switch, which acts on whatever the last failing
-syscall left in errno. A stale EAGAIN turns it into
-QIO_CHANNEL_ERR_BLOCK with errp untouched, and a caller which treats
-every negative return as fatal then passes a NULL Error to
-error_get_pretty(). The websocket handshake does exactly that, so an
-unauthenticated client crashes QEMU during the greeting.
-
-Returning 0 is safe for callers which loop until everything is
-written. qio_channel_writev_full_all() has no zero progress guard, but
-iov_copy() yields no entries for a zero length write, so that loop is
-never entered. A connected stream socket returns 0 only when there is
-nothing to send.
-
-The WIN32 implementation in the same file uses "ret < 0".
-
-Fixes: CVE-2026-84788
-Fixes: 559607ea173a ("io: add QIOChannelSocket class")
-Cc: qemu-stable@nongnu.org
-Cc: Daniel P. Berrangé <berrange@redhat.com>
-Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
-Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
-Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-Signed-off-by: Denis V. Lunev <den@openvz.org>
-Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-(cherry picked from commit a3de21bfa5d0c33110942d407ff5c7903965d3ad)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- io/channel-socket.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/io/channel-socket.c b/io/channel-socket.c
-index 12773b832c..7920cee639 100644
---- a/io/channel-socket.c
-+++ b/io/channel-socket.c
-@@ -667,7 +667,7 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
-
- retry:
- ret = sendmsg(sioc->fd, &msg, sflags);
-- if (ret <= 0) {
-+ if (ret < 0) {
- switch (errno) {
- case EAGAIN:
- return QIO_CHANNEL_ERR_BLOCK;
diff --git a/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch b/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
index c0e337a613..de48b8fe25 100644
--- a/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
+++ b/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
@@ -59,10 +59,10 @@ index 686304bafa..474afba207 100644
qapi_free_BalloonInfo(info);
}
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
-index 4c5f486ba2..58fa33fb4a 100644
+index 07d519cf6d..55c775bfe2 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
-@@ -793,8 +793,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+@@ -797,8 +797,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
diff --git a/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch b/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
index f04bc2896a..4bc6855b2e 100644
--- a/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
+++ b/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
@@ -883,10 +883,10 @@ index b1eaf7b054..0794a3a7a3 100644
# @query-migrate:
#
diff --git a/qapi/misc.json b/qapi/misc.json
-index 22b7afed9f..786aeb4d3c 100644
+index c71a5fe657..48359a8992 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
-@@ -455,6 +455,31 @@
+@@ -463,6 +463,31 @@
##
{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
diff --git a/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch b/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
index 93f0c8d78e..c88df54d03 100644
--- a/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
+++ b/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
@@ -247,10 +247,10 @@ index 0000000000..036edb17f5
+
+block_init(bdrv_zeroinit_init);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index c2f6139dea..c3204f5739 100644
+index 28d9c1e98e..07d16c4a04 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3375,7 +3375,7 @@
+@@ -3377,7 +3377,7 @@
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
@@ -259,7 +259,7 @@ index c2f6139dea..c3204f5739 100644
##
# @BlockdevOptionsFile:
-@@ -4909,7 +4909,8 @@
+@@ -4911,7 +4911,8 @@
'if': 'CONFIG_BLKIO' },
'vmdk': 'BlockdevOptionsGenericCOWFormat',
'vpc': 'BlockdevOptionsGenericFormat',
diff --git a/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch b/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
index c52036cfcc..19a9952b75 100644
--- a/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+++ b/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
@@ -119,10 +119,10 @@ index e5b942b6e4..adf9557428 100644
};
return raw_co_create(&options, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index c3204f5739..338675b98a 100644
+index 07d16c4a04..a12a1a2747 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -5128,6 +5128,10 @@
+@@ -5130,6 +5130,10 @@
# @extent-size-hint: Extent size hint to add to the image file; 0 for
# not adding an extent size hint (default: 1 MB, since 5.1)
#
@@ -133,7 +133,7 @@ index c3204f5739..338675b98a 100644
# Since: 2.12
##
{ 'struct': 'BlockdevCreateOptionsFile',
-@@ -5135,7 +5139,8 @@
+@@ -5137,7 +5141,8 @@
'size': 'size',
'*preallocation': 'PreallocMode',
'*nocow': 'bool',
diff --git a/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch b/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
index 98e5c0eee7..e23026c00b 100644
--- a/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
+++ b/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
@@ -312,7 +312,7 @@ index 147c08155f..41c82fc1ab 100644
BDRV_TRACKED_READ,
BDRV_TRACKED_WRITE,
diff --git a/job.c b/job.c
-index e747908472..5120a01265 100644
+index d7220aaf30..40dd820fba 100644
--- a/job.c
+++ b/job.c
@@ -337,7 +337,8 @@ static bool job_started_locked(Job *job)
diff --git a/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch b/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
index 8f1b20151c..2f1c31a750 100644
--- a/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
+++ b/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
@@ -34,7 +34,7 @@ index 0e40e8b457..f4fff5fa0d 100644
* Release a reference that was previously acquired with job_txn_add_job or
* job_txn_new. If it's the last reference to the object, it will be freed.
diff --git a/job.c b/job.c
-index 5120a01265..353a0216cd 100644
+index 40dd820fba..6de4c7cfdb 100644
--- a/job.c
+++ b/job.c
@@ -94,6 +94,8 @@ struct JobTxn {
@@ -72,7 +72,7 @@ index 5120a01265..353a0216cd 100644
/* Called with job_mutex held. */
static void job_txn_ref_locked(JobTxn *txn)
{
-@@ -1048,6 +1069,12 @@ static void job_completed_txn_success_locked(Job *job)
+@@ -1055,6 +1076,12 @@ static void job_completed_txn_success_locked(Job *job)
*/
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
if (!job_is_completed_locked(other_job)) {
@@ -85,7 +85,7 @@ index 5120a01265..353a0216cd 100644
return;
}
assert(other_job->ret == 0);
-@@ -1259,6 +1286,13 @@ int job_finish_sync_locked(Job *job,
+@@ -1266,6 +1293,13 @@ int job_finish_sync_locked(Job *job,
return -EBUSY;
}
diff --git a/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch b/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
index 67bb0c2f10..e5d76c54c0 100644
--- a/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
+++ b/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
@@ -1685,7 +1685,7 @@ index 0000000000..177fb851b4
+ return ret;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 338675b98a..2a0cc0fd2a 100644
+index a12a1a2747..e66c455f6e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -952,6 +952,248 @@
diff --git a/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch b/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
index 1af35e10b7..0dbc77f807 100644
--- a/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+++ b/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
@@ -361,10 +361,10 @@ index 91de400570..b1cbaa100e 100644
summary_info += {'libdaxctl support': libdaxctl}
summary_info += {'libcbor support': libcbor}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 2a0cc0fd2a..d3349661ba 100644
+index e66c455f6e..ca18144902 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3613,6 +3613,7 @@
+@@ -3615,6 +3615,7 @@
'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
@@ -372,7 +372,7 @@ index 2a0cc0fd2a..d3349661ba 100644
'ssh', 'throttle', 'vdi', 'vhdx',
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
-@@ -3699,6 +3700,33 @@
+@@ -3701,6 +3702,33 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -406,7 +406,7 @@ index 2a0cc0fd2a..d3349661ba 100644
##
# @BlockdevOptionsNVMe:
#
-@@ -5122,6 +5150,7 @@
+@@ -5124,6 +5152,7 @@
'nfs': 'BlockdevOptionsNfs',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
diff --git a/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
index 407c9a7e2e..f14c756faa 100644
--- a/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+++ b/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
@@ -200,7 +200,7 @@ index 177fb851b4..7575abab7c 100644
ret->pbs_masterkey = true;
ret->backup_max_workers = true;
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index d3349661ba..5965a3c1f3 100644
+index ca18144902..91efb9922e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1112,6 +1112,11 @@
diff --git a/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch b/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
index d331b20701..b5394a53b0 100644
--- a/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
+++ b/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
-index cba54e25cd..23eb5f40b3 100644
+index 1b8f39c12b..00e35179e6 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -539,7 +539,11 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
diff --git a/debian/patches/pve/0035-block-add-alloc-track-driver.patch b/debian/patches/pve/0035-block-add-alloc-track-driver.patch
index 1f566747f8..b54317dd3e 100644
--- a/debian/patches/pve/0035-block-add-alloc-track-driver.patch
+++ b/debian/patches/pve/0035-block-add-alloc-track-driver.patch
@@ -449,10 +449,10 @@ index d023753091..a777c8079c 100644
out:
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 5965a3c1f3..5a9ab23d5d 100644
+index 91efb9922e..80ffcc0547 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3606,7 +3606,8 @@
+@@ -3608,7 +3608,8 @@
# Since: 2.9
##
{ 'enum': 'BlockdevDriver',
@@ -462,7 +462,7 @@ index 5965a3c1f3..5a9ab23d5d 100644
'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg',
'file', 'snapshot-access', 'ftp', 'ftps',
{'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
-@@ -3706,6 +3707,21 @@
+@@ -3708,6 +3709,21 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -484,7 +484,7 @@ index 5965a3c1f3..5a9ab23d5d 100644
##
# @BlockdevOptionsPbs:
#
-@@ -5129,6 +5145,7 @@
+@@ -5131,6 +5147,7 @@
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
'discriminator': 'driver',
'data': {
diff --git a/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch b/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
index 0368018156..dbcf3bb65f 100644
--- a/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
+++ b/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
@@ -429,7 +429,7 @@ index 7575abab7c..8b83465ebd 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 5a9ab23d5d..2dd422aa03 100644
+index 80ffcc0547..62d7fb4e7a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1054,6 +1054,10 @@
diff --git a/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch b/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
index f74e82017a..598ed3e441 100644
--- a/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
+++ b/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
@@ -740,7 +740,7 @@ index 0000000000..9ebeef7c8f
+
+#endif /* PVE_BACKUP_H */
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 2dd422aa03..7ef1dd337c 100644
+index 62d7fb4e7a..5e50776664 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1128,6 +1128,9 @@
diff --git a/debian/patches/series b/debian/patches/series
index a13019354d..3140ed6230 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,14 +1,7 @@
extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
extra/0002-fdmon-io_uring-avoid-idle-event-loop-being-accounted.patch
extra/0003-block-vmdk-tolerate-known-seSparse-reserved1-bit.patch
-extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
-extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
-extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
-extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
-extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
-extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
-extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
-extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
+extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
diff --git a/qemu b/qemu
index c3d48b7d1e..4fc49f46dc 160000
--- a/qemu
+++ b/qemu
@@ -1 +1 @@
-Subproject commit c3d48b7d1e89604920e5b81b91140c2ad39a1943
+Subproject commit 4fc49f46dc95d4a27de2509e7fceb2931e91faeb
--
2.47.3
^ permalink raw reply related [relevance 6%]
* [PATCH qemu 1/2] update submodule and patches to QEMU 11.1.2
@ 2026-10-12 10:51 6% ` Fiona Ebner
0 siblings, 0 replies; 23+ results
From: Fiona Ebner @ 2026-10-12 10:51 UTC (permalink / raw)
To: pve-devel
Picking up fixes for x86 and ARM emulation, QXL display, USB
emulation, IDE emulation, VirtIO and VirtIO-net.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
...d-support-for-sync-bitmap-mode-never.patch | 6 +-
...alidate-primary-surface-stride-again.patch | 81 ---------
...5a-gracefully-handle-re-entrant-DMA.patch} | 0
...ix-text-mode-OOB-write-after-a-graph.patch | 164 ------------------
...-fix-out-of-bound-read-in-WRITE-SAME.patch | 71 --------
...ELECT-block-size-change-behind-a-qui.patch | 89 ----------
...-the-VAPIC-region-to-0xc0000.0xe0000.patch | 75 --------
...-MemoryRegion-if-vapic_map_rom_writa.patch | 36 ----
...t-do-not-treat-a-zero-length-write-a.patch | 54 ------
...virtio-balloon-improve-query-balloon.patch | 4 +-
...async-for-background-state-snapshots.patch | 4 +-
...add-the-zeroinit-block-driver-filter.patch | 6 +-
...le-posix-make-locking-optiono-on-cre.patch | 6 +-
...-Backup-add-backup-dump-block-driver.patch | 2 +-
...d-sequential-job-transaction-support.patch | 6 +-
...ckup-Proxmox-backup-patches-for-QEMU.patch | 2 +-
...k-driver-to-map-backup-archives-into.patch | 8 +-
...igrate-dirty-bitmap-state-via-savevm.patch | 2 +-
...dirty-bitmap-migrate-other-bitmaps-e.patch | 2 +-
.../0035-block-add-alloc-track-driver.patch | 8 +-
.../0036-PVE-backup-add-fleecing-option.patch | 2 +-
...ment-backup-access-setup-and-teardow.patch | 2 +-
debian/patches/series | 9 +-
qemu | 2 +-
24 files changed, 32 insertions(+), 609 deletions(-)
delete mode 100644 debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
rename debian/patches/extra/{0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch => 0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch} (100%)
delete mode 100644 debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
delete mode 100644 debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
delete mode 100644 debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
delete mode 100644 debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
delete mode 100644 debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
delete mode 100644 debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
diff --git a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
index 40ec9887d7..8b0740a093 100644
--- a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
+++ b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
@@ -333,7 +333,7 @@ index e7c8f1a856..d5aa68caeb 100644
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 1f87b07850..c2f6139dea 100644
+index 199efc1e00..28d9c1e98e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2280,6 +2280,15 @@
@@ -363,7 +363,7 @@ index 1f87b07850..c2f6139dea 100644
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
-@@ -2598,6 +2609,15 @@
+@@ -2600,6 +2611,15 @@
# destination (all the disk, only the sectors allocated in the
# topmost image, or only new I/O).
#
@@ -379,7 +379,7 @@ index 1f87b07850..c2f6139dea 100644
# @granularity: granularity of the dirty bitmap, default is 64K if the
# image format doesn't have clusters, 4K if the clusters are
# smaller than that, else the cluster size. Must be a power of 2
-@@ -2650,7 +2670,8 @@
+@@ -2652,7 +2672,8 @@
{ 'command': 'blockdev-mirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*replaces': 'str',
diff --git a/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch b/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
deleted file mode 100644
index 299927cb83..0000000000
--- a/debian/patches/extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
-Date: Mon, 20 Jul 2026 15:45:13 +0400
-Subject: [PATCH] hw/display/qxl: validate primary surface stride against width
-
-The existing validation in qxl_create_guest_primary() checks that
-abs(stride) * height fits in vgamem_size and that stride is 4-byte
-aligned, but never checks that abs(stride) is large enough to hold one
-row of pixels for the declared width and format.
-
-A malicious guest can create a primary surface with a stride much
-smaller than width * bytes_per_pixel (e.g. stride=4 for a 64-wide 32bpp
-surface). The spice server rejects this via red_validate_surface(), but
-the return is void and QEMU unconditionally proceeds to set up the local
-rendering state. On the next display refresh, VNC or SDL reads width *
-byptes_pp per scanline from a region backed by only stride bytes per
-row, causing a host-side out-of-bounds read.
-
-Add three checks before creating the surface:
- - reject unknown surface formats
- - reject zero width or height
- - reject surfaces where abs(stride) < width * bytes_per_pixel
-
-Fixes: CVE-2026-16271
-Fixes: 3761abb16784 ("hw/display/qxl: fix signed to unsigned comparison")
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3637
-Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
-Link: https://lore.kernel.org/qemu-devel/20260720114513.2500370-1-marcandre.lureau@redhat.com
-(picked from qemu-devel)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/display/qxl.c | 29 +++++++++++++++++++++++++++++
- 1 file changed, 29 insertions(+)
-
-diff --git a/hw/display/qxl.c b/hw/display/qxl.c
-index b7d871b9ee..41673c369b 100644
---- a/hw/display/qxl.c
-+++ b/hw/display/qxl.c
-@@ -1496,6 +1496,7 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
- QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
- uint32_t requested_height = le32_to_cpu(sc->height);
- int requested_stride = le32_to_cpu(sc->stride);
-+ uint32_t bytes_pp;
-
- if (requested_stride == INT32_MIN ||
- abs(requested_stride) * (uint64_t)requested_height
-@@ -1532,6 +1533,34 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
- return;
- }
-
-+ switch (surface.format) {
-+ case SPICE_SURFACE_FMT_16_555:
-+ case SPICE_SURFACE_FMT_16_565:
-+ bytes_pp = 2;
-+ break;
-+ case SPICE_SURFACE_FMT_32_xRGB:
-+ case SPICE_SURFACE_FMT_32_ARGB:
-+ bytes_pp = 4;
-+ break;
-+ default:
-+ qxl_set_guest_bug(qxl, "%s: unhandled format %d",
-+ __func__, surface.format);
-+ return;
-+ }
-+
-+ if (surface.width == 0 || surface.height == 0) {
-+ qxl_set_guest_bug(qxl, "%s: zero dimension %ux%u",
-+ __func__, surface.width, surface.height);
-+ return;
-+ }
-+
-+ if ((uint64_t)surface.width * bytes_pp > abs(surface.stride)) {
-+ qxl_set_guest_bug(qxl, "%s: stride too small for width:"
-+ " stride %d width %u bpp %u",
-+ __func__, surface.stride, surface.width, bytes_pp);
-+ return;
-+ }
-+
- surface.mouse_mode = true;
- surface.group_id = MEMSLOT_GROUP_GUEST;
- if (loadvm) {
diff --git a/debian/patches/extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch b/debian/patches/extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
similarity index 100%
rename from debian/patches/extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
rename to debian/patches/extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
diff --git a/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch b/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
deleted file mode 100644
index 9c7c7f6d32..0000000000
--- a/debian/patches/extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
+++ /dev/null
@@ -1,164 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Warisjeet Singh <sinxx198@gmail.com>
-Date: Mon, 24 Aug 2026 12:47:26 -0400
-Subject: [PATCH] hw/display/vga: fix text-mode OOB write after a graphics
- surface switch
-
-vga_draw_text() decides whether the console surface needs a resize from
-its geometry cache, but none of the cache terms observe the graphics
-renderer having replaced the console surface in between:
-
-- last_width/last_height are shared with vga_draw_graphic(), which
- stores them in pixels while the text path stores characters;
-- last_depth stays 0 for legacy (non-VBE) graphics modes, because
- vga_get_bpp() only reports a depth when VBE is enabled, so the
- "s->last_depth" term that normally forces a resize after a graphics
- frame does not fire.
-
-So a graphics frame that shrinks the console surface (e.g. 80x25
-pixels) followed by a text frame with matching character geometry
-(80x25 chars) skips the resize, and the glyph loop then paints
-width*cw x height*cheight pixels into the smaller surface, out of
-bounds, with guest-controlled (DAC palette) values, on every display
-refresh.
-
-Separate the geometry cache per renderer: text paths (vga_draw_text,
-vga_update_text, and the text handling in vga_invalidate_display /
-vga_common_reset) now only manipulate last_text_{width,height}, in
-characters; last_{width,height} become graphics-only, in pixels.
-Additionally, make the text path compare the pixel size it is about
-to paint against the console surface's actual dimensions. The
-surface check is the load-bearing term: caches in either unit cannot
-see the other renderer swapping the surface, the surface can.
-
-Fixes: CVE-2026-77913
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4215
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Warisjeet Singh (sin99xx) <sinxx198@gmail.com>
-Message-ID: <vga-v3-20260824.sinxx198@gmail.com>
-(cherry picked from commit 418396be8013386a81f8d8d89ac0effcf03a64b6)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/display/vga.c | 37 ++++++++++++++++++++++---------------
- hw/display/vga_int.h | 3 ++-
- 2 files changed, 24 insertions(+), 16 deletions(-)
-
-diff --git a/hw/display/vga.c b/hw/display/vga.c
-index da0c331486..cb0e28b79b 100644
---- a/hw/display/vga.c
-+++ b/hw/display/vga.c
-@@ -1241,7 +1241,10 @@ static void vga_draw_text(VGACommonState *s, int full_update)
- return;
- }
-
-- if (width != s->last_width || height != s->last_height ||
-+ if (surface == NULL ||
-+ surface_width(surface) != width * cw ||
-+ surface_height(surface) != height * cheight ||
-+ width != s->last_text_width || height != s->last_text_height ||
- cw != s->last_cw || cheight != s->last_ch || s->last_depth) {
- s->last_scr_width = width * cw;
- s->last_scr_height = height * cheight;
-@@ -1249,8 +1252,8 @@ static void vga_draw_text(VGACommonState *s, int full_update)
- surface = qemu_console_surface(s->con);
- qemu_console_text_resize(s->con, width, height);
- s->last_depth = 0;
-- s->last_width = width;
-- s->last_height = height;
-+ s->last_text_width = width;
-+ s->last_text_height = height;
- s->last_ch = cheight;
- s->last_cw = cw;
- full_update = 1;
-@@ -1845,6 +1848,8 @@ static void vga_invalidate_display(void *opaque)
-
- s->last_width = -1;
- s->last_height = -1;
-+ s->last_text_width = -1;
-+ s->last_text_height = -1;
- }
-
- void vga_common_reset(VGACommonState *s)
-@@ -1887,6 +1892,8 @@ void vga_common_reset(VGACommonState *s)
- s->last_ch = 0;
- s->last_width = 0;
- s->last_height = 0;
-+ s->last_text_width = 0;
-+ s->last_text_height = 0;
- s->last_scr_width = 0;
- s->last_scr_height = 0;
- s->cursor_start = 0;
-@@ -1938,8 +1945,8 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- s->graphic_mode = graphic_mode;
- full_update = 1;
- }
-- if (s->last_width == -1) {
-- s->last_width = 0;
-+ if (s->last_text_width == -1) {
-+ s->last_text_width = 0;
- full_update = 1;
- }
-
-@@ -1978,15 +1985,15 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- break;
- }
-
-- if (width != s->last_width || height != s->last_height ||
-+ if (width != s->last_text_width || height != s->last_text_height ||
- cw != s->last_cw || cheight != s->last_ch) {
- s->last_scr_width = width * cw;
- s->last_scr_height = height * cheight;
- qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height);
- qemu_console_text_resize(s->con, width, height);
- s->last_depth = 0;
-- s->last_width = width;
-- s->last_height = height;
-+ s->last_text_width = width;
-+ s->last_text_height = height;
- s->last_ch = cheight;
- s->last_cw = cw;
- full_update = 1;
-@@ -2071,22 +2078,22 @@ static void vga_update_text(void *opaque, uint32_t *chardata)
- }
-
- /* Display a message */
-- s->last_width = 60;
-- s->last_height = height = 3;
-+ s->last_text_width = 60;
-+ s->last_text_height = height = 3;
- qemu_console_text_set_cursor(s->con, -1, -1);
-- qemu_console_text_resize(s->con, s->last_width, height);
-+ qemu_console_text_resize(s->con, s->last_text_width, height);
-
-- for (dst = chardata, i = 0; i < s->last_width * height; i ++)
-+ for (dst = chardata, i = 0; i < s->last_text_width * height; i ++)
- *dst++ = ' ';
-
- size = strlen(msg_buffer);
-- width = (s->last_width - size) / 2;
-- dst = chardata + s->last_width + width;
-+ width = (s->last_text_width - size) / 2;
-+ dst = chardata + s->last_text_width + width;
- for (i = 0; i < size; i ++)
- *dst++ = ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE,
- QEMU_COLOR_BLACK, 1);
-
-- qemu_console_text_update(s->con, 0, 0, s->last_width, height);
-+ qemu_console_text_update(s->con, 0, 0, s->last_text_width, height);
- }
-
- static uint64_t vga_mem_read(void *opaque, hwaddr addr,
-diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
-index 5664317ecd..ca69ae9815 100644
---- a/hw/display/vga_int.h
-+++ b/hw/display/vga_int.h
-@@ -122,7 +122,8 @@ typedef struct VGACommonState {
- uint32_t plane_updated;
- uint32_t last_line_offset;
- uint8_t last_cw, last_ch;
-- uint32_t last_width, last_height; /* in chars or pixels */
-+ uint32_t last_width, last_height; /* in pixels (graphics renderer) */
-+ uint32_t last_text_width, last_text_height; /* in chars (text renderer) */
- uint32_t last_scr_width, last_scr_height; /* in pixels */
- uint32_t last_depth; /* in bits */
- bool last_byteswap;
diff --git a/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch b/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
deleted file mode 100644
index ffab5481da..0000000000
--- a/debian/patches/extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:22:41 +0200
-Subject: [PATCH] scsi-disk: fix out-of-bound read in WRITE SAME
-
-A guest with an attached scsi-hd can force QEMU's SCSI disk emulation
-to read roughly 60 KiB past the end of a heap buffer, copying that out
-of bounds host memory into the guest's own disk image.
-
-WRITE SAME computes the request transfer length at dev->blocksize
-when the request is prepared and sets cmd->xfer from dev->blocksize.
-scsi_disk_emulate_command() then uses cmd->xfer as the size of the
-request buffer.
-
-However, MODE SELECT can race with the WRITE SAME command and guest raise
-the logical block size to any value whose low bits fit 0xfe00, up to 65024.
-In the presence of this race, scsi_disk_emulate_write_same() will read
-from memory as many bytes as indicated by the *new* dev->blocksize,
-and write it to disk.
-
-The read length in WRITE SAME must be bounded by the buffer that was
-actually allocated, not by the mutable s->qdev.blocksize, so clamp the
-length used against inbuf to r->buflen. Re-validating req->cmd.xfer
-against the current block size would not work because the race is
-intrinsic in the SCSI protocol.
-
-I am not sure if this is exploitable with virtio-scsi and other SG-capable
-HBAs, because it should process the WRITE SAME input immediately,
-without letting the MODE SELECT command race with it.
-
-Fixes: 356c4c441ec ("scsi-disk: allow MODE SELECT block descriptor to set the block size", 2022-07-13)
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4365
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit d30254aec93141d6b89262986a62764b2ae07177)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/scsi/scsi-disk.c | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
-index 1b0cce128c..5bb7a974d6 100644
---- a/hw/scsi/scsi-disk.c
-+++ b/hw/scsi/scsi-disk.c
-@@ -1911,6 +1911,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- SCSIRequest *req = &r->req;
- SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
- uint32_t nb_sectors = scsi_data_cdb_xfer(r->req.cmd.buf);
-+ uint32_t buflen = MIN(s->qdev.blocksize, r->buflen);
- WriteSameCBData *data;
- uint8_t *buf;
- int i, l;
-@@ -1930,7 +1931,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- return;
- }
-
-- if ((req->cmd.buf[1] & 0x1) || buffer_is_zero(inbuf, s->qdev.blocksize)) {
-+ if ((req->cmd.buf[1] & 0x1) || buffer_is_zero(inbuf, buflen)) {
- int flags = (req->cmd.buf[1] & 0x8) ? BDRV_REQ_MAY_UNMAP : 0;
-
- /* The request is used as the AIO opaque value, so add a ref. */
-@@ -1956,7 +1957,7 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf)
- qemu_iovec_init_external(&data->qiov, &data->iov, 1);
-
- for (i = 0; i < data->iov.iov_len; i += l) {
-- l = MIN(s->qdev.blocksize, data->iov.iov_len - i);
-+ l = MIN(buflen, data->iov.iov_len - i);
- memcpy(&buf[i], inbuf, l);
- }
-
diff --git a/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch b/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
deleted file mode 100644
index 28b60a97d2..0000000000
--- a/debian/patches/extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:53:31 +0200
-Subject: [PATCH] scsi: hide MODE SELECT block size change behind a quirk
-
-This is a dangerous operation in that the block size is not
-protected by a lock, but it can be written concurrently if
-you have a multi-queue virtio-scsi HBA. Put it behind a quirk
-that is only enabled by the Q800 machine, since the MODE
-SELECT feature was added for A/UX.
-
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit 0f410adf6b0dead1f09938054da639954bda3bc1)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/m68k/q800.c | 2 ++
- hw/scsi/scsi-disk.c | 12 ++++++++++--
- include/hw/scsi/scsi.h | 1 +
- 3 files changed, 13 insertions(+), 2 deletions(-)
-
-diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
-index ab64250c47..1ad3f93b29 100644
---- a/hw/m68k/q800.c
-+++ b/hw/m68k/q800.c
-@@ -710,12 +710,14 @@ static void q800_init(Object *obj)
-
- static GlobalProperty hw_compat_q800[] = {
- { "scsi-hd", "quirk_mode_page_vendor_specific_apple", "on" },
-+ { "scsi-hd", "quirk_mode_page_set_block_size", "on" },
- { "scsi-hd", "vendor", " SEAGATE" },
- { "scsi-hd", "product", " ST225N" },
- { "scsi-hd", "ver", "1.0 " },
- { "scsi-cd", "quirk_mode_page_apple_vendor", "on" },
- { "scsi-cd", "quirk_mode_sense_rom_use_dbd", "on" },
- { "scsi-cd", "quirk_mode_page_vendor_specific_apple", "on" },
-+ { "scsi-cd", "quirk_mode_page_set_block_size", "on" },
- { "scsi-cd", "quirk_mode_page_truncated", "on" },
- { "scsi-cd", "vendor", "MATSHITA" },
- { "scsi-cd", "product", "CD-ROM CR-8005" },
-diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
-index 5bb7a974d6..a42f7d8e77 100644
---- a/hw/scsi/scsi-disk.c
-+++ b/hw/scsi/scsi-disk.c
-@@ -1673,8 +1673,12 @@ static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf)
- goto invalid_param;
- }
-
-- /* Allow changing the block size */
-- if (bd_len) {
-+ /*
-+ * Allow changing the block size only if the quirk is enabled for it.
-+ * Writing s->qdev.blocksize is not thread safe!
-+ */
-+ if (bd_len && (s->quirks &
-+ (1 << SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE))) {
- bs = p[5] << 16 | p[6] << 8 | p[7];
-
- /*
-@@ -3247,6 +3251,8 @@ static const Property scsi_hd_properties[] = {
- DEFINE_PROP_BIT("quirk_mode_page_vendor_specific_apple", SCSIDiskState,
- quirks, SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE,
- 0),
-+ DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState,
-+ quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0),
- DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf),
- };
-
-@@ -3352,6 +3358,8 @@ static const Property scsi_cd_properties[] = {
- 0),
- DEFINE_PROP_BIT("quirk_mode_page_truncated", SCSIDiskState, quirks,
- SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED, 0),
-+ DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState,
-+ quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0),
- };
-
- static void scsi_cd_class_initfn(ObjectClass *klass, const void *data)
-diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
-index c60c6e8810..3eab339b0d 100644
---- a/include/hw/scsi/scsi.h
-+++ b/include/hw/scsi/scsi.h
-@@ -262,5 +262,6 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error **errp);
- #define SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD 1
- #define SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE 2
- #define SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED 3
-+#define SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE 4
-
- #endif
diff --git a/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch b/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
deleted file mode 100644
index c0b17c6339..0000000000
--- a/debian/patches/extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
+++ /dev/null
@@ -1,75 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 20:02:56 +0200
-Subject: [PATCH] vapic: confine the VAPIC region to 0xc0000..0xe0000
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The VAPIC region is mapped as writable RAM, at very high priority,
-above existing memory. If the guest is allowed to map it everywhere,
-it can overlap PCI BARs or even SMRAM. Ensure that the whole
-region first in the 128K of low memory that are reserved to
-option ROMs.
-
-Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4206
-Reported-by: Artem Dinaburg <https://gitlab.com/artem35>
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit d61c8a6fb7388486353aa267ba0d75b098f16662)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/i386/vapic.c | 16 +++++++++++++++-
- 1 file changed, 15 insertions(+), 1 deletion(-)
-
-diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
-index 8dd9188d96..9adce17262 100644
---- a/hw/i386/vapic.c
-+++ b/hw/i386/vapic.c
-@@ -34,6 +34,10 @@
- #define ROM_BLOCK_SIZE 512
- #define ROM_BLOCK_MASK (~(ROM_BLOCK_SIZE - 1))
-
-+/* Option ROM window on PC/Q35 machines; the vapic ROM must live in here. */
-+#define OPTION_ROM_START 0xc0000
-+#define OPTION_ROM_END 0xe0000
-+
- typedef enum VAPICMode {
- VAPIC_INACTIVE = 0,
- VAPIC_ACTIVE = 1,
-@@ -592,6 +596,14 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- size_t rom_size;
- uint8_t *ram;
-
-+ /*
-+ * The VAPIC region should be mapped in place, refuse mapping it
-+ * outside of the option ROM window.
-+ */
-+ if (rom_paddr < OPTION_ROM_START || rom_paddr >= OPTION_ROM_END) {
-+ return -1;
-+ }
-+
- if (s->rom_mapped_writable) {
- memory_region_del_subregion(mr, &s->rom);
- object_unparent(OBJECT(&s->rom));
-@@ -606,9 +618,10 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- }
- ram = memory_region_get_ram_ptr(section.mr);
- rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
-- if (rom_size == 0) {
-+ if (rom_size == 0 || rom_size > OPTION_ROM_END - rom_paddr) {
- return -1;
- }
-+
- s->rom_size = rom_size;
-
- /* We need to round to avoid creating subpages
-@@ -616,6 +629,7 @@ static int vapic_map_rom_writable(VAPICROMState *s)
- rom_size += rom_paddr & ~TARGET_PAGE_MASK;
- rom_paddr &= TARGET_PAGE_MASK;
- rom_size = TARGET_PAGE_ALIGN(rom_size);
-+ assert(rom_paddr >= OPTION_ROM_START && rom_paddr + rom_size <= OPTION_ROM_END);
-
- memory_region_init_alias(&s->rom, OBJECT(s), "kvmvapic-rom", section.mr,
- rom_paddr, rom_size);
diff --git a/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch b/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
deleted file mode 100644
index c232e80930..0000000000
--- a/debian/patches/extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Wed, 26 Aug 2026 19:47:32 +0200
-Subject: [PATCH] i386/vapic: unref MemoryRegion if vapic_map_rom_writable
- fails
-
-memory_region_find returns the memory region with an elevated
-reference count. Drop the reference count also if the memory
-region cannot be mapped writable.
-
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry picked from commit cfa6e2c52ca8f756461fe41f4ce40e61a82fd914)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- hw/i386/vapic.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
-index 9adce17262..5c3911cf9c 100644
---- a/hw/i386/vapic.c
-+++ b/hw/i386/vapic.c
-@@ -614,11 +614,13 @@ static int vapic_map_rom_writable(VAPICROMState *s)
-
- /* read ROM size from RAM region */
- if (rom_paddr + 2 >= memory_region_size(section.mr)) {
-+ memory_region_unref(section.mr);
- return -1;
- }
- ram = memory_region_get_ram_ptr(section.mr);
- rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
- if (rom_size == 0 || rom_size > OPTION_ROM_END - rom_paddr) {
-+ memory_region_unref(section.mr);
- return -1;
- }
-
diff --git a/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch b/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
deleted file mode 100644
index 24834b364c..0000000000
--- a/debian/patches/extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: "Denis V. Lunev" <den@openvz.org>
-Date: Mon, 31 Aug 2026 12:01:46 +0200
-Subject: [PATCH] io/channel-socket: do not treat a zero length write as an
- error
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-qio_channel_socket_writev() checks "ret <= 0" after sendmsg(). A zero
-length iovec is written successfully and returns 0, so the success
-falls into the errno switch, which acts on whatever the last failing
-syscall left in errno. A stale EAGAIN turns it into
-QIO_CHANNEL_ERR_BLOCK with errp untouched, and a caller which treats
-every negative return as fatal then passes a NULL Error to
-error_get_pretty(). The websocket handshake does exactly that, so an
-unauthenticated client crashes QEMU during the greeting.
-
-Returning 0 is safe for callers which loop until everything is
-written. qio_channel_writev_full_all() has no zero progress guard, but
-iov_copy() yields no entries for a zero length write, so that loop is
-never entered. A connected stream socket returns 0 only when there is
-nothing to send.
-
-The WIN32 implementation in the same file uses "ret < 0".
-
-Fixes: CVE-2026-84788
-Fixes: 559607ea173a ("io: add QIOChannelSocket class")
-Cc: qemu-stable@nongnu.org
-Cc: Daniel P. Berrangé <berrange@redhat.com>
-Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
-Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
-Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-Signed-off-by: Denis V. Lunev <den@openvz.org>
-Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-(cherry picked from commit a3de21bfa5d0c33110942d407ff5c7903965d3ad)
-Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
----
- io/channel-socket.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/io/channel-socket.c b/io/channel-socket.c
-index 12773b832c..7920cee639 100644
---- a/io/channel-socket.c
-+++ b/io/channel-socket.c
-@@ -667,7 +667,7 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
-
- retry:
- ret = sendmsg(sioc->fd, &msg, sflags);
-- if (ret <= 0) {
-+ if (ret < 0) {
- switch (errno) {
- case EAGAIN:
- return QIO_CHANNEL_ERR_BLOCK;
diff --git a/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch b/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
index c0e337a613..de48b8fe25 100644
--- a/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
+++ b/debian/patches/pve/0011-PVE-virtio-balloon-improve-query-balloon.patch
@@ -59,10 +59,10 @@ index 686304bafa..474afba207 100644
qapi_free_BalloonInfo(info);
}
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
-index 4c5f486ba2..58fa33fb4a 100644
+index 07d519cf6d..55c775bfe2 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
-@@ -793,8 +793,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+@@ -797,8 +797,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
diff --git a/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch b/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
index f04bc2896a..4bc6855b2e 100644
--- a/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
+++ b/debian/patches/pve/0015-PVE-add-savevm-async-for-background-state-snapshots.patch
@@ -883,10 +883,10 @@ index b1eaf7b054..0794a3a7a3 100644
# @query-migrate:
#
diff --git a/qapi/misc.json b/qapi/misc.json
-index 22b7afed9f..786aeb4d3c 100644
+index c71a5fe657..48359a8992 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
-@@ -455,6 +455,31 @@
+@@ -463,6 +463,31 @@
##
{ 'command': 'query-fdsets', 'returns': ['FdsetInfo'] }
diff --git a/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch b/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
index 93f0c8d78e..c88df54d03 100644
--- a/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
+++ b/debian/patches/pve/0017-PVE-block-add-the-zeroinit-block-driver-filter.patch
@@ -247,10 +247,10 @@ index 0000000000..036edb17f5
+
+block_init(bdrv_zeroinit_init);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index c2f6139dea..c3204f5739 100644
+index 28d9c1e98e..07d16c4a04 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3375,7 +3375,7 @@
+@@ -3377,7 +3377,7 @@
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
@@ -259,7 +259,7 @@ index c2f6139dea..c3204f5739 100644
##
# @BlockdevOptionsFile:
-@@ -4909,7 +4909,8 @@
+@@ -4911,7 +4911,8 @@
'if': 'CONFIG_BLKIO' },
'vmdk': 'BlockdevOptionsGenericCOWFormat',
'vpc': 'BlockdevOptionsGenericFormat',
diff --git a/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch b/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
index c52036cfcc..19a9952b75 100644
--- a/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+++ b/debian/patches/pve/0020-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
@@ -119,10 +119,10 @@ index e5b942b6e4..adf9557428 100644
};
return raw_co_create(&options, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index c3204f5739..338675b98a 100644
+index 07d16c4a04..a12a1a2747 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -5128,6 +5128,10 @@
+@@ -5130,6 +5130,10 @@
# @extent-size-hint: Extent size hint to add to the image file; 0 for
# not adding an extent size hint (default: 1 MB, since 5.1)
#
@@ -133,7 +133,7 @@ index c3204f5739..338675b98a 100644
# Since: 2.12
##
{ 'struct': 'BlockdevCreateOptionsFile',
-@@ -5135,7 +5139,8 @@
+@@ -5137,7 +5141,8 @@
'size': 'size',
'*preallocation': 'PreallocMode',
'*nocow': 'bool',
diff --git a/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch b/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
index 98e5c0eee7..e23026c00b 100644
--- a/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
+++ b/debian/patches/pve/0025-PVE-Backup-add-backup-dump-block-driver.patch
@@ -312,7 +312,7 @@ index 147c08155f..41c82fc1ab 100644
BDRV_TRACKED_READ,
BDRV_TRACKED_WRITE,
diff --git a/job.c b/job.c
-index e747908472..5120a01265 100644
+index d7220aaf30..40dd820fba 100644
--- a/job.c
+++ b/job.c
@@ -337,7 +337,8 @@ static bool job_started_locked(Job *job)
diff --git a/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch b/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
index 8f1b20151c..2f1c31a750 100644
--- a/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
+++ b/debian/patches/pve/0026-PVE-Add-sequential-job-transaction-support.patch
@@ -34,7 +34,7 @@ index 0e40e8b457..f4fff5fa0d 100644
* Release a reference that was previously acquired with job_txn_add_job or
* job_txn_new. If it's the last reference to the object, it will be freed.
diff --git a/job.c b/job.c
-index 5120a01265..353a0216cd 100644
+index 40dd820fba..6de4c7cfdb 100644
--- a/job.c
+++ b/job.c
@@ -94,6 +94,8 @@ struct JobTxn {
@@ -72,7 +72,7 @@ index 5120a01265..353a0216cd 100644
/* Called with job_mutex held. */
static void job_txn_ref_locked(JobTxn *txn)
{
-@@ -1048,6 +1069,12 @@ static void job_completed_txn_success_locked(Job *job)
+@@ -1055,6 +1076,12 @@ static void job_completed_txn_success_locked(Job *job)
*/
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
if (!job_is_completed_locked(other_job)) {
@@ -85,7 +85,7 @@ index 5120a01265..353a0216cd 100644
return;
}
assert(other_job->ret == 0);
-@@ -1259,6 +1286,13 @@ int job_finish_sync_locked(Job *job,
+@@ -1266,6 +1293,13 @@ int job_finish_sync_locked(Job *job,
return -EBUSY;
}
diff --git a/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch b/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
index 67bb0c2f10..e5d76c54c0 100644
--- a/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
+++ b/debian/patches/pve/0027-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
@@ -1685,7 +1685,7 @@ index 0000000000..177fb851b4
+ return ret;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 338675b98a..2a0cc0fd2a 100644
+index a12a1a2747..e66c455f6e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -952,6 +952,248 @@
diff --git a/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch b/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
index 1af35e10b7..0dbc77f807 100644
--- a/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+++ b/debian/patches/pve/0029-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
@@ -361,10 +361,10 @@ index 91de400570..b1cbaa100e 100644
summary_info += {'libdaxctl support': libdaxctl}
summary_info += {'libcbor support': libcbor}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 2a0cc0fd2a..d3349661ba 100644
+index e66c455f6e..ca18144902 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3613,6 +3613,7 @@
+@@ -3615,6 +3615,7 @@
'parallels', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum',
'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
@@ -372,7 +372,7 @@ index 2a0cc0fd2a..d3349661ba 100644
'ssh', 'throttle', 'vdi', 'vhdx',
{ 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
-@@ -3699,6 +3700,33 @@
+@@ -3701,6 +3702,33 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -406,7 +406,7 @@ index 2a0cc0fd2a..d3349661ba 100644
##
# @BlockdevOptionsNVMe:
#
-@@ -5122,6 +5150,7 @@
+@@ -5124,6 +5152,7 @@
'nfs': 'BlockdevOptionsNfs',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
diff --git a/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
index 407c9a7e2e..f14c756faa 100644
--- a/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+++ b/debian/patches/pve/0031-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
@@ -200,7 +200,7 @@ index 177fb851b4..7575abab7c 100644
ret->pbs_masterkey = true;
ret->backup_max_workers = true;
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index d3349661ba..5965a3c1f3 100644
+index ca18144902..91efb9922e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1112,6 +1112,11 @@
diff --git a/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch b/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
index d331b20701..b5394a53b0 100644
--- a/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
+++ b/debian/patches/pve/0032-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
-index cba54e25cd..23eb5f40b3 100644
+index 1b8f39c12b..00e35179e6 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -539,7 +539,11 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
diff --git a/debian/patches/pve/0035-block-add-alloc-track-driver.patch b/debian/patches/pve/0035-block-add-alloc-track-driver.patch
index 1f566747f8..b54317dd3e 100644
--- a/debian/patches/pve/0035-block-add-alloc-track-driver.patch
+++ b/debian/patches/pve/0035-block-add-alloc-track-driver.patch
@@ -449,10 +449,10 @@ index d023753091..a777c8079c 100644
out:
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 5965a3c1f3..5a9ab23d5d 100644
+index 91efb9922e..80ffcc0547 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3606,7 +3606,8 @@
+@@ -3608,7 +3608,8 @@
# Since: 2.9
##
{ 'enum': 'BlockdevDriver',
@@ -462,7 +462,7 @@ index 5965a3c1f3..5a9ab23d5d 100644
'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg',
'file', 'snapshot-access', 'ftp', 'ftps',
{'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
-@@ -3706,6 +3707,21 @@
+@@ -3708,6 +3709,21 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -484,7 +484,7 @@ index 5965a3c1f3..5a9ab23d5d 100644
##
# @BlockdevOptionsPbs:
#
-@@ -5129,6 +5145,7 @@
+@@ -5131,6 +5147,7 @@
'*detect-zeroes': 'BlockdevDetectZeroesOptions' },
'discriminator': 'driver',
'data': {
diff --git a/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch b/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
index 0368018156..dbcf3bb65f 100644
--- a/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
+++ b/debian/patches/pve/0036-PVE-backup-add-fleecing-option.patch
@@ -429,7 +429,7 @@ index 7575abab7c..8b83465ebd 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 5a9ab23d5d..2dd422aa03 100644
+index 80ffcc0547..62d7fb4e7a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1054,6 +1054,10 @@
diff --git a/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch b/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
index f74e82017a..598ed3e441 100644
--- a/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
+++ b/debian/patches/pve/0042-PVE-backup-implement-backup-access-setup-and-teardow.patch
@@ -740,7 +740,7 @@ index 0000000000..9ebeef7c8f
+
+#endif /* PVE_BACKUP_H */
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 2dd422aa03..7ef1dd337c 100644
+index 62d7fb4e7a..5e50776664 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1128,6 +1128,9 @@
diff --git a/debian/patches/series b/debian/patches/series
index a13019354d..3140ed6230 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,14 +1,7 @@
extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
extra/0002-fdmon-io_uring-avoid-idle-event-loop-being-accounted.patch
extra/0003-block-vmdk-tolerate-known-seSparse-reserved1-bit.patch
-extra/0004-hw-display-qxl-validate-primary-surface-stride-again.patch
-extra/0005-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
-extra/0006-hw-display-vga-fix-text-mode-OOB-write-after-a-graph.patch
-extra/0007-scsi-disk-fix-out-of-bound-read-in-WRITE-SAME.patch
-extra/0008-scsi-hide-MODE-SELECT-block-size-change-behind-a-qui.patch
-extra/0009-vapic-confine-the-VAPIC-region-to-0xc0000.0xe0000.patch
-extra/0010-i386-vapic-unref-MemoryRegion-if-vapic_map_rom_writa.patch
-extra/0011-io-channel-socket-do-not-treat-a-zero-length-write-a.patch
+extra/0004-hw-scsi-lsi53c895a-gracefully-handle-re-entrant-DMA.patch
bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
diff --git a/qemu b/qemu
index c3d48b7d1e..4fc49f46dc 160000
--- a/qemu
+++ b/qemu
@@ -1 +1 @@
-Subproject commit c3d48b7d1e89604920e5b81b91140c2ad39a1943
+Subproject commit 4fc49f46dc95d4a27de2509e7fceb2931e91faeb
--
2.47.3
^ permalink raw reply related [relevance 6%]
* [PATCH pve-cluster 12/14 v2] pmxcfs-rs: add pmxcfs main daemon binary
@ 2026-02-13 9:33 1% ` Kefu Chai
0 siblings, 0 replies; 23+ results
From: Kefu Chai @ 2026-02-13 9:33 UTC (permalink / raw)
To: pve-devel
Main daemon binary integrating all crates with:
- FUSE filesystem with broadcast-first architecture
- 8 plugin system files (clusterlog, versions, nodeip, etc.)
- Configuration initialization using Config::shared()
- Status initialization with status::init_with_config_and_rrd()
- Enhanced corosync config import logic
- 5 FUSE integration tests (basic, cluster, integration, locks,
symlink)
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
---
src/pmxcfs-rs/Cargo.toml | 11 +-
src/pmxcfs-rs/pmxcfs/Cargo.toml | 84 +
src/pmxcfs-rs/pmxcfs/README.md | 174 ++
.../pmxcfs/src/cluster_config_service.rs | 317 ++++
src/pmxcfs-rs/pmxcfs/src/daemon.rs | 314 ++++
src/pmxcfs-rs/pmxcfs/src/file_lock.rs | 105 ++
src/pmxcfs-rs/pmxcfs/src/fuse/README.md | 199 ++
src/pmxcfs-rs/pmxcfs/src/fuse/filesystem.rs | 1644 +++++++++++++++++
src/pmxcfs-rs/pmxcfs/src/fuse/mod.rs | 4 +
src/pmxcfs-rs/pmxcfs/src/ipc/mod.rs | 16 +
src/pmxcfs-rs/pmxcfs/src/ipc/request.rs | 314 ++++
src/pmxcfs-rs/pmxcfs/src/ipc/service.rs | 684 +++++++
src/pmxcfs-rs/pmxcfs/src/lib.rs | 13 +
src/pmxcfs-rs/pmxcfs/src/logging.rs | 44 +
src/pmxcfs-rs/pmxcfs/src/main.rs | 711 +++++++
src/pmxcfs-rs/pmxcfs/src/memdb_callbacks.rs | 663 +++++++
src/pmxcfs-rs/pmxcfs/src/plugins/README.md | 203 ++
.../pmxcfs/src/plugins/clusterlog.rs | 293 +++
src/pmxcfs-rs/pmxcfs/src/plugins/debug.rs | 145 ++
src/pmxcfs-rs/pmxcfs/src/plugins/members.rs | 198 ++
src/pmxcfs-rs/pmxcfs/src/plugins/mod.rs | 30 +
src/pmxcfs-rs/pmxcfs/src/plugins/registry.rs | 305 +++
src/pmxcfs-rs/pmxcfs/src/plugins/rrd.rs | 97 +
src/pmxcfs-rs/pmxcfs/src/plugins/types.rs | 112 ++
src/pmxcfs-rs/pmxcfs/src/plugins/version.rs | 178 ++
src/pmxcfs-rs/pmxcfs/src/plugins/vmlist.rs | 120 ++
src/pmxcfs-rs/pmxcfs/src/quorum_service.rs | 207 +++
src/pmxcfs-rs/pmxcfs/src/restart_flag.rs | 60 +
src/pmxcfs-rs/pmxcfs/src/status_callbacks.rs | 352 ++++
src/pmxcfs-rs/pmxcfs/tests/common/mod.rs | 221 +++
src/pmxcfs-rs/pmxcfs/tests/fuse_basic_test.rs | 216 +++
.../pmxcfs/tests/fuse_cluster_test.rs | 220 +++
.../pmxcfs/tests/fuse_integration_test.rs | 414 +++++
src/pmxcfs-rs/pmxcfs/tests/fuse_locks_test.rs | 377 ++++
.../pmxcfs/tests/local_integration.rs | 277 +++
src/pmxcfs-rs/pmxcfs/tests/quorum_behavior.rs | 274 +++
.../pmxcfs/tests/single_node_functional.rs | 361 ++++
.../pmxcfs/tests/symlink_quorum_test.rs | 145 ++
38 files changed, 10100 insertions(+), 2 deletions(-)
create mode 100644 src/pmxcfs-rs/pmxcfs/Cargo.toml
create mode 100644 src/pmxcfs-rs/pmxcfs/README.md
create mode 100644 src/pmxcfs-rs/pmxcfs/src/cluster_config_service.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/daemon.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/file_lock.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/fuse/README.md
create mode 100644 src/pmxcfs-rs/pmxcfs/src/fuse/filesystem.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/fuse/mod.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/ipc/mod.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/ipc/request.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/ipc/service.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/lib.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/logging.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/main.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/memdb_callbacks.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/README.md
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/clusterlog.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/debug.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/members.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/mod.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/registry.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/rrd.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/types.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/version.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/plugins/vmlist.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/quorum_service.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/restart_flag.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/src/status_callbacks.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/common/mod.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/fuse_basic_test.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/fuse_cluster_test.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/fuse_integration_test.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/fuse_locks_test.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/local_integration.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/quorum_behavior.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/single_node_functional.rs
create mode 100644 src/pmxcfs-rs/pmxcfs/tests/symlink_quorum_test.rs
diff --git a/src/pmxcfs-rs/Cargo.toml b/src/pmxcfs-rs/Cargo.toml
index 31bade5f4..a5b67b699 100644
--- a/src/pmxcfs-rs/Cargo.toml
+++ b/src/pmxcfs-rs/Cargo.toml
@@ -11,6 +11,7 @@ members = [
"pmxcfs-services", # Service framework for automatic retry and lifecycle management
"pmxcfs-ipc", # libqb-compatible IPC server
"pmxcfs-dfsm", # Distributed Finite State Machine
+ "pmxcfs", # Main daemon binary
]
resolver = "2"
@@ -41,6 +42,7 @@ rust-corosync = "0.1"
# Core async runtime
tokio = { version = "1.35", features = ["full"] }
tokio-util = "0.7"
+futures = "0.3"
# Error handling
anyhow = "1.0"
@@ -48,29 +50,34 @@ thiserror = "1.0"
# Logging and tracing
tracing = "0.1"
-tracing-subscriber = "0.3"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
+tracing-journald = "0.3"
# Async trait support
async-trait = "0.1"
# Serialization
serde = { version = "1.0", features = ["derive"] }
+serde_json = "1.0"
bincode = "1.3"
bytemuck = { version = "1.14", features = ["derive"] }
# Network and cluster
bytes = "1.5"
sha2 = "0.10"
+base64 = "0.21"
# Concurrency primitives
parking_lot = "0.12"
# System integration
libc = "0.2"
-nix = { version = "0.29", features = ["socket", "poll"] }
+nix = { version = "0.27", features = ["fs", "process", "signal", "user", "socket"] }
+users = "0.11"
# Utilities
num_enum = "0.7"
+chrono = "0.4"
# Development dependencies
tempfile = "3.8"
diff --git a/src/pmxcfs-rs/pmxcfs/Cargo.toml b/src/pmxcfs-rs/pmxcfs/Cargo.toml
new file mode 100644
index 000000000..83fb8edad
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/Cargo.toml
@@ -0,0 +1,84 @@
+[package]
+name = "pmxcfs"
+description = "Proxmox Cluster File System - Rust implementation"
+homepage = "https://www.proxmox.com"
+
+version.workspace = true
+edition.workspace = true
+authors.workspace = true
+license.workspace = true
+repository.workspace = true
+
+[lints]
+workspace = true
+
+[lib]
+name = "pmxcfs_rs"
+path = "src/lib.rs"
+
+[[bin]]
+name = "pmxcfs"
+path = "src/main.rs"
+
+[dependencies]
+# Workspace members
+pmxcfs-config.workspace = true
+pmxcfs-api-types.workspace = true
+pmxcfs-memdb.workspace = true
+pmxcfs-dfsm.workspace = true
+pmxcfs-rrd.workspace = true
+pmxcfs-status.workspace = true
+pmxcfs-ipc.workspace = true
+pmxcfs-services.workspace = true
+
+# Core async runtime
+tokio.workspace = true
+tokio-util.workspace = true
+async-trait.workspace = true
+
+# Error handling
+anyhow.workspace = true
+thiserror.workspace = true
+
+# Logging and tracing
+tracing.workspace = true
+tracing-subscriber.workspace = true
+tracing-journald.workspace = true
+
+# Serialization
+serde.workspace = true
+serde_json.workspace = true
+bincode.workspace = true
+
+# Command-line parsing
+clap = { version = "4.4", features = ["derive"] }
+
+# FUSE filesystem (using local fork with rename support)
+proxmox-fuse = { path = "../../../../proxmox-fuse-rs" }
+
+# Network and cluster
+bytes.workspace = true
+sha2.workspace = true
+bytemuck.workspace = true
+base64.workspace = true
+
+# System integration
+libc.workspace = true
+nix.workspace = true
+users.workspace = true
+
+# Corosync/CPG bindings
+rust-corosync.workspace = true
+
+# Concurrency primitives
+parking_lot.workspace = true
+
+# Utilities
+chrono.workspace = true
+futures.workspace = true
+num_enum.workspace = true
+
+[dev-dependencies]
+tempfile.workspace = true
+pmxcfs-test-utils.workspace = true
+filetime = "0.2"
diff --git a/src/pmxcfs-rs/pmxcfs/README.md b/src/pmxcfs-rs/pmxcfs/README.md
new file mode 100644
index 000000000..eb457d3ba
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/README.md
@@ -0,0 +1,174 @@
+# pmxcfs Rust Implementation
+
+This directory contains the Rust reimplementation of pmxcfs (Proxmox Cluster File System).
+
+## Architecture Overview
+
+pmxcfs is a FUSE-based cluster filesystem that provides:
+- **Cluster-wide configuration storage** via replicated database (pmxcfs-memdb)
+- **State synchronization** across nodes via Corosync CPG (pmxcfs-dfsm)
+- **Virtual files** for runtime status (plugins: .version, .members, .vmlist, .rrd)
+- **Quorum enforcement** for write protection
+- **IPC server** for management tools (pvecm, pvenode)
+
+### Component Architecture
+
+### FUSE Plugin System
+
+Virtual files that appear in `/etc/pve` but don't exist in the database:
+
+| Plugin | File | Purpose | C Equivalent |
+|--------|------|---------|--------------|
+| `version.rs` | `.version` | Cluster version info | `cfs-plug-func.c` (cfs_plug_version_read) |
+| `members.rs` | `.members` | Cluster member list | `cfs-plug-func.c` (cfs_plug_members_read) |
+| `vmlist.rs` | `.vmlist` | VM/CT registry | `cfs-plug-func.c` (cfs_plug_vmlist_read) |
+| `rrd.rs` | `.rrd` | RRD dump (all metrics) | `cfs-plug-func.c` (cfs_plug_rrd_read) |
+| `clusterlog.rs` | `.clusterlog` | Cluster log viewer | `cfs-plug-func.c` (cfs_plug_clusterlog_read) |
+| `debug.rs` | `.debug` | Runtime debug control | `cfs-plug-func.c` (cfs_plug_debug) |
+
+#### Plugin Trait
+
+Plugins are registered in `plugins/registry.rs` and integrated into the FUSE filesystem.
+
+### C File Mapping
+
+| C Source | Rust Equivalent | Description |
+|----------|-----------------|-------------|
+| `pmxcfs.c` | `main.rs`, `daemon.rs` | Main entry point, daemon lifecycle |
+| `cfs-plug.c` | `fuse/filesystem.rs` | FUSE operations dispatcher |
+| `cfs-plug-memdb.c` | `fuse/filesystem.rs` | MemDb integration |
+| `cfs-plug-func.c` | `plugins/*.rs` | Virtual file plugins |
+| `server.c` | `ipc_service.rs` + pmxcfs-ipc | IPC server |
+| `loop.c` | pmxcfs-services | Service management |
+
+## Key Differences from C Implementation
+
+### Command-line Options
+
+Both implementations support the core options with identical behavior:
+- `-d` / `--debug` - Turn on debug messages
+- `-f` / `--foreground` - Do not daemonize server
+- `-l` / `--local` - Force local mode (ignore corosync.conf, force quorum)
+
+The Rust implementation adds these additional options for flexibility and testing:
+- `--test-dir <PATH>` - Test directory (sets all paths to subdirectories for isolated testing)
+- `--mount <PATH>` - Custom mount point (default: /etc/pve)
+- `--db <PATH>` - Custom database path (default: /var/lib/pve-cluster/config.db)
+- `--rundir <PATH>` - Custom runtime directory (default: /run/pmxcfs)
+- `--cluster-name <NAME>` - Cluster name / CPG group name for Corosync isolation (default: "pmxcfs")
+
+The Rust version is fully backward-compatible with C version command-line usage. The additional options are for advanced use cases (testing, multi-instance deployments) and don't affect standard deployment scenarios.
+
+### Logging
+
+**C Implementation**: Uses libqb's qb_log with traditional syslog format
+
+**Rust Implementation**: Uses tracing + tracing-subscriber with structured output integrated with systemd journald
+
+Log messages may appear in different format, but journald integration provides same searchability as syslog. Log levels work equivalently (debug, info, warn, error).
+
+## Plugin System Details
+
+### Virtual File Plugins
+
+Each plugin provides a read-only (or read-write) virtual file accessible through the FUSE mount:
+
+#### `.version` - Version Information
+
+**Path:** `/etc/pve/.version`
+**Format:** `{start_time}:{vmlist_version}:{path_versions...}`
+**Purpose:** Allows tools to detect configuration changes
+**Implementation:** `plugins/version.rs`
+
+Example output:
+Each number is a version counter that increments on changes.
+
+#### `.members` - Cluster Members
+
+**Path:** `/etc/pve/.members`
+**Format:** INI-style with member info
+**Purpose:** Lists active cluster nodes
+**Implementation:** `plugins/members.rs`
+
+Example output:
+Format: `{nodeid}\t{name}\t{online}\t{ip}`
+
+#### `.vmlist` - VM/CT Registry
+
+**Path:** `/etc/pve/.vmlist`
+**Format:** INI-style with VM info
+**Purpose:** Cluster-wide VM/CT registry
+**Implementation:** `plugins/vmlist.rs`
+
+Example output:
+Format: `{vmid}\t{node}\t{version}`
+
+#### `.rrd` - RRD Metrics Dump
+
+**Path:** `/etc/pve/.rrd`
+**Format:** Custom RRD dump format
+**Purpose:** Exports all RRD metrics for graph generation
+**Implementation:** `plugins/rrd.rs`
+
+Example output:
+
+#### `.clusterlog` - Cluster Log
+
+**Path:** `/etc/pve/.clusterlog`
+**Format:** Plain text log entries
+**Purpose:** Aggregated cluster-wide log
+**Implementation:** `plugins/clusterlog.rs`
+
+Example output:
+
+#### `.debug` - Debug Control
+
+**Path:** `/etc/pve/.debug`
+**Format:** Text commands
+**Purpose:** Runtime debug level control
+**Implementation:** `plugins/debug.rs`
+
+Write "1" to enable debug logging, "0" to disable.
+
+### Plugin Registration
+
+Plugins are registered in `plugins/registry.rs`:
+
+### FUSE Integration
+
+The FUSE filesystem checks plugins before MemDb:
+
+## Crate Structure
+
+The Rust implementation is organized as a workspace with 9 crates:
+
+| Crate | Purpose | Lines | C Equivalent |
+|-------|---------|-------|--------------|
+| **pmxcfs** | Main daemon binary | ~3500 | pmxcfs.c + plugins |
+| **pmxcfs-api-types** | Shared types | ~400 | cfs-utils.h |
+| **pmxcfs-config** | Configuration | ~75 | (inline in C) |
+| **pmxcfs-memdb** | In-memory database | ~2500 | memdb.c + database.c |
+| **pmxcfs-dfsm** | State machine | ~3000 | dfsm.c + dcdb.c |
+| **pmxcfs-rrd** | RRD persistence | ~800 | status.c (embedded) |
+| **pmxcfs-status** | Status tracking | ~900 | status.c |
+| **pmxcfs-ipc** | IPC server | ~2000 | server.c |
+| **pmxcfs-services** | Service framework | ~500 | loop.c |
+
+Total: **~14,000 lines** vs C implementation **~15,000 lines**
+
+## Migration Notes
+
+The Rust implementation can coexist with C nodes in the same cluster:
+- **Wire protocol**: 100% compatible (DFSM, IPC, RRD)
+- **Database format**: SQLite schema identical
+- **Corosync integration**: Uses same CPG groups
+- **File format**: All config files compatible
+
+## References
+
+### Documentation
+- [Implementation Plan](../../pmxcfs-rust-rewrite-plan.rst)
+- Individual crate README.md files for detailed docs
+
+### C Implementation
+- `src/pmxcfs/` - Original C implementation
diff --git a/src/pmxcfs-rs/pmxcfs/src/cluster_config_service.rs b/src/pmxcfs-rs/pmxcfs/src/cluster_config_service.rs
new file mode 100644
index 000000000..309db2dca
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/cluster_config_service.rs
@@ -0,0 +1,317 @@
+//! Cluster Configuration Service
+//!
+//! This service monitors Corosync cluster configuration changes via the CMAP API.
+//! It tracks nodelist changes and configuration version updates, matching the C
+//! implementation's service_confdb functionality.
+
+use async_trait::async_trait;
+use pmxcfs_services::{Service, ServiceError};
+use rust_corosync::{self as corosync, CsError, cmap};
+use std::sync::Arc;
+use tracing::{debug, error, info, warn};
+
+use pmxcfs_status::Status;
+
+/// Cluster configuration service (matching C's service_confdb)
+///
+/// Monitors Corosync CMAP for:
+/// - Nodelist changes (`nodelist.node.*`)
+/// - Configuration version changes (`totem.config_version`)
+///
+/// Updates cluster info when configuration changes are detected.
+pub struct ClusterConfigService {
+ /// CMAP handle (None when not initialized)
+ cmap_handle: parking_lot::RwLock<Option<cmap::Handle>>,
+ /// Nodelist track handle
+ nodelist_track_handle: parking_lot::RwLock<Option<cmap::TrackHandle>>,
+ /// Config version track handle
+ version_track_handle: parking_lot::RwLock<Option<cmap::TrackHandle>>,
+ /// Status instance for cluster info updates
+ status: Arc<Status>,
+ /// Flag indicating configuration changes detected
+ changes_detected: parking_lot::RwLock<bool>,
+}
+
+impl ClusterConfigService {
+ /// Create a new cluster configuration service
+ pub fn new(status: Arc<Status>) -> Self {
+ Self {
+ cmap_handle: parking_lot::RwLock::new(None),
+ nodelist_track_handle: parking_lot::RwLock::new(None),
+ version_track_handle: parking_lot::RwLock::new(None),
+ status,
+ changes_detected: parking_lot::RwLock::new(false),
+ }
+ }
+
+ /// Read cluster configuration from CMAP
+ fn read_cluster_config(&self, handle: &cmap::Handle) -> Result<(), anyhow::Error> {
+ // Read config version
+ let config_version = match cmap::get(*handle, &"totem.config_version".to_string()) {
+ Ok(cmap::Data::UInt64(v)) => v,
+ Ok(cmap::Data::UInt32(v)) => v as u64,
+ Ok(cmap::Data::UInt16(v)) => v as u64,
+ Ok(cmap::Data::UInt8(v)) => v as u64,
+ Ok(_) => {
+ warn!("Unexpected data type for totem.config_version");
+ 0
+ }
+ Err(e) => {
+ warn!("Failed to read totem.config_version: {:?}", e);
+ 0
+ }
+ };
+
+ // Read cluster name
+ let cluster_name = match cmap::get(*handle, &"totem.cluster_name".to_string()) {
+ Ok(cmap::Data::String(s)) => s,
+ Ok(_) => {
+ error!("totem.cluster_name has unexpected type");
+ return Err(anyhow::anyhow!("Invalid cluster_name type"));
+ }
+ Err(e) => {
+ error!("Failed to read totem.cluster_name: {:?}", e);
+ return Err(anyhow::anyhow!("Failed to read cluster_name"));
+ }
+ };
+
+ info!(
+ "Cluster configuration: name='{}', version={}",
+ cluster_name, config_version
+ );
+
+ // Read cluster nodes
+ self.read_cluster_nodes(handle, &cluster_name, config_version)?;
+
+ Ok(())
+ }
+
+ /// Read cluster nodes from CMAP nodelist
+ fn read_cluster_nodes(
+ &self,
+ handle: &cmap::Handle,
+ cluster_name: &str,
+ config_version: u64,
+ ) -> Result<(), anyhow::Error> {
+ let mut nodes = Vec::new();
+
+ // Iterate through nodelist (nodelist.node.0, nodelist.node.1, etc.)
+ for node_idx in 0..256 {
+ let nodeid_key = format!("nodelist.node.{node_idx}.nodeid");
+ let name_key = format!("nodelist.node.{node_idx}.name");
+ let ring0_key = format!("nodelist.node.{node_idx}.ring0_addr");
+
+ // Try to read node ID - if it doesn't exist, we've reached the end
+ let nodeid = match cmap::get(*handle, &nodeid_key) {
+ Ok(cmap::Data::UInt32(id)) => id,
+ Ok(cmap::Data::UInt8(id)) => id as u32,
+ Ok(cmap::Data::UInt16(id)) => id as u32,
+ Err(CsError::CsErrNotExist) => break, // No more nodes
+ Err(e) => {
+ debug!("Error reading {}: {:?}", nodeid_key, e);
+ continue;
+ }
+ Ok(_) => {
+ warn!("Unexpected type for {}", nodeid_key);
+ continue;
+ }
+ };
+
+ let name = match cmap::get(*handle, &name_key) {
+ Ok(cmap::Data::String(s)) => s,
+ _ => {
+ debug!("No name for node {}", nodeid);
+ format!("node{nodeid}")
+ }
+ };
+
+ let ip = match cmap::get(*handle, &ring0_key) {
+ Ok(cmap::Data::String(s)) => s,
+ _ => String::new(),
+ };
+
+ debug!(
+ "Found cluster node: id={}, name={}, ip={}",
+ nodeid, name, ip
+ );
+ nodes.push((nodeid, name, ip));
+ }
+
+ info!("Found {} cluster nodes", nodes.len());
+
+ // Update cluster info in Status
+ self.status
+ .update_cluster_info(cluster_name.to_string(), config_version, nodes)?;
+
+ Ok(())
+ }
+}
+
+/// CMAP track callback (matches C's track_callback)
+///
+/// This function is called by Corosync whenever a tracked CMAP key changes.
+/// We use user_data to pass a pointer to the ClusterConfigService.
+fn track_callback(
+ _handle: &cmap::Handle,
+ _track_handle: &cmap::TrackHandle,
+ _event: cmap::TrackType,
+ key_name: &String, // Note: rust-corosync API uses &String not &str
+ _new_value: &cmap::Data,
+ _old_value: &cmap::Data,
+ user_data: u64,
+) {
+ debug!("CMAP track callback: key_name={}", key_name);
+
+ if user_data == 0 {
+ error!("BUG: CMAP track callback called with null user_data");
+ return;
+ }
+
+ // Safety: user_data contains a valid pointer to ClusterConfigService
+ // The pointer remains valid because ServiceManager holds the service
+ unsafe {
+ let service_ptr = user_data as *const ClusterConfigService;
+ let service = &*service_ptr;
+ *service.changes_detected.write() = true;
+ }
+}
+
+#[async_trait]
+impl Service for ClusterConfigService {
+ fn name(&self) -> &str {
+ "cluster-config"
+ }
+
+ async fn initialize(&mut self) -> pmxcfs_services::Result<std::os::unix::io::RawFd> {
+ info!("Initializing cluster configuration service");
+
+ // Initialize CMAP connection
+ let handle = cmap::initialize(cmap::Map::Icmap).map_err(|e| {
+ ServiceError::InitializationFailed(format!("cmap_initialize failed: {e:?}"))
+ })?;
+
+ // Store self pointer as user_data for callbacks
+ let self_ptr = self as *const Self as u64;
+
+ // Create callback struct
+ let callback = cmap::NotifyCallback {
+ notify_fn: Some(track_callback),
+ };
+
+ // Set up nodelist tracking (matches C's CMAP_TRACK_PREFIX | CMAP_TRACK_ADD | ...)
+ let nodelist_track = cmap::track_add(
+ handle,
+ &"nodelist.node.".to_string(),
+ cmap::TrackType::PREFIX
+ | cmap::TrackType::ADD
+ | cmap::TrackType::DELETE
+ | cmap::TrackType::MODIFY,
+ &callback,
+ self_ptr,
+ )
+ .map_err(|e| {
+ cmap::finalize(handle).ok();
+ ServiceError::InitializationFailed(format!("cmap_track_add (nodelist) failed: {e:?}"))
+ })?;
+
+ // Set up config version tracking
+ let version_track = cmap::track_add(
+ handle,
+ &"totem.config_version".to_string(),
+ cmap::TrackType::ADD | cmap::TrackType::DELETE | cmap::TrackType::MODIFY,
+ &callback,
+ self_ptr,
+ )
+ .map_err(|e| {
+ cmap::track_delete(handle, nodelist_track).ok();
+ cmap::finalize(handle).ok();
+ ServiceError::InitializationFailed(format!(
+ "cmap_track_add (config_version) failed: {e:?}"
+ ))
+ })?;
+
+ // Get file descriptor for event monitoring
+ let fd = cmap::fd_get(handle).map_err(|e| {
+ cmap::track_delete(handle, version_track).ok();
+ cmap::track_delete(handle, nodelist_track).ok();
+ cmap::finalize(handle).ok();
+ ServiceError::InitializationFailed(format!("cmap_fd_get failed: {e:?}"))
+ })?;
+
+ // Read initial configuration
+ if let Err(e) = self.read_cluster_config(&handle) {
+ warn!("Failed to read initial cluster configuration: {}", e);
+ // Don't fail initialization - we'll try again on next change
+ }
+
+ // Store handles
+ *self.cmap_handle.write() = Some(handle);
+ *self.nodelist_track_handle.write() = Some(nodelist_track);
+ *self.version_track_handle.write() = Some(version_track);
+
+ info!(
+ "Cluster configuration service initialized successfully with fd {}",
+ fd
+ );
+ Ok(fd)
+ }
+
+ async fn dispatch(&mut self) -> pmxcfs_services::Result<bool> {
+ let handle = *self.cmap_handle.read().as_ref().ok_or_else(|| {
+ ServiceError::DispatchFailed("CMAP handle not initialized".to_string())
+ })?;
+
+ // Dispatch CMAP events (matches C's cmap_dispatch with CS_DISPATCH_ALL)
+ match cmap::dispatch(handle, corosync::DispatchFlags::All) {
+ Ok(_) => {
+ // Check if changes were detected (matches C implementation)
+ if *self.changes_detected.read() {
+ *self.changes_detected.write() = false;
+
+ // Re-read cluster configuration
+ if let Err(e) = self.read_cluster_config(&handle) {
+ warn!("Failed to update cluster configuration: {}", e);
+ }
+ }
+ Ok(true)
+ }
+ Err(CsError::CsErrTryAgain) => {
+ // TRY_AGAIN is expected, continue normally
+ Ok(true)
+ }
+ Err(CsError::CsErrLibrary) | Err(CsError::CsErrBadHandle) => {
+ // Connection lost, need to reinitialize
+ warn!("CMAP connection lost, requesting reinitialization");
+ Ok(false)
+ }
+ Err(e) => {
+ error!("CMAP dispatch failed: {:?}", e);
+ Err(ServiceError::DispatchFailed(format!(
+ "cmap_dispatch failed: {e:?}"
+ )))
+ }
+ }
+ }
+
+ async fn finalize(&mut self) -> pmxcfs_services::Result<()> {
+ info!("Finalizing cluster configuration service");
+
+ if let Some(handle) = self.cmap_handle.write().take() {
+ // Remove track handles
+ if let Some(version_track) = self.version_track_handle.write().take() {
+ cmap::track_delete(handle, version_track).ok();
+ }
+ if let Some(nodelist_track) = self.nodelist_track_handle.write().take() {
+ cmap::track_delete(handle, nodelist_track).ok();
+ }
+
+ // Finalize CMAP connection
+ if let Err(e) = cmap::finalize(handle) {
+ warn!("Error finalizing CMAP: {:?}", e);
+ }
+ }
+
+ info!("Cluster configuration service finalized");
+ Ok(())
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/daemon.rs b/src/pmxcfs-rs/pmxcfs/src/daemon.rs
new file mode 100644
index 000000000..2327bfd23
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/daemon.rs
@@ -0,0 +1,314 @@
+//! Daemon builder with integrated PID file management
+//!
+//! This module provides a builder-based API for daemonization that combines
+//! process forking, parent-child signaling, and PID file management into a
+//! cohesive, easy-to-use abstraction.
+//!
+//! Inspired by the daemonize crate but tailored for pmxcfs needs with async support.
+
+use anyhow::{Context, Result};
+use nix::unistd::{ForkResult, fork, pipe};
+use pmxcfs_api_types::PmxcfsError;
+use std::fs::{self, File};
+use std::os::unix::fs::PermissionsExt;
+use std::os::unix::io::{AsRawFd, RawFd};
+use std::path::PathBuf;
+
+/// RAII guard for PID file - automatically removes file on drop
+pub struct PidFileGuard {
+ path: PathBuf,
+}
+
+impl Drop for PidFileGuard {
+ fn drop(&mut self) {
+ if let Err(e) = fs::remove_file(&self.path) {
+ tracing::warn!(
+ "Failed to remove PID file at {}: {}",
+ self.path.display(),
+ e
+ );
+ } else {
+ tracing::debug!("Removed PID file at {}", self.path.display());
+ }
+ }
+}
+
+/// Represents the daemon process after daemonization
+pub enum DaemonProcess {
+ /// Parent process - should exit after receiving this
+ Parent,
+ /// Child process - contains RAII guard for PID file cleanup
+ Child(PidFileGuard),
+}
+
+/// Builder for daemon configuration with integrated PID file management
+///
+/// Provides a fluent API for configuring daemonization behavior including
+/// PID file location, group ownership, and parent-child signaling.
+pub struct Daemon {
+ pid_file: Option<PathBuf>,
+ group: Option<u32>,
+}
+
+impl Daemon {
+ /// Create a new daemon builder with default settings
+ pub fn new() -> Self {
+ Self {
+ pid_file: None,
+ group: None,
+ }
+ }
+
+ /// Set the PID file path
+ ///
+ /// The PID file will be created with 0o644 permissions and owned by root:group.
+ pub fn pid_file<P: Into<PathBuf>>(mut self, path: P) -> Self {
+ self.pid_file = Some(path.into());
+ self
+ }
+
+ /// Set the group ID for PID file ownership
+ pub fn group(mut self, gid: u32) -> Self {
+ self.group = Some(gid);
+ self
+ }
+
+ /// Start the daemonization process (foreground mode)
+ ///
+ /// Returns a guard that manages PID file lifecycle.
+ /// The PID file is written immediately and cleaned up when the guard is dropped.
+ pub fn start_foreground(self) -> Result<PidFileGuard> {
+ let pid_file_path = self
+ .pid_file
+ .ok_or_else(|| PmxcfsError::System("PID file path must be specified".into()))?;
+
+ let gid = self.group.unwrap_or(0);
+
+ // Write PID file with current process ID
+ write_pid_file(&pid_file_path, std::process::id(), gid)?;
+
+ tracing::info!("Running in foreground mode with PID {}", std::process::id());
+
+ Ok(PidFileGuard {
+ path: pid_file_path,
+ })
+ }
+
+ /// Start the daemonization process (daemon mode)
+ ///
+ /// Forks the process and returns either:
+ /// - `DaemonProcess::Parent` - The parent should exit after cleanup
+ /// - `DaemonProcess::Child(guard)` - The child should continue with daemon operations
+ ///
+ /// This uses a pipe-based signaling mechanism where the parent waits for the
+ /// child to signal readiness before writing the PID file and exiting.
+ pub fn start_daemon(self) -> Result<DaemonProcess> {
+ let pid_file_path = self
+ .pid_file
+ .ok_or_else(|| PmxcfsError::System("PID file path must be specified".into()))?;
+
+ let gid = self.group.unwrap_or(0);
+
+ // Create pipe for parent-child signaling
+ let (read_fd, write_fd) = pipe().context("Failed to create pipe for daemonization")?;
+
+ match unsafe { fork() } {
+ Ok(ForkResult::Parent { child }) => {
+ // Parent: wait for child to signal readiness
+ unsafe { libc::close(write_fd) };
+
+ let mut buffer = [0u8; 1];
+ let bytes_read =
+ unsafe { libc::read(read_fd, buffer.as_mut_ptr() as *mut libc::c_void, 1) };
+ let errno = std::io::Error::last_os_error();
+ unsafe { libc::close(read_fd) };
+
+ if bytes_read == -1 {
+ return Err(
+ PmxcfsError::System(format!("Failed to read from child: {errno}")).into(),
+ );
+ } else if bytes_read != 1 || buffer[0] != b'1' {
+ return Err(
+ PmxcfsError::System("Child failed to send ready signal".into()).into(),
+ );
+ }
+
+ // Child is ready - write PID file with child's PID
+ let child_pid = child.as_raw() as u32;
+ write_pid_file(&pid_file_path, child_pid, gid)?;
+
+ tracing::info!("Child process {} signaled ready, parent exiting", child_pid);
+
+ Ok(DaemonProcess::Parent)
+ }
+ Ok(ForkResult::Child) => {
+ // Child: become daemon and return signal handle
+ unsafe { libc::close(read_fd) };
+
+ // Create new session
+ unsafe {
+ if libc::setsid() == -1 {
+ return Err(
+ PmxcfsError::System("Failed to create new session".into()).into()
+ );
+ }
+ }
+
+ // Change to root directory
+ std::env::set_current_dir("/")?;
+
+ // Redirect standard streams to /dev/null
+ let devnull = File::open("/dev/null")?;
+ unsafe {
+ libc::dup2(devnull.as_raw_fd(), 0);
+ libc::dup2(devnull.as_raw_fd(), 1);
+ libc::dup2(devnull.as_raw_fd(), 2);
+ }
+
+ // Return child variant - we don't use the write_fd in this simplified version
+ // Note: This method is not actually used - use start_daemon_with_signal instead
+ unsafe { libc::close(write_fd) };
+ Ok(DaemonProcess::Child(PidFileGuard {
+ path: pid_file_path,
+ }))
+ }
+ Err(e) => Err(PmxcfsError::System(format!("Failed to fork: {e}")).into()),
+ }
+ }
+
+ /// Start daemonization with deferred signaling
+ ///
+ /// Returns (DaemonProcess, Option<SignalHandle>) where SignalHandle
+ /// must be used to signal the parent when ready.
+ pub fn start_daemon_with_signal(self) -> Result<(DaemonProcess, Option<SignalHandle>)> {
+ let pid_file_path = self
+ .pid_file
+ .clone()
+ .ok_or_else(|| PmxcfsError::System("PID file path must be specified".into()))?;
+
+ let gid = self.group.unwrap_or(0);
+
+ // Create pipe for parent-child signaling
+ let (read_fd, write_fd) = pipe().context("Failed to create pipe for daemonization")?;
+
+ match unsafe { fork() } {
+ Ok(ForkResult::Parent { child }) => {
+ // Parent: wait for child to signal readiness
+ unsafe { libc::close(write_fd) };
+
+ let mut buffer = [0u8; 1];
+ let bytes_read =
+ unsafe { libc::read(read_fd, buffer.as_mut_ptr() as *mut libc::c_void, 1) };
+ let errno = std::io::Error::last_os_error();
+ unsafe { libc::close(read_fd) };
+
+ if bytes_read == -1 {
+ return Err(
+ PmxcfsError::System(format!("Failed to read from child: {errno}")).into(),
+ );
+ } else if bytes_read != 1 || buffer[0] != b'1' {
+ return Err(
+ PmxcfsError::System("Child failed to send ready signal".into()).into(),
+ );
+ }
+
+ // Child is ready - write PID file with child's PID
+ let child_pid = child.as_raw() as u32;
+ write_pid_file(&pid_file_path, child_pid, gid)?;
+
+ tracing::info!("Child process {} signaled ready, parent exiting", child_pid);
+
+ Ok((DaemonProcess::Parent, None))
+ }
+ Ok(ForkResult::Child) => {
+ // Child: become daemon and return signal handle
+ unsafe { libc::close(read_fd) };
+
+ // Create new session
+ unsafe {
+ if libc::setsid() == -1 {
+ return Err(
+ PmxcfsError::System("Failed to create new session".into()).into()
+ );
+ }
+ }
+
+ // Change to root directory
+ std::env::set_current_dir("/")?;
+
+ // Redirect standard streams to /dev/null
+ let devnull = File::open("/dev/null")?;
+ unsafe {
+ libc::dup2(devnull.as_raw_fd(), 0);
+ libc::dup2(devnull.as_raw_fd(), 1);
+ libc::dup2(devnull.as_raw_fd(), 2);
+ }
+
+ let signal_handle = SignalHandle { write_fd };
+ let guard = PidFileGuard {
+ path: pid_file_path,
+ };
+
+ Ok((DaemonProcess::Child(guard), Some(signal_handle)))
+ }
+ Err(e) => Err(PmxcfsError::System(format!("Failed to fork: {e}")).into()),
+ }
+ }
+}
+
+impl Default for Daemon {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+/// Handle for signaling parent process readiness
+///
+/// The child process must call `signal_ready()` to inform the parent
+/// that all initialization is complete and it's safe to write the PID file.
+pub struct SignalHandle {
+ write_fd: RawFd,
+}
+
+impl SignalHandle {
+ /// Signal parent that child is ready
+ ///
+ /// This must be called after all initialization is complete.
+ /// The parent will write the PID file and exit after receiving this signal.
+ pub fn signal_ready(self) -> Result<()> {
+ unsafe {
+ let result = libc::write(self.write_fd, b"1".as_ptr() as *const libc::c_void, 1);
+ libc::close(self.write_fd);
+
+ if result != 1 {
+ return Err(PmxcfsError::System("Failed to signal parent process".into()).into());
+ }
+ }
+ tracing::debug!("Signaled parent process - child ready");
+ Ok(())
+ }
+}
+
+/// Write PID file with specified process ID
+fn write_pid_file(path: &PathBuf, pid: u32, gid: u32) -> Result<()> {
+ let content = format!("{pid}\n");
+
+ fs::write(path, content)
+ .with_context(|| format!("Failed to write PID file to {}", path.display()))?;
+
+ // Set permissions (0o644 = rw-r--r--)
+ let metadata = fs::metadata(path)?;
+ let mut perms = metadata.permissions();
+ perms.set_mode(0o644);
+ fs::set_permissions(path, perms)?;
+
+ // Set ownership (root:gid)
+ let path_cstr = std::ffi::CString::new(path.to_string_lossy().as_ref()).unwrap();
+ unsafe {
+ libc::chown(path_cstr.as_ptr(), 0, gid as libc::gid_t);
+ }
+
+ tracing::info!("Created PID file at {} with PID {}", path.display(), pid);
+
+ Ok(())
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/file_lock.rs b/src/pmxcfs-rs/pmxcfs/src/file_lock.rs
new file mode 100644
index 000000000..2180e67b7
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/file_lock.rs
@@ -0,0 +1,105 @@
+//! File locking utilities
+//!
+//! This module provides file-based locking to ensure only one pmxcfs instance
+//! runs at a time. It uses the flock(2) system call with exclusive locks.
+
+use anyhow::{Context, Result};
+use pmxcfs_api_types::PmxcfsError;
+use std::fs::File;
+use std::os::unix::fs::OpenOptionsExt;
+use std::os::unix::io::AsRawFd;
+use std::path::PathBuf;
+use tracing::{info, warn};
+
+/// RAII wrapper for a file lock
+///
+/// The lock is automatically released when the FileLock is dropped.
+pub struct FileLock(File);
+
+impl FileLock {
+ const MAX_RETRIES: u32 = 10;
+ const RETRY_DELAY: std::time::Duration = std::time::Duration::from_secs(1);
+
+ /// Acquire an exclusive file lock with retries (async)
+ ///
+ /// This function attempts to acquire an exclusive, non-blocking lock on the
+ /// specified file. It will retry up to 10 times with 1-second delays between
+ /// attempts, matching the C implementation's behavior.
+ ///
+ /// The blocking operations (file I/O and sleep) are executed on a blocking
+ /// thread pool to avoid blocking the async runtime.
+ ///
+ /// # Arguments
+ ///
+ /// * `lockfile_path` - Path to the lock file
+ ///
+ /// # Returns
+ ///
+ /// Returns a `FileLock` which automatically releases the lock when dropped.
+ ///
+ /// # Errors
+ ///
+ /// Returns an error if:
+ /// - The lock file cannot be created
+ /// - The lock cannot be acquired after 10 retry attempts
+ pub async fn acquire(lockfile_path: PathBuf) -> Result<Self> {
+ // Open/create the lock file on blocking thread pool
+ let file = tokio::task::spawn_blocking({
+ let lockfile_path = lockfile_path.clone();
+ move || {
+ File::options()
+ .create(true)
+ .read(true)
+ .append(true)
+ .mode(0o600)
+ .open(&lockfile_path)
+ .with_context(|| {
+ format!("Unable to create lock file at {}", lockfile_path.display())
+ })
+ }
+ })
+ .await
+ .context("Failed to spawn blocking task for file creation")??;
+
+ // Try to acquire lock with retries (matching C implementation)
+ for attempt in 0..=Self::MAX_RETRIES {
+ if Self::try_lock(&file).await? {
+ info!(path = %lockfile_path.display(), "Acquired pmxcfs lock");
+ return Ok(FileLock(file));
+ }
+
+ if attempt == Self::MAX_RETRIES {
+ return Err(PmxcfsError::System("Unable to acquire pmxcfs lock".into()).into());
+ }
+
+ if attempt == 0 {
+ warn!("Unable to acquire pmxcfs lock - retrying");
+ }
+
+ tokio::time::sleep(Self::RETRY_DELAY).await;
+ }
+
+ unreachable!("Loop should have returned or errored")
+ }
+
+ /// Attempt to acquire the lock (non-blocking)
+ async fn try_lock(file: &File) -> Result<bool> {
+ let result = tokio::task::spawn_blocking({
+ let fd = file.as_raw_fd();
+ move || unsafe { libc::flock(fd, libc::LOCK_EX | libc::LOCK_NB) }
+ })
+ .await
+ .context("Failed to spawn blocking task for flock")?;
+
+ Ok(result == 0)
+ }
+}
+
+impl Drop for FileLock {
+ fn drop(&mut self) {
+ // Safety: We own the file descriptor
+ unsafe {
+ libc::flock(self.0.as_raw_fd(), libc::LOCK_UN);
+ }
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/fuse/README.md b/src/pmxcfs-rs/pmxcfs/src/fuse/README.md
new file mode 100644
index 000000000..832207964
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/fuse/README.md
@@ -0,0 +1,199 @@
+# PMXCFS FUSE Filesystem
+
+## Overview
+
+PMXCFS provides a FUSE-based cluster filesystem mounted at `/etc/pve`. This filesystem exposes cluster configuration, VM/container configurations, and dynamic status information.
+
+## Filesystem Structure
+
+```
+/etc/pve/
+├── local -> nodes/{nodename}/ # Symlink plugin
+├── qemu-server -> nodes/{nodename}/qemu-server/ # Symlink plugin
+├── lxc -> nodes/{nodename}/lxc/ # Symlink plugin
+├── openvz -> nodes/{nodename}/openvz/ # Symlink plugin (legacy)
+│
+├── .version # Plugin file
+├── .members # Plugin file
+├── .vmlist # Plugin file
+├── .rrd # Plugin file
+├── .clusterlog # Plugin file
+├── .debug # Plugin file
+│
+├── nodes/
+│ ├── {node1}/
+│ │ ├── qemu-server/ # VM configs
+│ │ │ └── {vmid}.conf
+│ │ ├── lxc/ # CT configs
+│ │ │ └── {ctid}.conf
+│ │ ├── openvz/ # Legacy (OpenVZ)
+│ │ └── priv/ # Node-specific private data
+│ └── {node2}/
+│ └── ...
+│
+├── corosync.conf # Cluster configuration
+├── corosync.conf.new # Staging for new config
+├── storage.cfg # Storage configuration
+├── user.cfg # User database
+├── domains.cfg # Authentication domains
+├── datacenter.cfg # Datacenter settings
+├── vzdump.cron # Backup schedule
+├── vzdump.conf # Backup configuration
+├── jobs.cfg # Job definitions
+│
+├── ha/ # High Availability
+│ ├── crm_commands
+│ ├── manager_status
+│ ├── resources.cfg
+│ ├── groups.cfg
+│ ├── rules.cfg
+│ └── fence.cfg
+│
+├── sdn/ # Software Defined Networking
+│ ├── vnets.cfg
+│ ├── zones.cfg
+│ ├── controllers.cfg
+│ ├── subnets.cfg
+│ └── ipams.cfg
+│
+├── firewall/
+│ └── cluster.fw # Cluster firewall rules
+│
+├── replication.cfg # Replication configuration
+├── ceph.conf # Ceph configuration
+│
+├── notifications.cfg # Notification settings
+│
+└── priv/ # Cluster-wide private data
+ ├── shadow.cfg # Password hashes
+ ├── tfa.cfg # Two-factor auth
+ ├── token.cfg # API tokens
+ ├── notifications.cfg # Private notification config
+ └── acme/
+ └── plugins.cfg # ACME plugin configs
+```
+
+## File Categories
+
+### Plugin Files (Dynamic Content)
+
+Files beginning with `.` are plugin files that generate content dynamically:
+- `.version` - Cluster version and status
+- `.members` - Cluster membership
+- `.vmlist` - VM/container list
+- `.rrd` - RRD metrics dump
+- `.clusterlog` - Cluster log entries
+- `.debug` - Debug mode toggle
+
+See `../plugins/README.md` for detailed format specifications.
+
+### Symlink Plugins
+
+Convenience symlinks to node-specific directories:
+- `local/` - Points to current node's directory
+- `qemu-server/` - Points to current node's VM configs
+- `lxc/` - Points to current node's container configs
+- `openvz/` - Points to current node's OpenVZ configs (legacy)
+
+### Configuration Files (40 tracked files)
+
+The following files are tracked for version changes and synchronized across the cluster:
+
+**Core Configuration**:
+- `corosync.conf` - Corosync cluster configuration
+- `corosync.conf.new` - Staged configuration before activation
+- `storage.cfg` - Storage pool definitions
+- `user.cfg` - User accounts and permissions
+- `domains.cfg` - Authentication realm configuration
+- `datacenter.cfg` - Datacenter-wide settings
+
+**Backup Configuration**:
+- `vzdump.cron` - Backup schedule
+- `vzdump.conf` - Backup job settings
+- `jobs.cfg` - Recurring job definitions
+
+**High Availability** (6 files):
+- `ha/crm_commands` - HA command queue
+- `ha/manager_status` - HA manager status
+- `ha/resources.cfg` - HA resource definitions
+- `ha/groups.cfg` - HA service groups
+- `ha/rules.cfg` - HA placement rules
+- `ha/fence.cfg` - Fencing configuration
+
+**Software Defined Networking** (5 files):
+- `sdn/vnets.cfg` - Virtual networks
+- `sdn/zones.cfg` - Network zones
+- `sdn/controllers.cfg` - SDN controllers
+- `sdn/subnets.cfg` - Subnet definitions
+- `sdn/ipams.cfg` - IP address management
+
+**Notification** (2 files):
+- `notifications.cfg` - Public notification settings
+- `priv/notifications.cfg` - Private notification credentials
+
+**Security** (5 files):
+- `priv/shadow.cfg` - Password hashes
+- `priv/tfa.cfg` - Two-factor authentication
+- `priv/token.cfg` - API tokens
+- `priv/acme/plugins.cfg` - ACME DNS plugins
+- `firewall/cluster.fw` - Cluster-wide firewall rules
+
+**Other**:
+- `replication.cfg` - Storage replication jobs
+- `ceph.conf` - Ceph cluster configuration
+
+### Node-Specific Directories
+
+Each node has a directory under `nodes/{nodename}/` containing:
+- `qemu-server/*.conf` - QEMU/KVM VM configurations
+- `lxc/*.conf` - LXC container configurations
+- `openvz/*.conf` - OpenVZ container configurations (legacy)
+- `priv/` - Node-specific private data (not replicated)
+
+## FUSE Operations
+
+### Supported Operations
+
+All standard FUSE operations are supported:
+
+**Metadata Operations**:
+- `getattr` - Get file/directory attributes
+- `readdir` - List directory contents
+- `statfs` - Get filesystem statistics
+
+**Read Operations**:
+- `read` - Read file contents
+- `readlink` - Read symlink target
+
+**Write Operations**:
+- `write` - Write file contents
+- `create` - Create new file
+- `unlink` - Delete file
+- `mkdir` - Create directory
+- `rmdir` - Delete directory
+- `rename` - Rename/move file
+- `truncate` - Truncate file to size
+- `utimens` - Update timestamps
+
+**Permission Operations**:
+- `chmod` - Change file mode
+- `chown` - Change file ownership
+
+### Permission Handling
+
+- **Regular paths**: Standard Unix permissions apply
+- **Private paths** (`priv/` directories): Restricted to root only
+- **Plugin files**: Read-only for most users, special handling for `.debug`
+
+### File Size Limits
+
+- Maximum file size: 1 MiB (1024 × 1024 bytes)
+- Maximum filesystem size: 128 MiB
+- Maximum inodes: 256,000
+
+## Implementation
+
+The FUSE filesystem is implemented in `filesystem.rs` and integrates with:
+- **MemDB**: Backend storage (SQLite + in-memory tree)
+- **Plugin System**: Dynamic file generation
+- **Cluster Sync**: Changes are propagated via DFSM protocol
diff --git a/src/pmxcfs-rs/pmxcfs/src/fuse/filesystem.rs b/src/pmxcfs-rs/pmxcfs/src/fuse/filesystem.rs
new file mode 100644
index 000000000..dc7beaeb5
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/fuse/filesystem.rs
@@ -0,0 +1,1644 @@
+use anyhow::{Error, bail};
+use futures::stream::TryStreamExt;
+use libc::{EACCES, EINVAL, EIO, EISDIR, ENOENT};
+use proxmox_fuse::requests::{self, FuseRequest};
+use proxmox_fuse::{EntryParam, Fuse, ReplyBufState, Request};
+use std::ffi::{OsStr, OsString};
+use std::io;
+use std::mem;
+use std::path::Path;
+use std::sync::Arc;
+use std::time::{SystemTime, UNIX_EPOCH};
+
+use crate::plugins::{Plugin, PluginRegistry};
+use pmxcfs_config::Config;
+use pmxcfs_dfsm::{Dfsm, DfsmBroadcast, FuseMessage};
+use pmxcfs_memdb::{MemDb, ROOT_INODE, TreeEntry};
+use pmxcfs_status::Status;
+
+const TTL: f64 = 1.0;
+
+/// FUSE filesystem context for pmxcfs
+pub struct PmxcfsFilesystem {
+ memdb: MemDb,
+ dfsm: Option<Arc<Dfsm<FuseMessage>>>,
+ plugins: Arc<PluginRegistry>,
+ status: Arc<Status>,
+ uid: u32,
+ gid: u32,
+}
+
+impl PmxcfsFilesystem {
+ const PLUGIN_INODE_OFFSET: u64 = 1000000;
+ const FUSE_GENERATION: u64 = 1;
+ const NLINK_FILE: u32 = 1;
+ const NLINK_DIR: u32 = 2;
+
+ pub fn new(
+ memdb: MemDb,
+ config: Arc<Config>,
+ dfsm: Option<Arc<Dfsm<FuseMessage>>>,
+ plugins: Arc<PluginRegistry>,
+ status: Arc<Status>,
+ ) -> Self {
+ Self {
+ memdb,
+ gid: config.www_data_gid(),
+ dfsm,
+ plugins,
+ status,
+ uid: 0, // root
+ }
+ }
+
+ /// Convert FUSE nodeid to internal inode
+ ///
+ /// FUSE protocol uses nodeid 1 for root, but internally we use ROOT_INODE (0).
+ /// Regular file inodes need to be offset by -1 to match internal numbering.
+ /// Plugin inodes are in a separate range (>= PLUGIN_INODE_OFFSET) and unchanged.
+ ///
+ /// Mapping:
+ /// - FUSE nodeid 1 → internal inode 0 (ROOT_INODE)
+ /// - FUSE nodeid N (where N > 1 and N < PLUGIN_INODE_OFFSET) → internal inode N-1
+ /// - Plugin inodes (>= PLUGIN_INODE_OFFSET) are unchanged
+ #[inline]
+ fn fuse_to_inode(&self, fuse_nodeid: u64) -> u64 {
+ if fuse_nodeid >= Self::PLUGIN_INODE_OFFSET {
+ // Plugin inodes are unchanged
+ fuse_nodeid
+ } else {
+ // Regular inodes: FUSE nodeid N → internal inode N-1
+ // This maps FUSE root (1) to internal ROOT_INODE (0)
+ fuse_nodeid - 1
+ }
+ }
+
+ /// Convert internal inode to FUSE nodeid
+ ///
+ /// Internally we use ROOT_INODE (0) for root, but FUSE protocol uses nodeid 1.
+ /// Regular file inodes need to be offset by +1 to match FUSE numbering.
+ /// Plugin inodes (>= PLUGIN_INODE_OFFSET) are unchanged.
+ ///
+ /// Mapping:
+ /// - Internal inode 0 (ROOT_INODE) → FUSE nodeid 1
+ /// - Internal inode N (where N > 0 and N < PLUGIN_INODE_OFFSET) → FUSE nodeid N+1
+ /// - Plugin inodes (>= PLUGIN_INODE_OFFSET) are unchanged
+ #[inline]
+ fn inode_to_fuse(&self, inode: u64) -> u64 {
+ if inode >= Self::PLUGIN_INODE_OFFSET {
+ // Plugin inodes are unchanged
+ inode
+ } else {
+ // Regular inodes: internal inode N → FUSE nodeid N+1
+ // This maps internal ROOT_INODE (0) to FUSE root (1)
+ inode + 1
+ }
+ }
+
+ /// Check if a path is private (should have restricted permissions)
+ /// Matches C version's path_is_private() logic:
+ /// - Paths starting with "priv" or "priv/" are private
+ /// - Paths matching "nodes/*/priv" or "nodes/*/priv/*" are private
+ fn is_private_path(&self, path: &str) -> bool {
+ // Strip leading slashes
+ let path = path.trim_start_matches('/');
+
+ // Check if path starts with "priv" or "priv/"
+ if path.starts_with("priv") && (path.len() == 4 || path.as_bytes()[4] == b'/') {
+ return true;
+ }
+
+ // Check for "nodes/*/priv" or "nodes/*/priv/*" pattern
+ if let Some(after_nodes) = path.strip_prefix("nodes/") {
+ // Find the next '/' to skip the node name
+ if let Some(slash_pos) = after_nodes.find('/') {
+ let after_nodename = &after_nodes[slash_pos..];
+
+ // Check if it starts with "/priv" and ends or continues with '/'
+ if after_nodename.starts_with("/priv") {
+ let priv_end = slash_pos + 5; // position after "/priv"
+ if after_nodes.len() == priv_end || after_nodes.as_bytes()[priv_end] == b'/' {
+ return true;
+ }
+ }
+ }
+ }
+
+ false
+ }
+
+ /// Get a TreeEntry by inode (helper for FUSE operations)
+ fn get_entry_by_inode(&self, inode: u64) -> Option<TreeEntry> {
+ self.memdb.get_entry_by_inode(inode)
+ }
+
+ /// Get a TreeEntry by path
+ fn get_entry_by_path(&self, path: &str) -> Option<TreeEntry> {
+ self.memdb.lookup_path(path)
+ }
+
+ /// Get the full path for an inode by traversing up the tree
+ fn get_path_for_inode(&self, inode: u64) -> String {
+ if inode == ROOT_INODE {
+ return "/".to_string();
+ }
+
+ let mut path_components = Vec::new();
+ let mut current_inode = inode;
+
+ // Traverse up the tree
+ while current_inode != ROOT_INODE {
+ if let Some(entry) = self.memdb.get_entry_by_inode(current_inode) {
+ path_components.push(entry.name.clone());
+ current_inode = entry.parent;
+ } else {
+ // Entry not found, return root
+ return "/".to_string();
+ }
+ }
+
+ // Reverse to get correct order (we built from leaf to root)
+ path_components.reverse();
+
+ if path_components.is_empty() {
+ "/".to_string()
+ } else {
+ format!("/{}", path_components.join("/"))
+ }
+ }
+
+ fn join_path(&self, parent_path: &str, name: &str) -> io::Result<String> {
+ let mut path = std::path::PathBuf::from(parent_path);
+ path.push(name);
+ path.to_str()
+ .ok_or_else(|| {
+ io::Error::new(
+ io::ErrorKind::InvalidInput,
+ "Path contains invalid UTF-8 characters",
+ )
+ })
+ .map(|s| s.to_string())
+ }
+
+ /// Convert a TreeEntry to libc::stat using current quorum state
+ /// Applies permission adjustments based on whether the path is private
+ ///
+ /// Matches C implementation (cfs-plug-memdb.c:95-116, pmxcfs.c:130-138):
+ /// 1. Start with quorum-dependent base permissions (0777/0555 dirs, 0666/0444 files)
+ /// 2. Apply AND masking: private=0777700, dirs/symlinks=0777755, files=0777750
+ fn entry_to_stat(&self, entry: &TreeEntry, path: &str) -> libc::stat {
+ // Use current quorum state
+ let quorate = self.status.is_quorate();
+ self.entry_to_stat_with_quorum(entry, path, quorate)
+ }
+
+ /// Convert a TreeEntry to libc::stat with explicit quorum state
+ /// Applies permission adjustments based on whether the path is private
+ ///
+ /// Matches C implementation (cfs-plug-memdb.c:95-116, pmxcfs.c:130-138):
+ /// 1. Start with quorum-dependent base permissions (0777/0555 dirs, 0666/0444 files)
+ /// 2. Apply AND masking: private=0777700, dirs/symlinks=0777755, files=0777750
+ fn entry_to_stat_with_quorum(&self, entry: &TreeEntry, path: &str, quorate: bool) -> libc::stat {
+ let mtime_secs = entry.mtime as i64;
+ let mut stat: libc::stat = unsafe { mem::zeroed() };
+
+ // Convert internal inode to FUSE nodeid for st_ino field
+ let fuse_nodeid = self.inode_to_fuse(entry.inode);
+
+ if entry.is_dir() {
+ stat.st_ino = fuse_nodeid;
+ // Quorum-dependent directory permissions (C: 0777 when quorate, 0555 when not)
+ stat.st_mode = libc::S_IFDIR | if quorate { 0o777 } else { 0o555 };
+ stat.st_nlink = Self::NLINK_DIR as u64;
+ stat.st_uid = self.uid;
+ stat.st_gid = self.gid;
+ stat.st_size = 4096;
+ stat.st_blksize = 4096;
+ stat.st_blocks = 8;
+ stat.st_atime = mtime_secs;
+ stat.st_atime_nsec = 0;
+ stat.st_mtime = mtime_secs;
+ stat.st_mtime_nsec = 0;
+ stat.st_ctime = mtime_secs;
+ stat.st_ctime_nsec = 0;
+ } else {
+ stat.st_ino = fuse_nodeid;
+ // Quorum-dependent file permissions (C: 0666 when quorate, 0444 when not)
+ stat.st_mode = libc::S_IFREG | if quorate { 0o666 } else { 0o444 };
+ stat.st_nlink = Self::NLINK_FILE as u64;
+ stat.st_uid = self.uid;
+ stat.st_gid = self.gid;
+ stat.st_size = entry.size as i64;
+ stat.st_blksize = 4096;
+ stat.st_blocks = ((entry.size as i64 + 4095) / 4096) * 8;
+ stat.st_atime = mtime_secs;
+ stat.st_atime_nsec = 0;
+ stat.st_mtime = mtime_secs;
+ stat.st_mtime_nsec = 0;
+ stat.st_ctime = mtime_secs;
+ stat.st_ctime_nsec = 0;
+ }
+
+ // Apply permission adjustments based on path privacy (matching C implementation)
+ // See pmxcfs.c cfs_fuse_getattr() lines 130-138
+ // Uses AND masking to restrict permissions while preserving file type bits
+ if self.is_private_path(path) {
+ // Private paths: mask to rwx------ (0o700)
+ // C: stbuf->st_mode &= 0777700
+ stat.st_mode &= 0o777700;
+ } else {
+ // Non-private paths: different masks for dirs vs files
+ if (stat.st_mode & libc::S_IFMT) == libc::S_IFDIR
+ || (stat.st_mode & libc::S_IFMT) == libc::S_IFLNK
+ {
+ // Directories and symlinks: mask to rwxr-xr-x (0o755)
+ // C: stbuf->st_mode &= 0777755
+ stat.st_mode &= 0o777755;
+ } else {
+ // Regular files: mask to rwxr-x--- (0o750)
+ // C: stbuf->st_mode &= 0777750
+ stat.st_mode &= 0o777750;
+ }
+ }
+
+ stat
+ }
+
+ /// Check if a plugin supports write operations
+ ///
+ /// Tests if the plugin has a custom write implementation by checking
+ /// if write() returns the default "Write not supported" error
+ fn plugin_supports_write(plugin: &Arc<dyn Plugin>) -> bool {
+ // Try writing empty data - if it returns the default error, no write support
+ match plugin.write(&[]) {
+ Err(e) => {
+ let msg = e.to_string();
+ !msg.contains("Write not supported")
+ }
+ Ok(_) => true, // Write succeeded, so it's supported
+ }
+ }
+
+ /// Get stat for a plugin file
+ fn plugin_to_stat(&self, inode: u64, plugin: &Arc<dyn Plugin>) -> libc::stat {
+ let now = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs() as i64;
+ let data = plugin.read().unwrap_or_default();
+
+ let mut stat: libc::stat = unsafe { mem::zeroed() };
+ stat.st_ino = inode;
+
+ // Set file type and mode based on plugin type
+ if plugin.is_symlink() {
+ // Quorum-aware permissions for symlinks (matching C's cfs-plug-link.c:68-72)
+ // - When quorate: 0o777 (writable by all)
+ // - When not quorate: 0o555 (read-only for all)
+ let mode = if self.status.is_quorate() {
+ 0o777
+ } else {
+ 0o555
+ };
+ stat.st_mode = libc::S_IFLNK | mode;
+ } else {
+ // Regular file plugin
+ let mut mode = plugin.mode();
+
+ // Strip write bits if plugin doesn't support writing
+ // Matches C implementation (cfs-plug-func.c:216-218)
+ if !Self::plugin_supports_write(plugin) {
+ mode &= !0o222; // Remove write bits (owner, group, other)
+ }
+
+ stat.st_mode = libc::S_IFREG | mode;
+ }
+
+ stat.st_nlink = Self::NLINK_FILE as u64;
+ stat.st_uid = self.uid;
+ stat.st_gid = self.gid;
+ stat.st_size = data.len() as i64;
+ stat.st_blksize = 4096;
+ stat.st_blocks = ((data.len() as i64 + 4095) / 4096) * 8;
+ stat.st_atime = now;
+ stat.st_atime_nsec = 0;
+ stat.st_mtime = now;
+ stat.st_mtime_nsec = 0;
+ stat.st_ctime = now;
+ stat.st_ctime_nsec = 0;
+
+ stat
+ }
+
+ /// Handle lookup operation
+ async fn handle_lookup(&self, parent_fuse: u64, name: &OsStr) -> io::Result<EntryParam> {
+ tracing::debug!(
+ "lookup(parent={parent_fuse}, name={})",
+ name.to_string_lossy()
+ );
+
+ // Convert FUSE nodeid to internal inode
+ let parent = self.fuse_to_inode(parent_fuse);
+
+ let name_str = name.to_string_lossy();
+
+ // Check if this is a plugin file in the root directory
+ if parent == ROOT_INODE {
+ let plugin_names = self.plugins.list();
+ if let Some(plugin_idx) = plugin_names.iter().position(|p| p == name_str.as_ref()) {
+ // Found a plugin file
+ if let Some(plugin) = self.plugins.get(&name_str) {
+ let plugin_inode = Self::PLUGIN_INODE_OFFSET + plugin_idx as u64;
+ let stat = self.plugin_to_stat(plugin_inode, &plugin);
+
+ return Ok(EntryParam {
+ inode: plugin_inode, // Plugin inodes already in FUSE space
+ generation: Self::FUSE_GENERATION,
+ attr: stat,
+ attr_timeout: TTL,
+ entry_timeout: TTL,
+ });
+ }
+ }
+ }
+
+ // Get parent entry
+ let parent_entry = if parent == ROOT_INODE {
+ // Root directory
+ self.get_entry_by_inode(ROOT_INODE)
+ .ok_or_else(|| io::Error::from_raw_os_error(ENOENT))?
+ } else {
+ self.get_entry_by_inode(parent)
+ .ok_or_else(|| io::Error::from_raw_os_error(ENOENT))?
+ };
+
+ // Construct the path
+ let parent_path = self.get_path_for_inode(parent_entry.inode);
+ let full_path = self.join_path(&parent_path, &name_str)?;
+
+ // Look up the entry
+ if let Ok(exists) = self.memdb.exists(&full_path)
+ && exists
+ {
+ // Get the entry to find its inode
+ if let Some(entry) = self.get_entry_by_path(&full_path) {
+ let stat = self.entry_to_stat(&entry, &full_path);
+ // Convert internal inode to FUSE nodeid
+ let fuse_nodeid = self.inode_to_fuse(entry.inode);
+ return Ok(EntryParam {
+ inode: fuse_nodeid,
+ generation: Self::FUSE_GENERATION,
+ attr: stat,
+ attr_timeout: TTL,
+ entry_timeout: TTL,
+ });
+ }
+ }
+
+ Err(io::Error::from_raw_os_error(ENOENT))
+ }
+
+ /// Handle getattr operation
+ fn handle_getattr(&self, ino_fuse: u64) -> io::Result<libc::stat> {
+ tracing::debug!("getattr(ino={})", ino_fuse);
+
+ // Check if this is a plugin file (inode >= PLUGIN_INODE_OFFSET)
+ if ino_fuse >= Self::PLUGIN_INODE_OFFSET {
+ let plugin_idx = (ino_fuse - Self::PLUGIN_INODE_OFFSET) as usize;
+ let plugin_names = self.plugins.list();
+ if plugin_idx < plugin_names.len() {
+ let plugin_name = &plugin_names[plugin_idx];
+ if let Some(plugin) = self.plugins.get(plugin_name) {
+ return Ok(self.plugin_to_stat(ino_fuse, &plugin));
+ }
+ }
+ }
+
+ // Convert FUSE nodeid to internal inode
+ let ino = self.fuse_to_inode(ino_fuse);
+
+ if let Some(entry) = self.get_entry_by_inode(ino) {
+ let path = self.get_path_for_inode(ino);
+ Ok(self.entry_to_stat(&entry, &path))
+ } else {
+ Err(io::Error::from_raw_os_error(ENOENT))
+ }
+ }
+
+ /// Handle readdir operation
+ fn handle_readdir(&self, request: &mut requests::Readdir) -> Result<(), Error> {
+ let ino_fuse = request.inode;
+ tracing::debug!("readdir(ino={}, offset={})", ino_fuse, request.offset);
+
+ // Convert FUSE nodeid to internal inode
+ let ino = self.fuse_to_inode(ino_fuse);
+ let offset = request.offset;
+
+ // Get the directory path
+ let path = self.get_path_for_inode(ino);
+
+ // Read directory entries from memdb
+ let entries = self
+ .memdb
+ .readdir(&path)
+ .map_err(|_| io::Error::from_raw_os_error(ENOENT))?;
+
+ // Build complete list of entries
+ let mut all_entries: Vec<(u64, libc::stat, String)> = Vec::new();
+
+ // Add . and .. entries
+ // C implementation (cfs-plug-memdb.c:172) always passes quorate=0 for readdir stats
+ // This ensures directory listings show non-quorate permissions (read-only view)
+ if let Some(dir_entry) = self.get_entry_by_inode(ino) {
+ let dir_stat = self.entry_to_stat_with_quorum(&dir_entry, &path, false);
+ all_entries.push((ino_fuse, dir_stat, ".".to_string()));
+ all_entries.push((ino_fuse, dir_stat, "..".to_string()));
+ }
+
+ // For root directory, add plugin files
+ if ino == ROOT_INODE {
+ let plugin_names = self.plugins.list();
+ for (idx, plugin_name) in plugin_names.iter().enumerate() {
+ let plugin_inode = Self::PLUGIN_INODE_OFFSET + idx as u64;
+ if let Some(plugin) = self.plugins.get(plugin_name) {
+ let stat = self.plugin_to_stat(plugin_inode, &plugin);
+ all_entries.push((plugin_inode, stat, plugin_name.clone()));
+ }
+ }
+ }
+
+ // Add actual entries from memdb
+ // C implementation (cfs-plug-memdb.c:172) always passes quorate=0 for readdir stats
+ for entry in &entries {
+ let entry_path = match self.join_path(&path, &entry.name) {
+ Ok(p) => p,
+ Err(e) => {
+ tracing::warn!("Skipping entry with invalid UTF-8 path: {}", e);
+ continue;
+ }
+ };
+ let stat = self.entry_to_stat_with_quorum(entry, &entry_path, false);
+ // Convert internal inode to FUSE nodeid for directory entry
+ let fuse_nodeid = self.inode_to_fuse(entry.inode);
+ all_entries.push((fuse_nodeid, stat, entry.name.clone()));
+ }
+
+ // Return entries starting from offset
+ let mut next = offset as isize;
+ for (_inode, stat, name) in all_entries.iter().skip(offset as usize) {
+ next += 1;
+ match request.add_entry(OsStr::new(name), stat, next)? {
+ ReplyBufState::Ok => (),
+ ReplyBufState::Full => return Ok(()),
+ }
+ }
+
+ Ok(())
+ }
+
+ /// Handle read operation
+ fn handle_read(&self, ino_fuse: u64, offset: u64, size: usize) -> io::Result<Vec<u8>> {
+ tracing::debug!("read(ino={}, offset={}, size={})", ino_fuse, offset, size);
+
+ // Check if this is a plugin file (inode >= PLUGIN_INODE_OFFSET)
+ if ino_fuse >= Self::PLUGIN_INODE_OFFSET {
+ let plugin_idx = (ino_fuse - Self::PLUGIN_INODE_OFFSET) as usize;
+ let plugin_names = self.plugins.list();
+ if plugin_idx < plugin_names.len() {
+ let plugin_name = &plugin_names[plugin_idx];
+ if let Some(plugin) = self.plugins.get(plugin_name) {
+ let data = plugin
+ .read()
+ .map_err(|_| io::Error::from_raw_os_error(EIO))?;
+
+ let offset = offset as usize;
+ if offset >= data.len() {
+ return Ok(Vec::new());
+ } else {
+ let end = std::cmp::min(offset + size, data.len());
+ return Ok(data[offset..end].to_vec());
+ }
+ }
+ }
+ }
+
+ // Convert FUSE nodeid to internal inode
+ let ino = self.fuse_to_inode(ino_fuse);
+
+ let path = self.get_path_for_inode(ino);
+
+ // Check if this is a directory
+ if ino == ROOT_INODE {
+ // Root directory itself - can't read
+ return Err(io::Error::from_raw_os_error(EISDIR));
+ }
+
+ // Read from memdb
+ self.memdb
+ .read(&path, offset, size)
+ .map_err(|_| io::Error::from_raw_os_error(ENOENT))
+ }
+
+ /// Handle write operation
+ async fn handle_write(&self, ino_fuse: u64, offset: u64, data: &[u8]) -> io::Result<usize> {
+ tracing::debug!(
+ "write(ino={}, offset={}, size={})",
+ ino_fuse,
+ offset,
+ data.len()
+ );
+
+ // Check if this is a plugin file (inode >= PLUGIN_INODE_OFFSET)
+ if ino_fuse >= Self::PLUGIN_INODE_OFFSET {
+ let plugin_idx = (ino_fuse - Self::PLUGIN_INODE_OFFSET) as usize;
+ let plugin_names = self.plugins.list();
+
+ if plugin_idx < plugin_names.len() {
+ let plugin_name = &plugin_names[plugin_idx];
+ if let Some(plugin) = self.plugins.get(plugin_name) {
+ // Validate offset (C only allows offset 0)
+ if offset != 0 {
+ tracing::warn!("Plugin write rejected: offset {} != 0", offset);
+ return Err(io::Error::from_raw_os_error(libc::EIO));
+ }
+
+ // Call plugin write
+ tracing::debug!("Writing {} bytes to plugin '{}'", data.len(), plugin_name);
+ plugin.write(data).map(|_| data.len()).map_err(|e| {
+ tracing::error!("Plugin write failed: {}", e);
+ io::Error::from_raw_os_error(libc::EIO)
+ })?;
+
+ return Ok(data.len());
+ }
+ }
+
+ // Plugin not found or invalid index
+ return Err(io::Error::from_raw_os_error(libc::ENOENT));
+ }
+
+ // Regular memdb file write
+ // Convert FUSE nodeid to internal inode
+ let ino = self.fuse_to_inode(ino_fuse);
+
+ let path = self.get_path_for_inode(ino);
+
+ // C-style broadcast-first: send message and wait for result
+ // C implementation (cfs-plug-memdb.c:262-265) sends just the write chunk
+ // with original offset, not the full file contents
+ if let Some(dfsm) = &self.dfsm {
+ // Send write message with just the data chunk and original offset
+ // The DFSM delivery will apply the write to all nodes
+ let result = dfsm
+ .send_message_sync(
+ FuseMessage::Write {
+ path: path.clone(),
+ offset,
+ data: data.to_vec(),
+ },
+ std::time::Duration::from_secs(10),
+ )
+ .await
+ .map_err(|e| {
+ tracing::error!("DFSM send_message_sync failed: {}", e);
+ io::Error::from_raw_os_error(EIO)
+ })?;
+
+ if result.result < 0 {
+ tracing::warn!("Write failed with errno: {}", -result.result);
+ return Err(io::Error::from_raw_os_error(-result.result as i32));
+ }
+
+ Ok(data.len())
+ } else {
+ // No cluster - write locally
+ let mtime = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs() as u32;
+
+ // FUSE write() should never truncate - truncation is handled separately
+ // via setattr (for explicit truncate) or open with O_TRUNC flag.
+ // Offset writes must preserve content beyond the write range (POSIX semantics).
+ self.memdb
+ .write(&path, offset, 0, mtime, data, false)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))
+ }
+ }
+
+ /// Handle mkdir operation
+ async fn handle_mkdir(&self, parent_fuse: u64, name: &OsStr, mode: u32) -> io::Result<EntryParam> {
+ tracing::debug!(
+ "mkdir(parent={}, name={})",
+ parent_fuse,
+ name.to_string_lossy()
+ );
+
+ // Convert FUSE nodeid to internal inode
+ let parent = self.fuse_to_inode(parent_fuse);
+
+ let parent_path = self.get_path_for_inode(parent);
+ let name_str = name.to_string_lossy();
+ let full_path = self.join_path(&parent_path, &name_str)?;
+
+ // C-style broadcast-first: send message and wait for result
+ if let Some(dfsm) = &self.dfsm {
+ let result = dfsm
+ .send_message_sync(
+ FuseMessage::Mkdir {
+ path: full_path.clone(),
+ },
+ std::time::Duration::from_secs(10),
+ )
+ .await
+ .map_err(|e| {
+ tracing::error!("DFSM send_message_sync failed: {}", e);
+ io::Error::from_raw_os_error(EIO)
+ })?;
+
+ if result.result < 0 {
+ tracing::warn!("Mkdir failed with errno: {}", -result.result);
+ return Err(io::Error::from_raw_os_error(-result.result as i32));
+ }
+ } else {
+ // No cluster - create locally
+ let mtime = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs() as u32;
+
+ self.memdb
+ .create(&full_path, mode | libc::S_IFDIR, 0, mtime)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+
+ // Look up the newly created entry (created via delivery callback)
+ let entry = self
+ .memdb
+ .lookup_path(&full_path)
+ .ok_or_else(|| io::Error::from_raw_os_error(EIO))?;
+
+ let stat = self.entry_to_stat(&entry, &full_path);
+ // Convert internal inode to FUSE nodeid
+ let fuse_nodeid = self.inode_to_fuse(entry.inode);
+ Ok(EntryParam {
+ inode: fuse_nodeid,
+ generation: Self::FUSE_GENERATION,
+ attr: stat,
+ attr_timeout: TTL,
+ entry_timeout: TTL,
+ })
+ }
+
+ /// Handle rmdir operation
+ async fn handle_rmdir(&self, parent_fuse: u64, name: &OsStr) -> io::Result<()> {
+ tracing::debug!(
+ "rmdir(parent={}, name={})",
+ parent_fuse,
+ name.to_string_lossy()
+ );
+
+ // Convert FUSE nodeid to internal inode
+ let parent = self.fuse_to_inode(parent_fuse);
+
+ let parent_path = self.get_path_for_inode(parent);
+ let name_str = name.to_string_lossy();
+ let full_path = self.join_path(&parent_path, &name_str)?;
+
+ // C-style broadcast-first: send message and wait for result
+ if let Some(dfsm) = &self.dfsm {
+ let result = dfsm
+ .send_message_sync(
+ FuseMessage::Delete {
+ path: full_path.clone(),
+ },
+ std::time::Duration::from_secs(10),
+ )
+ .await
+ .map_err(|e| {
+ tracing::error!("DFSM send_message_sync failed: {}", e);
+ io::Error::from_raw_os_error(EIO)
+ })?;
+
+ if result.result < 0 {
+ tracing::warn!("Rmdir failed with errno: {}", -result.result);
+ return Err(io::Error::from_raw_os_error(-result.result as i32));
+ }
+ } else {
+ // No cluster - delete locally
+ self.memdb
+ .delete(&full_path, 0, SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as u32)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+
+ Ok(())
+ }
+
+ /// Handle create operation
+ async fn handle_create(&self, parent_fuse: u64, name: &OsStr, mode: u32) -> io::Result<EntryParam> {
+ tracing::debug!(
+ "create(parent={}, name={})",
+ parent_fuse,
+ name.to_string_lossy()
+ );
+
+ // Convert FUSE nodeid to internal inode
+ let parent = self.fuse_to_inode(parent_fuse);
+
+ let parent_path = self.get_path_for_inode(parent);
+ let name_str = name.to_string_lossy();
+ let full_path = self.join_path(&parent_path, &name_str)?;
+
+ // C-style broadcast-first: send message and wait for result
+ if let Some(dfsm) = &self.dfsm {
+ // Direct await - clean and idiomatic async code
+ let result = dfsm
+ .send_message_sync(
+ FuseMessage::Create {
+ path: full_path.clone(),
+ },
+ std::time::Duration::from_secs(10),
+ )
+ .await
+ .map_err(|e| {
+ tracing::error!("DFSM send_message_sync failed: {}", e);
+ io::Error::from_raw_os_error(EIO)
+ })?;
+
+ // Check result from deliver callback
+ if result.result < 0 {
+ tracing::warn!("Create failed with errno: {}", -result.result);
+ return Err(io::Error::from_raw_os_error(-result.result as i32));
+ }
+ } else {
+ // No cluster - create locally
+ let mtime = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs() as u32;
+
+ self.memdb
+ .create(&full_path, mode | libc::S_IFREG, 0, mtime)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+
+ // Look up the newly created entry (created via delivery callback)
+ let entry = self
+ .memdb
+ .lookup_path(&full_path)
+ .ok_or_else(|| io::Error::from_raw_os_error(EIO))?;
+
+ let stat = self.entry_to_stat(&entry, &full_path);
+ // Convert internal inode to FUSE nodeid
+ let fuse_nodeid = self.inode_to_fuse(entry.inode);
+ Ok(EntryParam {
+ inode: fuse_nodeid,
+ generation: Self::FUSE_GENERATION,
+ attr: stat,
+ attr_timeout: TTL,
+ entry_timeout: TTL,
+ })
+ }
+
+ /// Handle unlink operation
+ async fn handle_unlink(&self, parent_fuse: u64, name: &OsStr) -> io::Result<()> {
+ tracing::debug!(
+ "unlink(parent={}, name={})",
+ parent_fuse,
+ name.to_string_lossy()
+ );
+
+ // Convert FUSE nodeid to internal inode
+ let parent = self.fuse_to_inode(parent_fuse);
+
+ let name_str = name.to_string_lossy();
+
+ // Don't allow unlinking plugin files (in root directory)
+ if parent == ROOT_INODE {
+ let plugin_names = self.plugins.list();
+ if plugin_names.iter().any(|p| p == name_str.as_ref()) {
+ return Err(io::Error::from_raw_os_error(EACCES));
+ }
+ }
+
+ let parent_path = self.get_path_for_inode(parent);
+ let full_path = self.join_path(&parent_path, &name_str)?;
+
+ // Check if trying to unlink a directory (should use rmdir instead)
+ if let Some(entry) = self.memdb.lookup_path(&full_path)
+ && entry.is_dir()
+ {
+ return Err(io::Error::from_raw_os_error(libc::EISDIR));
+ }
+
+ // C-style broadcast-first: send message and wait for result
+ if let Some(dfsm) = &self.dfsm {
+ let result = dfsm
+ .send_message_sync(
+ FuseMessage::Delete { path: full_path },
+ std::time::Duration::from_secs(10),
+ )
+ .await
+ .map_err(|e| {
+ tracing::error!("DFSM send_message_sync failed: {}", e);
+ io::Error::from_raw_os_error(EIO)
+ })?;
+
+ if result.result < 0 {
+ tracing::warn!("Unlink failed with errno: {}", -result.result);
+ return Err(io::Error::from_raw_os_error(-result.result as i32));
+ }
+ } else {
+ // No cluster - delete locally
+ self.memdb
+ .delete(&full_path, 0, SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as u32)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+
+ Ok(())
+ }
+
+ /// Handle rename operation
+ async fn handle_rename(
+ &self,
+ parent_fuse: u64,
+ name: &OsStr,
+ new_parent_fuse: u64,
+ new_name: &OsStr,
+ ) -> io::Result<()> {
+ tracing::debug!(
+ "rename(parent={}, name={}, new_parent={}, new_name={})",
+ parent_fuse,
+ name.to_string_lossy(),
+ new_parent_fuse,
+ new_name.to_string_lossy()
+ );
+
+ // Convert FUSE nodeids to internal inodes
+ let parent = self.fuse_to_inode(parent_fuse);
+ let new_parent = self.fuse_to_inode(new_parent_fuse);
+
+ let parent_path = self.get_path_for_inode(parent);
+ let name_str = name.to_string_lossy();
+ let old_path = self.join_path(&parent_path, &name_str)?;
+
+ let new_parent_path = self.get_path_for_inode(new_parent);
+ let new_name_str = new_name.to_string_lossy();
+ let new_path = self.join_path(&new_parent_path, &new_name_str)?;
+
+ // C-style broadcast-first: send message and wait for result
+ if let Some(dfsm) = &self.dfsm {
+ let result = dfsm
+ .send_message_sync(
+ FuseMessage::Rename {
+ from: old_path.clone(),
+ to: new_path.clone(),
+ },
+ std::time::Duration::from_secs(10),
+ )
+ .await
+ .map_err(|e| {
+ tracing::error!("DFSM send_message_sync failed: {}", e);
+ io::Error::from_raw_os_error(EIO)
+ })?;
+
+ if result.result < 0 {
+ tracing::warn!("Rename failed with errno: {}", -result.result);
+ return Err(io::Error::from_raw_os_error(-result.result as i32));
+ }
+ } else {
+ // No cluster - rename locally
+ self.memdb
+ .rename(&old_path, &new_path, 0, SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as u32)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+
+ Ok(())
+ }
+
+ /// Handle setattr operation
+ ///
+ /// Supports:
+ /// - Truncate (size parameter)
+ /// - Mtime updates (mtime parameter) - used for lock renewal/release
+ /// - Mode changes (mode parameter) - validation only, no actual changes
+ /// - Ownership changes (uid/gid parameters) - validation only, no actual changes
+ ///
+ /// C implementation (cfs-plug-memdb.c:393-436) ALWAYS sends DCDB_MESSAGE_CFS_MTIME
+ /// via DFSM when mtime is updated (line 420-422), in addition to unlock messages
+ ///
+ /// chmod/chown (pmxcfs.c:180-214): These operations don't actually change anything,
+ /// they just validate that the requested changes are allowed (returns -EPERM if not).
+ async fn handle_setattr(
+ &self,
+ ino_fuse: u64,
+ size: Option<u64>,
+ mtime: Option<u32>,
+ mode: Option<u32>,
+ uid: Option<u32>,
+ gid: Option<u32>,
+ ) -> io::Result<libc::stat> {
+ tracing::debug!(
+ "setattr(ino={}, size={:?}, mtime={:?})",
+ ino_fuse,
+ size,
+ mtime
+ );
+
+ // Convert FUSE nodeid to internal inode
+ let ino = self.fuse_to_inode(ino_fuse);
+ let path = self.get_path_for_inode(ino);
+
+ // Handle chmod operation (validation only - C: pmxcfs.c:180-197)
+ // chmod validates that requested mode is allowed but doesn't actually change anything
+ if let Some(new_mode) = mode {
+ let is_private = self.is_private_path(&path);
+ let mode_bits = new_mode & 0o777; // Extract permission bits only
+
+ // C implementation allows only specific modes:
+ // - 0600 (rw-------) for private paths
+ // - 0640 (rw-r-----) for non-private paths
+ let allowed = if is_private {
+ mode_bits == 0o600
+ } else {
+ mode_bits == 0o640
+ };
+
+ if !allowed {
+ tracing::debug!(
+ "chmod rejected: mode={:o}, path={}, is_private={}",
+ mode_bits,
+ path,
+ is_private
+ );
+ return Err(io::Error::from_raw_os_error(libc::EPERM));
+ }
+
+ tracing::debug!(
+ "chmod validated: mode={:o}, path={}, is_private={}",
+ mode_bits,
+ path,
+ is_private
+ );
+ }
+
+ // Handle chown operation (validation only - C: pmxcfs.c:198-214)
+ // chown validates that requested ownership is allowed but doesn't actually change anything
+ if uid.is_some() || gid.is_some() {
+ // C implementation allows only:
+ // - uid: 0 (root) or -1 (no change)
+ // - gid: www-data GID or -1 (no change)
+ let uid_allowed = match uid {
+ None => true,
+ Some(u) => u == 0 || u == u32::MAX, // -1 as u32 = u32::MAX
+ };
+
+ let gid_allowed = match gid {
+ None => true,
+ Some(g) => g == self.gid || g == u32::MAX, // -1 as u32 = u32::MAX
+ };
+
+ if !uid_allowed || !gid_allowed {
+ tracing::debug!(
+ "chown rejected: uid={:?}, gid={:?}, allowed_gid={}, path={}",
+ uid,
+ gid,
+ self.gid,
+ path
+ );
+ return Err(io::Error::from_raw_os_error(libc::EPERM));
+ }
+
+ tracing::debug!(
+ "chown validated: uid={:?}, gid={:?}, allowed_gid={}, path={}",
+ uid,
+ gid,
+ self.gid,
+ path
+ );
+ }
+
+ // Handle truncate operation
+ if let Some(new_size) = size {
+ let current_mtime = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs() as u32;
+
+ // Truncate: clear the file then write empty data to set size
+ self.memdb
+ .write(&path, 0, 0, current_mtime, &vec![0u8; new_size as usize], true)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+
+ // Handle mtime update (lock renewal/release)
+ // C implementation (cfs-plug-memdb.c:415-422) ALWAYS sends DCDB_MESSAGE_CFS_MTIME
+ // via DFSM when mtime is updated, in addition to unlock messages
+ if let Some(new_mtime) = mtime {
+ // Check if this is a lock directory
+ if pmxcfs_memdb::is_lock_path(&path) {
+ if let Some(entry) = self.memdb.get_entry_by_inode(ino)
+ && entry.is_dir()
+ {
+ // mtime=0 on lock directory = unlock request (C: cfs-plug-memdb.c:411-418)
+ if new_mtime == 0 {
+ tracing::debug!("Unlock request for lock directory: {}", path);
+ let csum = entry.compute_checksum();
+
+ // If DFSM is available and synced, only send the message - don't delete locally
+ // The leader will check if expired and send Unlock message if needed
+ // If DFSM is not available or not synced, delete locally if expired (C: cfs-plug-memdb.c:425-427)
+ if self.dfsm.as_ref().is_none_or(|d| !d.is_synced()) {
+ if self.memdb.lock_expired(&path, &csum) {
+ tracing::info!(
+ "DFSM not synced - deleting expired lock locally: {}",
+ path
+ );
+ self.memdb
+ .delete(&path, 0, SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as u32)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+ } else {
+ // Broadcast unlock request to cluster (C: cfs-plug-memdb.c:417)
+ tracing::debug!("DFSM synced - sending unlock request to cluster");
+ self.dfsm.broadcast(FuseMessage::UnlockRequest { path: path.clone() });
+ }
+ }
+ }
+ }
+
+ // C implementation ALWAYS sends MTIME message (lines 420-422), regardless of
+ // whether it's an unlock request or not. This broadcasts the mtime update to
+ // all cluster nodes for synchronization.
+ if let Some(dfsm) = &self.dfsm {
+ tracing::debug!("Sending MTIME message via DFSM: path={}, mtime={}", path, new_mtime);
+ let result = dfsm
+ .send_message_sync(
+ FuseMessage::Mtime {
+ path: path.clone(),
+ mtime: new_mtime,
+ },
+ std::time::Duration::from_secs(10),
+ )
+ .await
+ .map_err(|e| {
+ tracing::error!("DFSM send_message_sync failed for MTIME: {}", e);
+ io::Error::from_raw_os_error(EIO)
+ })?;
+
+ if result.result < 0 {
+ tracing::warn!("MTIME failed with errno: {}", -result.result);
+ return Err(io::Error::from_raw_os_error(-result.result as i32));
+ }
+ } else {
+ // No cluster - update locally
+ self.memdb
+ .set_mtime(&path, 0, new_mtime)
+ .map_err(|_| io::Error::from_raw_os_error(EACCES))?;
+ }
+ }
+
+ // Return current attributes
+ if let Some(entry) = self.memdb.get_entry_by_inode(ino) {
+ Ok(self.entry_to_stat(&entry, &path))
+ } else {
+ Err(io::Error::from_raw_os_error(ENOENT))
+ }
+ }
+
+ /// Handle readlink operation - read symbolic link target
+ fn handle_readlink(&self, ino_fuse: u64) -> io::Result<OsString> {
+ tracing::debug!("readlink(ino={})", ino_fuse);
+
+ // Check if this is a plugin (only plugins can be symlinks in pmxcfs)
+ if ino_fuse >= Self::PLUGIN_INODE_OFFSET {
+ let plugin_idx = (ino_fuse - Self::PLUGIN_INODE_OFFSET) as usize;
+ let plugin_names = self.plugins.list();
+ if plugin_idx < plugin_names.len() {
+ let plugin_name = &plugin_names[plugin_idx];
+ if let Some(plugin) = self.plugins.get(plugin_name) {
+ // Read the link target from the plugin
+ let data = plugin
+ .read()
+ .map_err(|_| io::Error::from_raw_os_error(EIO))?;
+
+ // Convert bytes to OsString
+ let target = std::str::from_utf8(&data)
+ .map_err(|_| io::Error::from_raw_os_error(EIO))?;
+
+ return Ok(OsString::from(target));
+ }
+ }
+ }
+
+ // Not a plugin or plugin not found
+ Err(io::Error::from_raw_os_error(EINVAL))
+ }
+
+ /// Handle statfs operation - return filesystem statistics
+ ///
+ /// Matches C implementation (memdb.c:1275-1307)
+ /// Returns fixed filesystem stats based on memdb state
+ fn handle_statfs(&self) -> io::Result<libc::statvfs> {
+ tracing::debug!("statfs()");
+
+ const BLOCKSIZE: u64 = 4096;
+
+ // Get statistics from memdb
+ let (blocks, bfree, bavail, files, ffree) = self.memdb.statfs();
+
+ let mut stbuf: libc::statvfs = unsafe { mem::zeroed() };
+
+ // Block size and counts
+ stbuf.f_bsize = BLOCKSIZE; // Filesystem block size
+ stbuf.f_frsize = BLOCKSIZE; // Fragment size (same as block size)
+ stbuf.f_blocks = blocks; // Total blocks in filesystem
+ stbuf.f_bfree = bfree; // Free blocks
+ stbuf.f_bavail = bavail; // Free blocks available to unprivileged user
+
+ // Inode counts
+ stbuf.f_files = files; // Total file nodes in filesystem
+ stbuf.f_ffree = ffree; // Free file nodes in filesystem
+ stbuf.f_favail = ffree; // Free file nodes available to unprivileged user
+
+ // Other fields
+ stbuf.f_fsid = 0; // Filesystem ID
+ stbuf.f_flag = 0; // Mount flags
+ stbuf.f_namemax = 255; // Maximum filename length
+
+ Ok(stbuf)
+ }
+}
+
+/// Create and mount FUSE filesystem
+pub async fn mount_fuse(
+ mount_path: &Path,
+ memdb: MemDb,
+ config: Arc<Config>,
+ dfsm: Option<Arc<Dfsm<FuseMessage>>>,
+ plugins: Arc<PluginRegistry>,
+ status: Arc<Status>,
+) -> Result<(), Error> {
+ let fs = Arc::new(PmxcfsFilesystem::new(memdb, config, dfsm, plugins, status));
+
+ let mut fuse = Fuse::builder("pmxcfs")?
+ .debug()
+ .options("default_permissions")? // Enable kernel permission checking
+ .options("allow_other")? // Allow non-root access
+ .enable_readdir()
+ .enable_readlink()
+ .enable_mkdir()
+ .enable_create()
+ .enable_write()
+ .enable_unlink()
+ .enable_rmdir()
+ .enable_rename()
+ .enable_setattr()
+ .enable_read()
+ .enable_statfs()
+ .build()?
+ .mount(mount_path)?;
+
+ tracing::info!("FUSE filesystem mounted at {}", mount_path.display());
+
+ // Process FUSE requests
+ while let Some(request) = fuse.try_next().await? {
+ let fs = Arc::clone(&fs);
+ match request {
+ Request::Lookup(request) => {
+ match fs.handle_lookup(request.parent, &request.file_name).await {
+ Ok(entry) => request.reply(&entry)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Getattr(request) => match fs.handle_getattr(request.inode) {
+ Ok(stat) => request.reply(&stat, TTL)?,
+ Err(err) => request.io_fail(err)?,
+ },
+ Request::Readlink(request) => match fs.handle_readlink(request.inode) {
+ Ok(target) => request.reply(&target)?,
+ Err(err) => request.io_fail(err)?,
+ },
+ Request::Readdir(mut request) => match fs.handle_readdir(&mut request) {
+ Ok(()) => request.reply()?,
+ Err(err) => {
+ if let Some(io_err) = err.downcast_ref::<io::Error>() {
+ let errno = io_err.raw_os_error().unwrap_or(EIO);
+ request.fail(errno)?;
+ } else {
+ request.io_fail(io::Error::from_raw_os_error(EIO))?;
+ }
+ }
+ },
+ Request::Read(request) => {
+ match fs.handle_read(request.inode, request.offset, request.size) {
+ Ok(data) => request.reply(&data)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Write(request) => {
+ match fs.handle_write(request.inode, request.offset, request.data()).await {
+ Ok(written) => request.reply(written)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Mkdir(request) => {
+ match fs.handle_mkdir(request.parent, &request.dir_name, request.mode).await {
+ Ok(entry) => request.reply(&entry)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Rmdir(request) => match fs.handle_rmdir(request.parent, &request.dir_name).await {
+ Ok(()) => request.reply()?,
+ Err(err) => request.io_fail(err)?,
+ },
+ Request::Rename(request) => {
+ match fs.handle_rename(
+ request.parent,
+ &request.name,
+ request.new_parent,
+ &request.new_name,
+ ).await {
+ Ok(()) => request.reply()?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Create(request) => {
+ match fs.handle_create(request.parent, &request.file_name, request.mode).await {
+ Ok(entry) => request.reply(&entry, 0)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Mknod(request) => {
+ // Treat mknod same as create
+ match fs.handle_create(request.parent, &request.file_name, request.mode).await {
+ Ok(entry) => request.reply(&entry)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Unlink(request) => {
+ match fs.handle_unlink(request.parent, &request.file_name).await {
+ Ok(()) => request.reply()?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Setattr(request) => {
+ // Extract mtime if being set
+ let mtime = request.mtime().map(|set_time| match set_time {
+ proxmox_fuse::requests::SetTime::Time(duration) => duration.as_secs() as u32,
+ proxmox_fuse::requests::SetTime::Now => SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs()
+ as u32,
+ });
+
+ // Extract mode, uid, gid for chmod/chown validation (M1, M2)
+ let mode = request.mode();
+ let uid = request.uid();
+ let gid = request.gid();
+
+ match fs.handle_setattr(request.inode, request.size(), mtime, mode, uid, gid).await {
+ Ok(stat) => request.reply(&stat, TTL)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ Request::Open(request) => {
+ // Plugin files don't support truncation, but can be opened for write
+ if request.inode >= PmxcfsFilesystem::PLUGIN_INODE_OFFSET {
+ // Check if plugin is being opened for writing
+ let is_write = (request.flags & (libc::O_WRONLY | libc::O_RDWR)) != 0;
+
+ if is_write {
+ // Verify plugin is writable
+ let plugin_idx =
+ (request.inode - PmxcfsFilesystem::PLUGIN_INODE_OFFSET) as usize;
+ let plugin_names = fs.plugins.list();
+
+ if plugin_idx < plugin_names.len() {
+ let plugin_name = &plugin_names[plugin_idx];
+ if let Some(plugin) = fs.plugins.get(plugin_name) {
+ // Check if plugin supports write (mode has write bit for owner)
+ let mode = plugin.mode();
+ if (mode & 0o200) == 0 {
+ // Plugin is read-only
+ request.io_fail(io::Error::from_raw_os_error(libc::EACCES))?;
+ continue;
+ }
+ }
+ }
+ }
+
+ // Verify plugin exists (getattr)
+ match fs.handle_getattr(request.inode) {
+ Ok(_) => request.reply(0)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ } else {
+ // Regular files: handle truncation
+ if (request.flags & libc::O_TRUNC) != 0 {
+ match fs.handle_setattr(request.inode, Some(0), None, None, None, None).await {
+ Ok(_) => request.reply(0)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ } else {
+ match fs.handle_getattr(request.inode) {
+ Ok(_) => request.reply(0)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ }
+ }
+ Request::Release(request) => {
+ request.reply()?;
+ }
+ Request::Forget(_request) => {
+ // Forget is a notification, no reply needed
+ }
+ Request::Statfs(request) => {
+ match fs.handle_statfs() {
+ Ok(stbuf) => request.reply(&stbuf)?,
+ Err(err) => request.io_fail(err)?,
+ }
+ }
+ other => {
+ tracing::warn!("Unsupported FUSE request: {:?}", other);
+ bail!("Unsupported FUSE request");
+ }
+ }
+ }
+
+ Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use tempfile::TempDir;
+
+ /// Helper to create a minimal PmxcfsFilesystem for testing
+ fn create_test_filesystem() -> (PmxcfsFilesystem, TempDir) {
+ let tmp_dir = TempDir::new().unwrap();
+ let db_path = tmp_dir.path().join("test.db");
+
+ let memdb = MemDb::open(&db_path, true).unwrap();
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let plugins = crate::plugins::init_plugins_for_test("testnode");
+ let status = Arc::new(Status::new(config.clone(), None));
+
+ let fs = PmxcfsFilesystem::new(memdb, config, None, plugins, status);
+ (fs, tmp_dir)
+ }
+
+ // ===== Inode Mapping Tests =====
+
+ #[test]
+ fn test_fuse_to_inode_mapping() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Root: FUSE nodeid 1 → internal inode 0
+ assert_eq!(fs.fuse_to_inode(1), 0);
+
+ // Regular inodes: N → N-1
+ assert_eq!(fs.fuse_to_inode(2), 1);
+ assert_eq!(fs.fuse_to_inode(10), 9);
+ assert_eq!(fs.fuse_to_inode(100), 99);
+
+ // Plugin inodes (>= PLUGIN_INODE_OFFSET) unchanged
+ assert_eq!(fs.fuse_to_inode(1000000), 1000000);
+ assert_eq!(fs.fuse_to_inode(1000001), 1000001);
+ }
+
+ #[test]
+ fn test_inode_to_fuse_mapping() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Root: internal inode 0 → FUSE nodeid 1
+ assert_eq!(fs.inode_to_fuse(0), 1);
+
+ // Regular inodes: N → N+1
+ assert_eq!(fs.inode_to_fuse(1), 2);
+ assert_eq!(fs.inode_to_fuse(9), 10);
+ assert_eq!(fs.inode_to_fuse(99), 100);
+
+ // Plugin inodes (>= PLUGIN_INODE_OFFSET) unchanged
+ assert_eq!(fs.inode_to_fuse(1000000), 1000000);
+ assert_eq!(fs.inode_to_fuse(1000001), 1000001);
+ }
+
+ #[test]
+ fn test_inode_mapping_roundtrip() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Test roundtrip for regular inodes
+ for inode in 0..1000 {
+ let fuse = fs.inode_to_fuse(inode);
+ let back = fs.fuse_to_inode(fuse);
+ assert_eq!(inode, back, "Roundtrip failed for inode {inode}");
+ }
+
+ // Test roundtrip for plugin inodes
+ for offset in 0..100 {
+ let inode = 1000000 + offset;
+ let fuse = fs.inode_to_fuse(inode);
+ let back = fs.fuse_to_inode(fuse);
+ assert_eq!(inode, back, "Roundtrip failed for plugin inode {inode}");
+ }
+ }
+
+ // ===== Path Privacy Tests =====
+
+ #[test]
+ fn test_is_private_path_priv_root() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Exact "priv" at root
+ assert!(fs.is_private_path("priv"));
+ assert!(fs.is_private_path("/priv"));
+ assert!(fs.is_private_path("///priv"));
+
+ // "priv/" at root
+ assert!(fs.is_private_path("priv/"));
+ assert!(fs.is_private_path("/priv/"));
+ assert!(fs.is_private_path("priv/file.txt"));
+ assert!(fs.is_private_path("/priv/subdir/file"));
+ }
+
+ #[test]
+ fn test_is_private_path_nodes() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Node-specific priv directories
+ assert!(fs.is_private_path("nodes/node1/priv"));
+ assert!(fs.is_private_path("/nodes/node1/priv"));
+ assert!(fs.is_private_path("nodes/node1/priv/"));
+ assert!(fs.is_private_path("nodes/node1/priv/config"));
+ assert!(fs.is_private_path("/nodes/node1/priv/subdir/file"));
+
+ // Multiple levels
+ assert!(fs.is_private_path("nodes/test-node/priv/deep/path/file.txt"));
+ }
+
+ #[test]
+ fn test_is_private_path_non_private() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // "priv" as substring but not matching pattern
+ assert!(!fs.is_private_path("private"));
+ assert!(!fs.is_private_path("privileged"));
+ assert!(!fs.is_private_path("some/private/path"));
+
+ // Regular paths
+ assert!(!fs.is_private_path(""));
+ assert!(!fs.is_private_path("/"));
+ assert!(!fs.is_private_path("nodes"));
+ assert!(!fs.is_private_path("nodes/node1"));
+ assert!(!fs.is_private_path("nodes/node1/qemu-server"));
+ assert!(!fs.is_private_path("corosync.conf"));
+
+ // "priv" in middle of path component
+ assert!(!fs.is_private_path("nodes/privileged"));
+ assert!(!fs.is_private_path("nodes/node1/private"));
+ }
+
+ #[test]
+ fn test_is_private_path_edge_cases() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Empty path
+ assert!(!fs.is_private_path(""));
+
+ // Only slashes
+ assert!(!fs.is_private_path("/"));
+ assert!(!fs.is_private_path("//"));
+ assert!(!fs.is_private_path("///"));
+
+ // "priv" with trailing characters (not slash)
+ assert!(!fs.is_private_path("priv123"));
+ assert!(!fs.is_private_path("priv.txt"));
+
+ // Case sensitivity
+ assert!(!fs.is_private_path("Priv"));
+ assert!(!fs.is_private_path("PRIV"));
+ assert!(!fs.is_private_path("nodes/node1/Priv"));
+ }
+
+ // ===== Error Path Tests =====
+
+ #[tokio::test]
+ async fn test_lookup_nonexistent() {
+ use std::ffi::OsStr;
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Try to lookup a file that doesn't exist
+ let result = fs.handle_lookup(1, OsStr::new("nonexistent.txt")).await;
+
+ assert!(result.is_err(), "Lookup of nonexistent file should fail");
+ if let Err(e) = result {
+ assert_eq!(e.raw_os_error(), Some(libc::ENOENT));
+ }
+ }
+
+ #[test]
+ fn test_getattr_nonexistent_inode() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Try to get attributes for an inode that doesn't exist
+ let result = fs.handle_getattr(999999);
+
+ assert!(result.is_err(), "Getattr on nonexistent inode should fail");
+ if let Err(e) = result {
+ assert_eq!(e.raw_os_error(), Some(libc::ENOENT));
+ }
+ }
+
+ #[test]
+ fn test_read_directory_as_file() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Try to read the root directory as if it were a file
+ let result = fs.handle_read(1, 0, 100);
+
+ assert!(result.is_err(), "Reading directory as file should fail");
+ if let Err(e) = result {
+ assert_eq!(e.raw_os_error(), Some(libc::EISDIR));
+ }
+ }
+
+ #[tokio::test]
+ async fn test_write_to_nonexistent_file() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Try to write to a file that doesn't exist (should fail with EACCES)
+ let result = fs.handle_write(999999, 0, b"data").await;
+
+ assert!(result.is_err(), "Writing to nonexistent file should fail");
+ if let Err(e) = result {
+ assert_eq!(e.raw_os_error(), Some(libc::EACCES));
+ }
+ }
+
+ #[tokio::test]
+ async fn test_unlink_directory_fails() {
+ use std::ffi::OsStr;
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Create a directory first by writing a file
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_secs() as u32;
+ let _ = fs.memdb.write("/testdir/file.txt", 0, 0, now, b"test", false);
+
+ // Look up testdir to verify it exists as a directory
+ if let Some(entry) = fs.memdb.lookup_path("/testdir") {
+ assert!(entry.is_dir(), "testdir should be a directory");
+
+ // Try to unlink the directory (should fail)
+ let result = fs.handle_unlink(1, OsStr::new("testdir")).await;
+
+ assert!(result.is_err(), "Unlinking directory should fail");
+ // Note: May return EACCES if directory doesn't exist in internal lookup,
+ // or EISDIR if found as directory
+ if let Err(e) = result {
+ let err_code = e.raw_os_error();
+ assert!(
+ err_code == Some(libc::EISDIR) || err_code == Some(libc::EACCES),
+ "Expected EISDIR or EACCES, got {err_code:?}"
+ );
+ }
+ }
+ }
+
+ // ===== Plugin-related Tests =====
+
+ #[test]
+ fn test_plugin_inode_range() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Plugin inodes should be >= PLUGIN_INODE_OFFSET (1000000)
+ let plugin_inode = 1000000;
+
+ // Verify that plugin inodes don't overlap with regular inodes
+ assert!(plugin_inode >= 1000000);
+ assert_ne!(fs.fuse_to_inode(plugin_inode), plugin_inode - 1);
+ assert_eq!(fs.fuse_to_inode(plugin_inode), plugin_inode);
+ }
+
+ #[test]
+ fn test_file_type_preservation_in_permissions() {
+ let (fs, _tmpdir) = create_test_filesystem();
+
+ // Create a file
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_secs() as u32;
+ let _ = fs.memdb.write("/test.txt", 0, 0, now, b"test", false);
+
+ if let Ok(stat) = fs.handle_getattr(fs.inode_to_fuse(1)) {
+ // Verify that file type bits are preserved (S_IFREG)
+ assert_eq!(stat.st_mode & libc::S_IFMT, libc::S_IFREG);
+ }
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/fuse/mod.rs b/src/pmxcfs-rs/pmxcfs/src/fuse/mod.rs
new file mode 100644
index 000000000..1157127cd
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/fuse/mod.rs
@@ -0,0 +1,4 @@
+mod filesystem;
+
+pub use filesystem::PmxcfsFilesystem;
+pub use filesystem::mount_fuse;
diff --git a/src/pmxcfs-rs/pmxcfs/src/ipc/mod.rs b/src/pmxcfs-rs/pmxcfs/src/ipc/mod.rs
new file mode 100644
index 000000000..2fe08e753
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/ipc/mod.rs
@@ -0,0 +1,16 @@
+//! IPC (Inter-Process Communication) subsystem
+//!
+//! This module handles libqb-compatible IPC communication between pmxcfs
+//! and client applications (e.g., pvestatd, pvesh, etc.).
+//!
+//! The IPC subsystem consists of:
+//! - Operation codes (CfsIpcOp) defining available IPC operations
+//! - Request types (IpcRequest) representing parsed client requests
+//! - Service handler (IpcHandler) implementing the request processing logic
+
+mod request;
+mod service;
+
+// Re-export public types
+pub use request::{CfsIpcOp, IpcRequest};
+pub use service::IpcHandler;
diff --git a/src/pmxcfs-rs/pmxcfs/src/ipc/request.rs b/src/pmxcfs-rs/pmxcfs/src/ipc/request.rs
new file mode 100644
index 000000000..4b590dcea
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/ipc/request.rs
@@ -0,0 +1,314 @@
+//! IPC request types and parsing
+//!
+//! This module defines the IPC operation codes and request message types
+//! used for communication between pmxcfs and client applications via libqb IPC.
+
+/// IPC operation codes (must match C version for compatibility)
+#[derive(Debug, Clone, Copy, PartialEq, Eq, num_enum::TryFromPrimitive)]
+#[repr(i32)]
+pub enum CfsIpcOp {
+ GetFsVersion = 1,
+ GetClusterInfo = 2,
+ GetGuestList = 3,
+ SetStatus = 4,
+ GetStatus = 5,
+ GetConfig = 6,
+ LogClusterMsg = 7,
+ GetClusterLog = 8,
+ GetRrdDump = 10,
+ GetGuestConfigProperty = 11,
+ VerifyToken = 12,
+ GetGuestConfigProperties = 13,
+}
+
+/// IPC request message
+///
+/// Represents deserialized IPC requests sent from clients via libqb IPC.
+/// Each variant corresponds to an IPC operation code and contains the
+/// deserialized request parameters.
+#[derive(Debug, Clone, PartialEq)]
+pub enum IpcRequest {
+ /// GET_FS_VERSION (op 1): Get filesystem version info
+ GetFsVersion,
+
+ /// GET_CLUSTER_INFO (op 2): Get cluster member list
+ GetClusterInfo,
+
+ /// GET_GUEST_LIST (op 3): Get VM/CT list
+ GetGuestList,
+
+ /// SET_STATUS (op 4): Update node status
+ SetStatus { name: String, data: Vec<u8> },
+
+ /// GET_STATUS (op 5): Get node status
+ /// C format: name (256 bytes) + nodename (256 bytes)
+ GetStatus {
+ name: String,
+ node_name: String,
+ },
+
+ /// GET_CONFIG (op 6): Read configuration file
+ GetConfig { path: String },
+
+ /// LOG_CLUSTER_MSG (op 7): Write to cluster log
+ LogClusterMsg {
+ priority: u8,
+ ident: String,
+ tag: String,
+ message: String,
+ },
+
+ /// GET_CLUSTER_LOG (op 8): Read cluster log
+ /// C struct has max_entries + 3 reserved u32s + user string
+ GetClusterLog { max_entries: usize, user: String },
+
+ /// GET_RRD_DUMP (op 10): Get RRD data dump
+ GetRrdDump,
+
+ /// GET_GUEST_CONFIG_PROPERTY (op 11): Get guest config property
+ GetGuestConfigProperty { vmid: u32, property: String },
+
+ /// VERIFY_TOKEN (op 12): Verify authentication token
+ VerifyToken { token: String },
+
+ /// GET_GUEST_CONFIG_PROPERTIES (op 13): Get multiple guest config properties
+ GetGuestConfigProperties { vmid: u32, properties: Vec<String> },
+}
+
+impl IpcRequest {
+ /// Deserialize an IPC request from message ID and data
+ pub fn deserialize(msg_id: i32, data: &[u8]) -> anyhow::Result<Self> {
+ let op = CfsIpcOp::try_from(msg_id)
+ .map_err(|_| anyhow::anyhow!("Unknown IPC operation code: {msg_id}"))?;
+
+ match op {
+ CfsIpcOp::GetFsVersion => Ok(IpcRequest::GetFsVersion),
+
+ CfsIpcOp::GetClusterInfo => Ok(IpcRequest::GetClusterInfo),
+
+ CfsIpcOp::GetGuestList => Ok(IpcRequest::GetGuestList),
+
+ CfsIpcOp::SetStatus => {
+ // SET_STATUS: name (256 bytes) + data (rest)
+ if data.len() < 256 {
+ anyhow::bail!("SET_STATUS data too short");
+ }
+
+ let name = std::ffi::CStr::from_bytes_until_nul(&data[..256])
+ .map_err(|_| anyhow::anyhow!("Invalid name in SET_STATUS"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in SET_STATUS name"))?
+ .to_string();
+
+ let status_data = data[256..].to_vec();
+
+ Ok(IpcRequest::SetStatus {
+ name,
+ data: status_data,
+ })
+ }
+
+ CfsIpcOp::GetStatus => {
+ // GET_STATUS: name (256 bytes) + nodename (256 bytes)
+ // Matches C struct cfs_status_get_request_header_t (server.c:64-67)
+ if data.len() < 512 {
+ anyhow::bail!("GET_STATUS data too short");
+ }
+
+ let name = std::ffi::CStr::from_bytes_until_nul(&data[..256])
+ .map_err(|_| anyhow::anyhow!("Invalid name in GET_STATUS"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in GET_STATUS name"))?
+ .to_string();
+
+ let node_name = std::ffi::CStr::from_bytes_until_nul(&data[256..512])
+ .map_err(|_| anyhow::anyhow!("Invalid node name in GET_STATUS"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in GET_STATUS node name"))?
+ .to_string();
+
+ Ok(IpcRequest::GetStatus { name, node_name })
+ }
+
+ CfsIpcOp::GetConfig => {
+ // GET_CONFIG: path (null-terminated string)
+ let path = std::ffi::CStr::from_bytes_until_nul(data)
+ .map_err(|_| anyhow::anyhow!("Invalid path in GET_CONFIG"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in GET_CONFIG path"))?
+ .to_string();
+
+ Ok(IpcRequest::GetConfig { path })
+ }
+
+ CfsIpcOp::LogClusterMsg => {
+ // LOG_CLUSTER_MSG: priority + ident_len + tag_len + strings
+ // C struct (server.c:69-75):
+ // uint8_t priority;
+ // uint8_t ident_len; // Length INCLUDING null terminator
+ // uint8_t tag_len; // Length INCLUDING null terminator
+ // char data[]; // ident\0 + tag\0 + message\0
+ if data.len() < 3 {
+ anyhow::bail!("LOG_CLUSTER_MSG data too short");
+ }
+
+ let priority = data[0];
+ let ident_len = data[1] as usize;
+ let tag_len = data[2] as usize;
+
+ // Validate lengths (must include null terminator, so >= 1)
+ if ident_len < 1 || tag_len < 1 {
+ anyhow::bail!("LOG_CLUSTER_MSG: ident_len or tag_len is 0");
+ }
+
+ // Calculate message length (C: datasize - ident_len - tag_len)
+ let msg_start = 3 + ident_len + tag_len;
+ if data.len() < msg_start + 1 {
+ anyhow::bail!("LOG_CLUSTER_MSG data too short for message");
+ }
+
+ // Parse ident (null-terminated C string)
+ // C validates: msg[ident_len - 1] == 0
+ let ident_data = &data[3..3 + ident_len];
+ if ident_data[ident_len - 1] != 0 {
+ anyhow::bail!("LOG_CLUSTER_MSG: ident not null-terminated");
+ }
+ let ident = std::ffi::CStr::from_bytes_with_nul(ident_data)
+ .map_err(|_| anyhow::anyhow!("Invalid ident in LOG_CLUSTER_MSG"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in ident"))?
+ .to_string();
+
+ // Parse tag (null-terminated C string)
+ // C validates: msg[ident_len + tag_len - 1] == 0
+ let tag_data = &data[3 + ident_len..3 + ident_len + tag_len];
+ if tag_data[tag_len - 1] != 0 {
+ anyhow::bail!("LOG_CLUSTER_MSG: tag not null-terminated");
+ }
+ let tag = std::ffi::CStr::from_bytes_with_nul(tag_data)
+ .map_err(|_| anyhow::anyhow!("Invalid tag in LOG_CLUSTER_MSG"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in tag"))?
+ .to_string();
+
+ // Parse message (rest of data, null-terminated)
+ // C validates: data[request_size] == 0 (but this is a bug - accesses past buffer)
+ // We'll be more lenient and just read until end or first null
+ let msg_data = &data[msg_start..];
+ let message = std::ffi::CStr::from_bytes_until_nul(msg_data)
+ .map_err(|_| anyhow::anyhow!("Invalid message in LOG_CLUSTER_MSG"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in message"))?
+ .to_string();
+
+ Ok(IpcRequest::LogClusterMsg {
+ priority,
+ ident,
+ tag,
+ message,
+ })
+ }
+
+ CfsIpcOp::GetClusterLog => {
+ // GET_CLUSTER_LOG: C struct (server.c:77-83):
+ // uint32_t max_entries;
+ // uint32_t res1, res2, res3; // reserved, unused
+ // char user[]; // null-terminated user string for filtering
+ // Total header: 16 bytes, followed by user string
+ const HEADER_SIZE: usize = 16; // 4 u32 fields
+
+ if data.len() <= HEADER_SIZE {
+ // C returns EINVAL if userlen <= 0
+ anyhow::bail!("GET_CLUSTER_LOG: missing user string");
+ }
+
+ let max_entries = u32::from_le_bytes([data[0], data[1], data[2], data[3]]) as usize;
+ // Default to 50 if max_entries is 0 (matches C: rh->max_entries ? rh->max_entries : 50)
+ let max_entries = if max_entries == 0 { 50 } else { max_entries };
+
+ // Parse user string (null-terminated)
+ let user = std::ffi::CStr::from_bytes_until_nul(&data[HEADER_SIZE..])
+ .map_err(|_| anyhow::anyhow!("Invalid user string in GET_CLUSTER_LOG"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in user string"))?
+ .to_string();
+
+ Ok(IpcRequest::GetClusterLog { max_entries, user })
+ }
+
+ CfsIpcOp::GetRrdDump => Ok(IpcRequest::GetRrdDump),
+
+ CfsIpcOp::GetGuestConfigProperty => {
+ // GET_GUEST_CONFIG_PROPERTY: vmid (u32) + property (null-terminated)
+ if data.len() < 4 {
+ anyhow::bail!("GET_GUEST_CONFIG_PROPERTY data too short");
+ }
+
+ let vmid = u32::from_le_bytes([data[0], data[1], data[2], data[3]]);
+
+ let property = std::ffi::CStr::from_bytes_until_nul(&data[4..])
+ .map_err(|_| anyhow::anyhow!("Invalid property in GET_GUEST_CONFIG_PROPERTY"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in property"))?
+ .to_string();
+
+ Ok(IpcRequest::GetGuestConfigProperty { vmid, property })
+ }
+
+ CfsIpcOp::VerifyToken => {
+ // VERIFY_TOKEN: token (null-terminated string)
+ let token = std::ffi::CStr::from_bytes_until_nul(data)
+ .map_err(|_| anyhow::anyhow!("Invalid token in VERIFY_TOKEN"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in token"))?
+ .to_string();
+
+ Ok(IpcRequest::VerifyToken { token })
+ }
+
+ CfsIpcOp::GetGuestConfigProperties => {
+ // GET_GUEST_CONFIG_PROPERTIES: vmid (u32) + num_props (u8) + property list
+ if data.len() < 5 {
+ anyhow::bail!("GET_GUEST_CONFIG_PROPERTIES data too short");
+ }
+
+ let vmid = u32::from_le_bytes([data[0], data[1], data[2], data[3]]);
+ let num_props = data[4] as usize;
+
+ if num_props == 0 {
+ anyhow::bail!("GET_GUEST_CONFIG_PROPERTIES requires at least one property");
+ }
+
+ let mut properties = Vec::with_capacity(num_props);
+ let mut remaining = &data[5..];
+
+ for i in 0..num_props {
+ if remaining.is_empty() {
+ anyhow::bail!("Property {i} is missing");
+ }
+
+ let property = std::ffi::CStr::from_bytes_until_nul(remaining)
+ .map_err(|_| anyhow::anyhow!("Property {i} not null-terminated"))?
+ .to_str()
+ .map_err(|_| anyhow::anyhow!("Property {i} is not valid UTF-8"))?;
+
+ // Validate property name starts with lowercase letter
+ if property.is_empty() || !property.chars().next().unwrap().is_ascii_lowercase()
+ {
+ anyhow::bail!("Property {i} does not start with [a-z]");
+ }
+
+ properties.push(property.to_string());
+ remaining = &remaining[property.len() + 1..]; // +1 for null terminator
+ }
+
+ // Verify no leftover data
+ if !remaining.is_empty() {
+ anyhow::bail!("Leftover data after parsing {num_props} properties");
+ }
+
+ Ok(IpcRequest::GetGuestConfigProperties { vmid, properties })
+ }
+ }
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/ipc/service.rs b/src/pmxcfs-rs/pmxcfs/src/ipc/service.rs
new file mode 100644
index 000000000..57eaaa1eb
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/ipc/service.rs
@@ -0,0 +1,684 @@
+//! IPC Service implementation
+//!
+//! This module implements the IPC service handler that processes requests
+//! from client applications via libqb-compatible IPC.
+
+use super::IpcRequest;
+use async_trait::async_trait;
+use pmxcfs_config::Config;
+use pmxcfs_ipc::{Handler, Permissions, Request, Response};
+use pmxcfs_memdb::MemDb;
+use pmxcfs_status as status;
+use std::io::Error as IoError;
+use std::sync::Arc;
+
+/// IPC handler for pmxcfs protocol operations
+pub struct IpcHandler {
+ memdb: MemDb,
+ status: Arc<status::Status>,
+ config: Arc<Config>,
+ www_data_gid: u32,
+}
+
+impl IpcHandler {
+ /// Create a new IPC handler
+ pub fn new(
+ memdb: MemDb,
+ status: Arc<status::Status>,
+ config: Arc<Config>,
+ www_data_gid: u32,
+ ) -> Self {
+ Self {
+ memdb,
+ status,
+ config,
+ www_data_gid,
+ }
+ }
+}
+
+impl IpcHandler {
+ /// Handle an IPC request and return (error_code, response_data)
+ async fn handle_request(&self, request: IpcRequest, is_read_only: bool) -> (i32, Vec<u8>) {
+ let result = match request {
+ IpcRequest::GetFsVersion => self.handle_get_fs_version(),
+ IpcRequest::GetClusterInfo => self.handle_get_cluster_info(),
+ IpcRequest::GetGuestList => self.handle_get_guest_list(),
+ IpcRequest::GetConfig { path } => self.handle_get_config(&path, is_read_only),
+ IpcRequest::GetStatus { name, node_name } => {
+ self.handle_get_status(&name, &node_name)
+ }
+ IpcRequest::SetStatus { name, data } => {
+ if is_read_only {
+ Err(IoError::from_raw_os_error(libc::EPERM))
+ } else {
+ self.handle_set_status(&name, &data).await
+ }
+ }
+ IpcRequest::LogClusterMsg {
+ priority,
+ ident,
+ tag,
+ message,
+ } => {
+ if is_read_only {
+ Err(IoError::from_raw_os_error(libc::EPERM))
+ } else {
+ self.handle_log_cluster_msg(priority, &ident, &tag, &message)
+ }
+ }
+ IpcRequest::GetClusterLog { max_entries, user } => {
+ self.handle_get_cluster_log(max_entries, &user)
+ }
+ IpcRequest::GetRrdDump => self.handle_get_rrd_dump(),
+ IpcRequest::GetGuestConfigProperty { vmid, property } => {
+ self.handle_get_guest_config_property(vmid, &property)
+ }
+ IpcRequest::VerifyToken { token } => self.handle_verify_token(&token),
+ IpcRequest::GetGuestConfigProperties { vmid, properties } => {
+ self.handle_get_guest_config_properties(vmid, &properties)
+ }
+ };
+
+ match result {
+ Ok(response_data) => (0, response_data),
+ Err(e) => {
+ let error_code = if let Some(os_error) = e.raw_os_error() {
+ -os_error
+ } else {
+ -libc::EIO
+ };
+ tracing::debug!("Request error: {}", e);
+ (error_code, Vec::new())
+ }
+ }
+ }
+
+ /// GET_FS_VERSION: Return filesystem version information
+ fn handle_get_fs_version(&self) -> Result<Vec<u8>, IoError> {
+ let version = serde_json::json!({
+ "version": 1,
+ "protocol": 1,
+ "cluster": self.status.is_quorate(),
+ });
+ Ok(version.to_string().into_bytes())
+ }
+
+ /// GET_CLUSTER_INFO: Return cluster member list
+ fn handle_get_cluster_info(&self) -> Result<Vec<u8>, IoError> {
+ let members = self.status.get_members();
+ let member_list: Vec<serde_json::Value> = members
+ .iter()
+ .map(|m| {
+ serde_json::json!({
+ "nodeid": m.node_id,
+ "name": format!("node{}", m.node_id),
+ "ip": "127.0.0.1",
+ "online": true,
+ })
+ })
+ .collect();
+
+ let info = serde_json::json!({
+ "nodelist": member_list,
+ "quorate": self.status.is_quorate(),
+ });
+ Ok(info.to_string().into_bytes())
+ }
+
+ /// GET_GUEST_LIST: Return VM/CT list
+ fn handle_get_guest_list(&self) -> Result<Vec<u8>, IoError> {
+ let vmlist_data = self.status.get_vmlist();
+
+ // Convert VM list to JSON format matching C implementation
+ let mut ids = serde_json::Map::new();
+ for (vmid, vm_entry) in vmlist_data {
+ ids.insert(
+ vmid.to_string(),
+ serde_json::json!({
+ "node": vm_entry.node,
+ "type": vm_entry.vmtype.to_string(),
+ "version": vm_entry.version,
+ }),
+ );
+ }
+
+ let vmlist = serde_json::json!({
+ "version": 1,
+ "ids": ids,
+ });
+
+ Ok(vmlist.to_string().into_bytes())
+ }
+
+ /// GET_CONFIG: Read configuration file
+ fn handle_get_config(&self, path: &str, is_read_only: bool) -> Result<Vec<u8>, IoError> {
+ // Check if read-only client is trying to access private path
+ if is_read_only && path.starts_with("priv/") {
+ return Err(IoError::from_raw_os_error(libc::EPERM));
+ }
+
+ // Read from memdb
+ match self.memdb.read(path, 0, 1024 * 1024) {
+ Ok(data) => Ok(data),
+ Err(_) => Err(IoError::from_raw_os_error(libc::ENOENT)),
+ }
+ }
+
+ /// GET_STATUS: Get node status
+ ///
+ /// Matches C implementation: cfs_create_status_msg(outbuf, nodename, name)
+ /// where nodename is the node to query and name is the specific status key.
+ ///
+ /// C implementation (server.c:233, status.c:1640-1668):
+ /// - If name is empty: return ENOENT
+ /// - Local node: look up bare `name` key in node_status (cfs_status.kvhash)
+ /// - Remote node: resolve nodename→nodeid, look up in kvstore (clnode->kvhash)
+ fn handle_get_status(&self, name: &str, nodename: &str) -> Result<Vec<u8>, IoError> {
+ if name.is_empty() {
+ return Err(IoError::from_raw_os_error(libc::ENOENT));
+ }
+
+ let is_local = nodename.is_empty() || nodename == self.config.nodename();
+
+ if is_local {
+ // Local node: look up bare key in node_status (matches C: cfs_status.kvhash[key])
+ if let Some(ns) = self.status.get_node_status(name) {
+ return Ok(ns.data);
+ }
+ } else {
+ // Remote node: resolve nodename→nodeid, look up in kvstore
+ // (matches C: clnode->kvhash[key] via clinfo->nodes_byname)
+ if let Some(info) = self.status.get_cluster_info() {
+ if let Some(&nodeid) = info.nodes_by_name.get(nodename) {
+ if let Some(data) = self.status.get_node_kv(nodeid, name) {
+ return Ok(data);
+ }
+ }
+ }
+ }
+
+ Err(IoError::from_raw_os_error(libc::ENOENT))
+ }
+
+ /// SET_STATUS: Update node status
+ async fn handle_set_status(&self, name: &str, status_data: &[u8]) -> Result<Vec<u8>, IoError> {
+ self.status
+ .set_node_status(name.to_string(), status_data.to_vec())
+ .await
+ .map_err(|_| IoError::from_raw_os_error(libc::EIO))?;
+
+ Ok(Vec::new())
+ }
+
+ /// LOG_CLUSTER_MSG: Write to cluster log
+ fn handle_log_cluster_msg(
+ &self,
+ priority: u8,
+ ident: &str,
+ tag: &str,
+ message: &str,
+ ) -> Result<Vec<u8>, IoError> {
+ // Get node name from config (matches C implementation's cfs.nodename)
+ let node = self.config.nodename().to_string();
+
+ // Add log entry to cluster log
+ let timestamp = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map_err(|_| IoError::from_raw_os_error(libc::EIO))?
+ .as_secs();
+
+ let entry = status::ClusterLogEntry {
+ uid: 0, // Will be assigned by cluster log
+ timestamp,
+ priority,
+ tag: tag.to_string(),
+ pid: std::process::id(),
+ node,
+ ident: ident.to_string(),
+ message: message.to_string(),
+ };
+
+ self.status.add_log_entry(entry);
+
+ Ok(Vec::new())
+ }
+
+ /// GET_CLUSTER_LOG: Read cluster log
+ ///
+ /// The `user` parameter is used for filtering log entries by user.
+ /// Matches C implementation: cfs_cluster_log_dump(outbuf, user, max)
+ /// Returns JSON format: {"data": [{entry1}, {entry2}, ...]}
+ fn handle_get_cluster_log(&self, max_entries: usize, user: &str) -> Result<Vec<u8>, IoError> {
+ let entries = self.status.get_log_entries_filtered(max_entries, user);
+
+ // Format as JSON object with "data" array (matches C implementation)
+ let json_entries: Vec<serde_json::Value> = entries
+ .iter()
+ .map(|entry| {
+ serde_json::json!({
+ "uid": entry.uid,
+ "time": entry.timestamp,
+ "pri": entry.priority,
+ "tag": entry.tag,
+ "pid": entry.pid,
+ "node": entry.node,
+ "user": entry.ident,
+ "msg": entry.message,
+ })
+ })
+ .collect();
+
+ let response = serde_json::json!({
+ "data": json_entries
+ });
+
+ Ok(response.to_string().into_bytes())
+ }
+
+ /// GET_RRD_DUMP: Get RRD data dump in C-compatible text format
+ fn handle_get_rrd_dump(&self) -> Result<Vec<u8>, IoError> {
+ let rrd_dump = self.status.get_rrd_dump();
+ Ok(rrd_dump.into_bytes())
+ }
+
+ /// GET_GUEST_CONFIG_PROPERTY: Get guest config property
+ fn handle_get_guest_config_property(
+ &self,
+ vmid: u32,
+ property: &str,
+ ) -> Result<Vec<u8>, IoError> {
+ // Delegate to multi-property handler with single property
+ self.handle_get_guest_config_properties_impl(&[property], vmid)
+ }
+
+ /// VERIFY_TOKEN: Verify authentication token
+ ///
+ /// Matches C implementation (server.c:399-448):
+ /// - Empty token → EINVAL
+ /// - Token containing newline → EINVAL
+ /// - Exact line match (no trimming), splitting on '\n' only
+ fn handle_verify_token(&self, token: &str) -> Result<Vec<u8>, IoError> {
+ // Reject empty tokens
+ if token.is_empty() {
+ return Err(IoError::from_raw_os_error(libc::EINVAL));
+ }
+
+ // Reject tokens containing newlines (would break line-based matching)
+ if token.contains('\n') {
+ return Err(IoError::from_raw_os_error(libc::EINVAL));
+ }
+
+ // Read token.cfg from database
+ match self.memdb.read("priv/token.cfg", 0, 1024 * 1024) {
+ Ok(token_data) => {
+ // Check if token exists in file (one token per line)
+ // C splits on '\n' only (not '\r\n') and does exact match (no trim)
+ let token_str = String::from_utf8_lossy(&token_data);
+ for line in token_str.split('\n') {
+ if line == token {
+ return Ok(Vec::new()); // Success
+ }
+ }
+ Err(IoError::from_raw_os_error(libc::ENOENT))
+ }
+ Err(_) => Err(IoError::from_raw_os_error(libc::ENOENT)),
+ }
+ }
+
+ /// GET_GUEST_CONFIG_PROPERTIES: Get multiple guest config properties
+ fn handle_get_guest_config_properties(
+ &self,
+ vmid: u32,
+ properties: &[String],
+ ) -> Result<Vec<u8>, IoError> {
+ // Convert Vec<String> to &[&str] for the impl function
+ let property_refs: Vec<&str> = properties.iter().map(|s| s.as_str()).collect();
+ self.handle_get_guest_config_properties_impl(&property_refs, vmid)
+ }
+
+ /// Core implementation for getting guest config properties
+ fn handle_get_guest_config_properties_impl(
+ &self,
+ properties: &[&str],
+ vmid: u32,
+ ) -> Result<Vec<u8>, IoError> {
+ // Validate vmid range
+ if vmid > 0 && vmid < 100 {
+ tracing::debug!("vmid out of range: {}", vmid);
+ return Err(IoError::from_raw_os_error(libc::EINVAL));
+ }
+
+ // Build response as a map: vmid -> {property -> value}
+ let mut response_map: serde_json::Map<String, serde_json::Value> = serde_json::Map::new();
+
+ if vmid >= 100 {
+ // Get specific VM
+ let vmlist = self.status.get_vmlist();
+
+ if !vmlist.contains_key(&vmid) {
+ return Err(IoError::from_raw_os_error(libc::ENOENT));
+ }
+
+ let vm_entry = vmlist.get(&vmid).unwrap();
+
+ // Get config path for this VM
+ let config_path = format!(
+ "nodes/{}/{}/{}.conf",
+ &vm_entry.node,
+ vm_entry.vmtype.config_dir(),
+ vmid
+ );
+
+ // Read config from memdb
+ match self.memdb.read(&config_path, 0, 1024 * 1024) {
+ Ok(config_data) => {
+ let config_str = String::from_utf8_lossy(&config_data);
+ let values = extract_properties(&config_str, properties);
+
+ if !values.is_empty() {
+ response_map
+ .insert(vmid.to_string(), serde_json::to_value(&values).unwrap());
+ }
+ }
+ Err(e) => {
+ tracing::debug!("Failed to read config for VM {}: {}", vmid, e);
+ return Err(IoError::from_raw_os_error(libc::EIO));
+ }
+ }
+ } else {
+ // vmid == 0: Get properties from all VMs
+ let vmlist = self.status.get_vmlist();
+
+ for (vm_id, vm_entry) in vmlist.iter() {
+ let config_path = format!(
+ "nodes/{}/{}/{}.conf",
+ &vm_entry.node,
+ vm_entry.vmtype.config_dir(),
+ vm_id
+ );
+
+ // Read config from memdb
+ if let Ok(config_data) = self.memdb.read(&config_path, 0, 1024 * 1024) {
+ let config_str = String::from_utf8_lossy(&config_data);
+ let values = extract_properties(&config_str, properties);
+
+ if !values.is_empty() {
+ response_map
+ .insert(vm_id.to_string(), serde_json::to_value(&values).unwrap());
+ }
+ }
+ }
+ }
+
+ // Serialize to JSON with pretty printing (matches C output format)
+ let json_str = serde_json::to_string_pretty(&response_map).map_err(|e| {
+ tracing::error!("Failed to serialize JSON: {}", e);
+ IoError::from_raw_os_error(libc::EIO)
+ })?;
+
+ Ok(json_str.into_bytes())
+ }
+}
+
+/// Extract property values from a VM config file
+///
+/// Parses config file line-by-line looking for "property: value" patterns.
+/// Matches the C implementation's parsing behavior from status.c:767-796.
+///
+/// Format: `^([a-z][a-z_]*\d*):\s*(.+?)\s*$`
+/// - Property name must start with lowercase letter
+/// - Followed by colon and optional whitespace
+/// - Value is trimmed of leading/trailing whitespace
+/// - Stops at snapshot sections (lines starting with '[')
+///
+/// Returns a map of property names to their values.
+fn extract_properties(
+ config: &str,
+ properties: &[&str],
+) -> std::collections::HashMap<String, String> {
+ let mut values = std::collections::HashMap::new();
+
+ // Parse config line by line
+ for line in config.lines() {
+ // Stop at snapshot or pending section markers (matches C implementation)
+ if line.starts_with('[') {
+ break;
+ }
+
+ // Skip empty lines
+ if line.is_empty() {
+ continue;
+ }
+
+ // Find colon separator (required in VM config format)
+ let Some(colon_pos) = line.find(':') else {
+ continue;
+ };
+
+ // Extract key (property name)
+ let key = &line[..colon_pos];
+
+ // Property must start with lowercase letter (matches C regex check)
+ if key.is_empty() || !key.chars().next().unwrap().is_ascii_lowercase() {
+ continue;
+ }
+
+ // Extract value after colon
+ let value = &line[colon_pos + 1..];
+
+ // Trim leading and trailing whitespace from value (matches C implementation)
+ let value = value.trim();
+
+ // Skip if value is empty after trimming
+ if value.is_empty() {
+ continue;
+ }
+
+ // Check if this is one of the requested properties
+ if properties.contains(&key) {
+ values.insert(key.to_string(), value.to_string());
+ }
+ }
+
+ values
+}
+
+#[async_trait]
+impl Handler for IpcHandler {
+ fn authenticate(&self, uid: u32, gid: u32) -> Option<Permissions> {
+ // Root with gid 0 gets read-write access
+ // Matches C: (uid == 0 && gid == 0) branch in server.c:111
+ if uid == 0 && gid == 0 {
+ tracing::debug!(
+ "IPC authentication: uid={}, gid={} - granted ReadWrite (root)",
+ uid,
+ gid
+ );
+ return Some(Permissions::ReadWrite);
+ }
+
+ // www-data group gets read-only access (regardless of uid)
+ // Matches C: (gid == cfs.gid) branch in server.c:111
+ if gid == self.www_data_gid {
+ tracing::debug!(
+ "IPC authentication: uid={}, gid={} - granted ReadOnly (www-data group)",
+ uid,
+ gid
+ );
+ return Some(Permissions::ReadOnly);
+ }
+
+ // Reject all other connections with security logging
+ tracing::warn!(
+ "IPC authentication failed: uid={}, gid={} - access denied (not root or www-data group)",
+ uid,
+ gid
+ );
+ None
+ }
+
+ async fn handle(&self, request: Request) -> Response {
+ // Deserialize IPC request from message ID and data
+ let ipc_request = match IpcRequest::deserialize(request.msg_id, &request.data) {
+ Ok(req) => req,
+ Err(e) => {
+ tracing::warn!(
+ "Failed to deserialize IPC request (msg_id={}): {}",
+ request.msg_id,
+ e
+ );
+ return Response::err(-libc::EINVAL);
+ }
+ };
+
+ let (error_code, data) = self.handle_request(ipc_request, request.is_read_only).await;
+
+ Response { error_code, data }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_extract_properties() {
+ let config = r#"
+# VM Configuration
+memory: 2048
+cores: 4
+sockets: 1
+cpu: host
+boot: order=scsi0;net0
+name: test-vm
+onboot: 1
+"#;
+
+ let properties = vec!["memory", "cores", "name", "nonexistent"];
+ let result = extract_properties(config, &properties);
+
+ assert_eq!(result.get("memory"), Some(&"2048".to_string()));
+ assert_eq!(result.get("cores"), Some(&"4".to_string()));
+ assert_eq!(result.get("name"), Some(&"test-vm".to_string()));
+ assert_eq!(result.get("nonexistent"), None);
+ }
+
+ #[test]
+ fn test_extract_properties_empty_config() {
+ let config = "";
+ let properties = vec!["memory"];
+ let result = extract_properties(config, &properties);
+ assert!(result.is_empty());
+ }
+
+ #[test]
+ fn test_extract_properties_stops_at_snapshot() {
+ let config = r#"
+memory: 2048
+cores: 4
+[snapshot]
+memory: 4096
+name: snapshot-value
+"#;
+ let properties = vec!["memory", "cores", "name"];
+ let result = extract_properties(config, &properties);
+
+ // Should stop at [snapshot] marker
+ assert_eq!(result.get("memory"), Some(&"2048".to_string()));
+ assert_eq!(result.get("cores"), Some(&"4".to_string()));
+ assert_eq!(result.get("name"), None); // After [snapshot], should not be parsed
+ }
+
+ #[test]
+ fn test_extract_properties_with_special_chars() {
+ let config = r#"
+name: test"vm
+description: Line1\nLine2
+path: /path/to\file
+"#;
+
+ let properties = vec!["name", "description", "path"];
+ let result = extract_properties(config, &properties);
+
+ assert_eq!(result.get("name"), Some(&r#"test"vm"#.to_string()));
+ assert_eq!(
+ result.get("description"),
+ Some(&r#"Line1\nLine2"#.to_string())
+ );
+ assert_eq!(result.get("path"), Some(&r#"/path/to\file"#.to_string()));
+ }
+
+ #[test]
+ fn test_extract_properties_whitespace_handling() {
+ let config = r#"
+memory: 2048
+cores:4
+name: test-vm
+"#;
+
+ let properties = vec!["memory", "cores", "name"];
+ let result = extract_properties(config, &properties);
+
+ // Values should be trimmed of leading/trailing whitespace
+ assert_eq!(result.get("memory"), Some(&"2048".to_string()));
+ assert_eq!(result.get("cores"), Some(&"4".to_string()));
+ assert_eq!(result.get("name"), Some(&"test-vm".to_string()));
+ }
+
+ #[test]
+ fn test_extract_properties_invalid_format() {
+ let config = r#"
+Memory: 2048
+CORES: 4
+_private: value
+123: value
+name value
+"#;
+
+ let properties = vec!["Memory", "CORES", "_private", "123", "name"];
+ let result = extract_properties(config, &properties);
+
+ // None should match because:
+ // - "Memory" starts with uppercase
+ // - "CORES" starts with uppercase
+ // - "_private" starts with underscore
+ // - "123" starts with digit
+ // - "name value" has no colon
+ assert!(result.is_empty());
+ }
+
+ #[test]
+ fn test_json_serialization_with_serde() {
+ // Verify that serde_json properly handles escaping
+ let mut values = std::collections::HashMap::new();
+ values.insert("name".to_string(), r#"test"vm"#.to_string());
+ values.insert("description".to_string(), "Line1\nLine2".to_string());
+
+ let json = serde_json::to_string(&values).unwrap();
+
+ // serde_json should properly escape quotes and newlines
+ assert!(json.contains(r#"\"test\\\"vm\""#) || json.contains(r#""test\"vm""#));
+ assert!(json.contains(r#"\n"#));
+ }
+
+ #[test]
+ fn test_json_pretty_format() {
+ // Verify pretty printing works
+ let mut response_map = serde_json::Map::new();
+ let mut vm_props = std::collections::HashMap::new();
+ vm_props.insert("memory".to_string(), "2048".to_string());
+ vm_props.insert("cores".to_string(), "4".to_string());
+
+ response_map.insert("100".to_string(), serde_json::to_value(&vm_props).unwrap());
+
+ let json_str = serde_json::to_string_pretty(&response_map).unwrap();
+
+ // Pretty format should have newlines
+ assert!(json_str.contains('\n'));
+ // Should contain the VM ID and properties
+ assert!(json_str.contains("100"));
+ assert!(json_str.contains("memory"));
+ assert!(json_str.contains("2048"));
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/lib.rs b/src/pmxcfs-rs/pmxcfs/src/lib.rs
new file mode 100644
index 000000000..06b77a38b
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/lib.rs
@@ -0,0 +1,13 @@
+// Library exports for testing and potential library usage
+
+pub mod cluster_config_service; // Cluster configuration monitoring via CMAP (matching C's confdb.c)
+pub mod daemon; // Unified daemon builder with integrated PID file management
+pub mod file_lock; // File locking utilities
+pub mod fuse;
+pub mod ipc; // IPC subsystem (request handling and service)
+pub mod logging; // Runtime-adjustable logging (for .debug plugin)
+pub mod memdb_callbacks; // DFSM callbacks for memdb (glue between dfsm and memdb)
+pub mod plugins;
+pub mod quorum_service; // Quorum tracking service (matching C's quorum.c)
+pub mod restart_flag; // Restart flag management
+pub mod status_callbacks; // DFSM callbacks for status kvstore (glue between dfsm and status)
diff --git a/src/pmxcfs-rs/pmxcfs/src/logging.rs b/src/pmxcfs-rs/pmxcfs/src/logging.rs
new file mode 100644
index 000000000..637aebb2b
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/logging.rs
@@ -0,0 +1,44 @@
+/// Runtime-adjustable logging infrastructure
+///
+/// This module provides the ability to change tracing filter levels at runtime,
+/// matching the C implementation's behavior where the .debug plugin can dynamically
+/// enable/disable debug logging.
+use anyhow::Result;
+use parking_lot::Mutex;
+use std::sync::OnceLock;
+use tracing_subscriber::{EnvFilter, reload};
+
+/// Type alias for the reload handle
+type ReloadHandle = reload::Handle<EnvFilter, tracing_subscriber::Registry>;
+
+/// Global reload handle for runtime log level adjustment
+static LOG_RELOAD_HANDLE: OnceLock<Mutex<ReloadHandle>> = OnceLock::new();
+
+/// Initialize the reload handle (called once during logging setup)
+pub fn set_reload_handle(handle: ReloadHandle) -> Result<()> {
+ LOG_RELOAD_HANDLE
+ .set(Mutex::new(handle))
+ .map_err(|_| anyhow::anyhow!("Failed to set log reload handle - already initialized"))
+}
+
+/// Set debug level at runtime (called by .debug plugin)
+///
+/// This changes the tracing filter to either "debug" (level > 0) or "info" (level == 0),
+/// matching the C implementation where writing to .debug affects cfs_debug() output.
+pub fn set_debug_level(level: u8) -> Result<()> {
+ let filter = if level > 0 {
+ EnvFilter::new("debug")
+ } else {
+ EnvFilter::new("info")
+ };
+
+ if let Some(handle) = LOG_RELOAD_HANDLE.get() {
+ handle
+ .lock()
+ .reload(filter)
+ .map_err(|e| anyhow::anyhow!("Failed to reload log filter: {e}"))?;
+ Ok(())
+ } else {
+ Err(anyhow::anyhow!("Log reload handle not initialized"))
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/main.rs b/src/pmxcfs-rs/pmxcfs/src/main.rs
new file mode 100644
index 000000000..106af97ba
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/main.rs
@@ -0,0 +1,711 @@
+use anyhow::{Context, Result};
+use clap::Parser;
+use std::fs;
+use std::sync::Arc;
+use tracing::{debug, error, info};
+use tracing_subscriber::{EnvFilter, layer::SubscriberExt, reload, util::SubscriberInitExt};
+
+use pmxcfs_rs::{
+ cluster_config_service::ClusterConfigService,
+ daemon::{Daemon, DaemonProcess},
+ file_lock::FileLock,
+ fuse,
+ ipc::IpcHandler,
+ memdb_callbacks::MemDbCallbacks,
+ plugins,
+ quorum_service::QuorumService,
+ restart_flag::RestartFlag,
+ status_callbacks::StatusCallbacks,
+};
+
+use pmxcfs_api_types::PmxcfsError;
+use pmxcfs_config::Config;
+use pmxcfs_dfsm::{
+ Callbacks, ClusterDatabaseService, Dfsm, FuseMessage, KvStoreMessage, StatusSyncService,
+};
+use pmxcfs_memdb::MemDb;
+use pmxcfs_services::ServiceManager;
+use pmxcfs_status as status;
+
+// Default paths matching the C version
+const DEFAULT_MOUNT_DIR: &str = "/etc/pve";
+const DEFAULT_DB_PATH: &str = "/var/lib/pve-cluster/config.db";
+const DEFAULT_VARLIB_DIR: &str = "/var/lib/pve-cluster";
+const DEFAULT_RUN_DIR: &str = "/run/pmxcfs";
+
+/// Type alias for the cluster services tuple
+type ClusterServices = (
+ Arc<Dfsm<FuseMessage>>,
+ Arc<Dfsm<KvStoreMessage>>,
+ Arc<QuorumService>,
+);
+
+/// Proxmox Cluster File System - Rust implementation
+///
+/// This FUSE filesystem uses corosync and sqlite3 to provide a
+/// cluster-wide, consistent view of config and other files.
+#[derive(Parser, Debug)]
+#[command(author, version, about, long_about = None)]
+struct Args {
+ /// Turn on debug messages
+ #[arg(short = 'd', long = "debug")]
+ debug: bool,
+
+ /// Do not daemonize server
+ #[arg(short = 'f', long = "foreground")]
+ foreground: bool,
+
+ /// Force local mode (ignore corosync.conf, force quorum)
+ #[arg(short = 'l', long = "local")]
+ local: bool,
+
+ /// Test directory (sets all paths to subdirectories for isolated testing)
+ #[arg(long = "test-dir")]
+ test_dir: Option<std::path::PathBuf>,
+
+ /// Custom mount point
+ #[arg(long = "mount", default_value = DEFAULT_MOUNT_DIR)]
+ mount: std::path::PathBuf,
+
+ /// Custom database path
+ #[arg(long = "db", default_value = DEFAULT_DB_PATH)]
+ db: std::path::PathBuf,
+
+ /// Custom runtime directory
+ #[arg(long = "rundir", default_value = DEFAULT_RUN_DIR)]
+ rundir: std::path::PathBuf,
+
+ /// Cluster name (CPG group name for Corosync isolation)
+ /// Must match C implementation's DCDB_CPG_GROUP_NAME
+ #[arg(long = "cluster-name", default_value = "pve_dcdb_v1")]
+ cluster_name: String,
+}
+
+/// Configuration for all filesystem paths used by pmxcfs
+#[derive(Debug, Clone)]
+struct PathConfig {
+ dbfilename: std::path::PathBuf,
+ lockfile: std::path::PathBuf,
+ restart_flag_file: std::path::PathBuf,
+ pid_file: std::path::PathBuf,
+ mount_dir: std::path::PathBuf,
+ varlib_dir: std::path::PathBuf,
+ run_dir: std::path::PathBuf,
+ pve2_socket_path: std::path::PathBuf, // IPC server socket (libqb-compatible)
+ corosync_conf_path: std::path::PathBuf,
+ rrd_dir: std::path::PathBuf,
+}
+
+impl PathConfig {
+ /// Create PathConfig from command line arguments
+ fn from_args(args: &Args) -> Self {
+ if let Some(ref test_dir) = args.test_dir {
+ // Test mode: all paths under test directory
+ Self {
+ dbfilename: test_dir.join("db/config.db"),
+ lockfile: test_dir.join("db/.pmxcfs.lockfile"),
+ restart_flag_file: test_dir.join("run/cfs-restart-flag"),
+ pid_file: test_dir.join("run/pmxcfs.pid"),
+ mount_dir: test_dir.join("pve"),
+ varlib_dir: test_dir.join("db"),
+ run_dir: test_dir.join("run"),
+ pve2_socket_path: test_dir.join("run/pve2"),
+ corosync_conf_path: test_dir.join("etc/corosync/corosync.conf"),
+ rrd_dir: test_dir.join("rrd"),
+ }
+ } else {
+ // Production mode: use provided args (which have defaults from clap)
+ let varlib_dir = args
+ .db
+ .parent()
+ .map(|p| p.to_path_buf())
+ .unwrap_or_else(|| std::path::PathBuf::from(DEFAULT_VARLIB_DIR));
+
+ Self {
+ dbfilename: args.db.clone(),
+ lockfile: varlib_dir.join(".pmxcfs.lockfile"),
+ restart_flag_file: args.rundir.join("cfs-restart-flag"),
+ pid_file: args.rundir.join("pmxcfs.pid"),
+ mount_dir: args.mount.clone(),
+ varlib_dir,
+ run_dir: args.rundir.clone(),
+ pve2_socket_path: std::path::PathBuf::from(DEFAULT_PVE2_SOCKET),
+ corosync_conf_path: std::path::PathBuf::from(HOST_CLUSTER_CONF_FN),
+ rrd_dir: std::path::PathBuf::from(DEFAULT_RRD_DIR),
+ }
+ }
+ }
+}
+
+const HOST_CLUSTER_CONF_FN: &str = "/etc/corosync/corosync.conf";
+
+const DEFAULT_RRD_DIR: &str = "/var/lib/rrdcached/db";
+const DEFAULT_PVE2_SOCKET: &str = "/var/run/pve2";
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ // Parse command line arguments
+ let args = Args::parse();
+
+ // Initialize logging
+ init_logging(args.debug)?;
+
+ // Create path configuration
+ let paths = PathConfig::from_args(&args);
+
+ info!("Starting pmxcfs (Rust version)");
+ debug!("Debug mode: {}", args.debug);
+ debug!("Foreground mode: {}", args.foreground);
+ debug!("Local mode: {}", args.local);
+
+ // Log test mode if enabled
+ if args.test_dir.is_some() {
+ info!("TEST MODE: Using isolated test directory");
+ info!(" Mount: {}", paths.mount_dir.display());
+ info!(" Database: {}", paths.dbfilename.display());
+ info!(" QB-IPC Socket: {}", paths.pve2_socket_path.display());
+ info!(" Run dir: {}", paths.run_dir.display());
+ info!(" RRD dir: {}", paths.rrd_dir.display());
+ }
+
+ // Get node name (equivalent to uname in C version)
+ let nodename = get_nodename()?;
+ info!("Node name: {}", nodename);
+
+ // Resolve node IP
+ let node_ip = resolve_node_ip(&nodename)?;
+ info!("Resolved node '{}' to IP '{}'", nodename, node_ip);
+
+ // Get www-data group ID
+ let www_data_gid = get_www_data_gid()?;
+ debug!("www-data group ID: {}", www_data_gid);
+
+ // Create configuration
+ let config = Config::shared(
+ nodename,
+ node_ip,
+ www_data_gid,
+ args.debug,
+ args.local,
+ args.cluster_name.clone(),
+ );
+
+ // Set umask (027 = rwxr-x---)
+ unsafe {
+ libc::umask(0o027);
+ }
+
+ // Create required directories
+ let is_test_mode = args.test_dir.is_some();
+ create_directories(www_data_gid, &paths, is_test_mode)?;
+
+ // Acquire lock
+ let _lock = FileLock::acquire(paths.lockfile.clone()).await?;
+
+ // Initialize status subsystem with config and RRD directory
+ // This allows get_local_nodename() to work properly by accessing config.nodename()
+ let status = status::init_with_config_and_rrd(config.clone(), &paths.rrd_dir).await;
+
+ // Check if database exists
+ let db_exists = paths.dbfilename.exists();
+
+ // Open or create database
+ let memdb = MemDb::open(&paths.dbfilename, !db_exists)?;
+
+ // Check for corosync.conf in database
+ let mut has_corosync_conf = memdb.exists("/corosync.conf")?;
+
+ // Import corosync.conf if it exists on disk but not in database and not in local mode
+ // This handles both new databases and existing databases that need the config imported
+ if !has_corosync_conf && !args.local {
+ // Try test-mode path first, then fall back to production path
+ // This matches C behavior and handles test environments where only some nodes
+ // have the test path set up (others use the shared /etc/corosync via volume)
+ let import_path = if paths.corosync_conf_path.exists() {
+ &paths.corosync_conf_path
+ } else {
+ std::path::Path::new(HOST_CLUSTER_CONF_FN)
+ };
+
+ if import_path.exists() {
+ import_corosync_conf(&memdb, import_path)?;
+ // Refresh the check after import
+ has_corosync_conf = memdb.exists("/corosync.conf")?;
+ }
+ }
+
+ // Initialize cluster services if needed (matching C's pmxcfs.c)
+ let (dfsm, status_dfsm, quorum_service) = if has_corosync_conf && !args.local {
+ info!("Initializing cluster services");
+ let (db_dfsm, st_dfsm, quorum) = setup_cluster_services(
+ &memdb,
+ config.clone(),
+ status.clone(),
+ &paths.corosync_conf_path,
+ )?;
+ (Some(db_dfsm), Some(st_dfsm), Some(quorum))
+ } else {
+ if args.local {
+ info!("Forcing local mode");
+ } else {
+ info!("Using local mode (corosync.conf does not exist)");
+ }
+ status.set_quorate(true);
+ (None, None, None)
+ };
+
+ // Initialize cluster info in status
+ status.init_cluster(config.cluster_name().to_string());
+
+ // Initialize plugin registry
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ // Note: Node registration from corosync is handled by ClusterConfigService during
+ // its initialization, matching C's service_confdb behavior (confdb.c:276)
+
+ // Daemonize if not in foreground mode (using builder pattern)
+ let (daemon_guard, signal_handle) = if !args.foreground {
+ let (process, handle) = Daemon::new()
+ .pid_file(paths.pid_file.clone())
+ .group(www_data_gid)
+ .start_daemon_with_signal()?;
+
+ match process {
+ DaemonProcess::Parent => {
+ // Parent exits here after child signals ready
+ std::process::exit(0);
+ }
+ DaemonProcess::Child(guard) => (Some(guard), handle),
+ }
+ } else {
+ (None, None)
+ };
+
+ // Mount FUSE filesystem
+ let fuse_task = setup_fuse(
+ &paths.mount_dir,
+ memdb.clone(),
+ config.clone(),
+ dfsm.clone(),
+ plugins,
+ status.clone(),
+ )?;
+
+ // Start cluster services using ServiceManager (matching C's pmxcfs.c service initialization)
+ // If this fails, abort the FUSE task to prevent orphaned mount
+ let service_manager_handle = match setup_services(
+ dfsm.as_ref(),
+ status_dfsm.as_ref(),
+ quorum_service,
+ has_corosync_conf,
+ args.local,
+ status.clone(),
+ ) {
+ Ok(handle) => handle,
+ Err(e) => {
+ error!("Failed to setup services: {}", e);
+ fuse_task.abort();
+ return Err(e);
+ }
+ };
+
+ // Scan VM list after database is loaded (matching C's memdb_open behavior)
+ status.scan_vmlist(&memdb);
+
+ // Setup signal handlers BEFORE starting IPC server to ensure signals are caught
+ // during the startup sequence. This prevents a race where a signal arriving
+ // between IPC start and signal handler setup would be missed.
+ use tokio::signal::unix::{SignalKind, signal};
+ let mut sigterm = signal(SignalKind::terminate())
+ .map_err(|e| anyhow::anyhow!("Failed to setup SIGTERM handler: {e}"))?;
+ let mut sigint = signal(SignalKind::interrupt())
+ .map_err(|e| anyhow::anyhow!("Failed to setup SIGINT handler: {e}"))?;
+
+ // Initialize and start IPC server (libqb-compatible IPC for C clients)
+ // If this fails, abort FUSE task to prevent orphaned mount
+ info!("Initializing IPC server (libqb-compatible)");
+ let ipc_handler = IpcHandler::new(memdb.clone(), status.clone(), config.clone(), www_data_gid);
+ let mut ipc_server = pmxcfs_ipc::Server::new("pve2", ipc_handler);
+ if let Err(e) = ipc_server.start() {
+ error!("Failed to start IPC server: {}", e);
+ fuse_task.abort();
+ return Err(e.into());
+ }
+
+ info!("pmxcfs started successfully");
+
+ // Signal parent if daemonized, or write PID file in foreground mode
+ let _pid_guard = if let Some(handle) = signal_handle {
+ // Daemon mode: signal parent that we're ready (parent writes PID file and exits)
+ handle.signal_ready()?;
+ daemon_guard // Keep guard alive for cleanup on drop
+ } else {
+ // Foreground mode: write PID file now and retain guard for cleanup
+ Some(
+ Daemon::new()
+ .pid_file(paths.pid_file.clone())
+ .group(www_data_gid)
+ .start_foreground()?,
+ )
+ };
+
+ // Remove restart flag (matching C's timing - after all services started)
+ let _ = fs::remove_file(&paths.restart_flag_file);
+
+ // Wait for shutdown signal (using pre-registered handlers)
+ tokio::select! {
+ _ = sigterm.recv() => {
+ info!("Received SIGTERM");
+ }
+ _ = sigint.recv() => {
+ info!("Received SIGINT");
+ }
+ }
+
+ info!("Shutting down pmxcfs");
+
+ // Abort background tasks
+ fuse_task.abort();
+
+ // Create restart flag (signals restart, not permanent shutdown)
+ let _restart_flag = RestartFlag::create(paths.restart_flag_file.clone(), www_data_gid);
+
+ // Stop services
+ ipc_server.stop();
+
+ // Stop cluster services via ServiceManager
+ if let Some(service_manager) = service_manager_handle {
+ info!("Shutting down cluster services via ServiceManager");
+ let _ = service_manager
+ .shutdown(std::time::Duration::from_secs(5))
+ .await;
+ }
+
+ // Unmount filesystem (matching C's fuse_unmount, using lazy unmount like umount -l)
+ info!(
+ "Unmounting FUSE filesystem from {}",
+ paths.mount_dir.display()
+ );
+ let mount_path_cstr =
+ std::ffi::CString::new(paths.mount_dir.to_string_lossy().as_ref()).unwrap();
+ unsafe {
+ libc::umount2(mount_path_cstr.as_ptr(), libc::MNT_DETACH);
+ }
+
+ info!("pmxcfs shutdown complete");
+
+ Ok(())
+}
+
+fn init_logging(debug: bool) -> Result<()> {
+ let filter_level = if debug { "debug" } else { "info" };
+ let filter = EnvFilter::new(filter_level);
+
+ // Create reloadable filter layer
+ let (filter_layer, reload_handle) = reload::Layer::new(filter);
+
+ // Create formatter layer for console output
+ let fmt_layer = tracing_subscriber::fmt::layer()
+ .with_target(false)
+ .with_thread_ids(false)
+ .with_thread_names(false);
+
+ // Try to connect to journald (systemd journal / syslog integration)
+ // Matches C implementation's openlog() call (status.c:1360)
+ // Falls back to console-only logging if journald is unavailable
+ let subscriber = tracing_subscriber::registry()
+ .with(filter_layer)
+ .with(fmt_layer);
+
+ match tracing_journald::layer() {
+ Ok(journald_layer) => {
+ // Successfully connected to journald
+ subscriber.with(journald_layer).init();
+ debug!("Logging to journald (syslog) enabled");
+ }
+ Err(e) => {
+ // Journald not available (e.g., not running under systemd)
+ // Continue with console logging only
+ subscriber.init();
+ debug!("Journald unavailable ({}), using console logging only", e);
+ }
+ }
+
+ // Store reload handle for runtime adjustment (used by .debug plugin)
+ pmxcfs_rs::logging::set_reload_handle(reload_handle)?;
+
+ Ok(())
+}
+
+fn get_nodename() -> Result<String> {
+ let mut utsname = libc::utsname {
+ sysname: [0; 65],
+ nodename: [0; 65],
+ release: [0; 65],
+ version: [0; 65],
+ machine: [0; 65],
+ domainname: [0; 65],
+ };
+
+ unsafe {
+ if libc::uname(&mut utsname) != 0 {
+ return Err(PmxcfsError::System("Unable to get node name".into()).into());
+ }
+ }
+
+ let nodename_bytes = &utsname.nodename;
+ let nodename_cstr = unsafe { std::ffi::CStr::from_ptr(nodename_bytes.as_ptr()) };
+ let mut nodename = nodename_cstr.to_string_lossy().to_string();
+
+ // Remove domain part if present (like C version)
+ if let Some(dot_pos) = nodename.find('.') {
+ nodename.truncate(dot_pos);
+ }
+
+ Ok(nodename)
+}
+
+fn resolve_node_ip(nodename: &str) -> Result<std::net::IpAddr> {
+ use std::net::ToSocketAddrs;
+
+ let addr_iter = (nodename, 0)
+ .to_socket_addrs()
+ .context("Failed to resolve node IP")?;
+
+ for addr in addr_iter {
+ let ip = addr.ip();
+ // Skip loopback addresses
+ if !ip.is_loopback() {
+ return Ok(ip);
+ }
+ }
+
+ Err(PmxcfsError::Configuration(format!(
+ "Unable to resolve node name '{nodename}' to a non-loopback IP address"
+ ))
+ .into())
+}
+
+fn get_www_data_gid() -> Result<u32> {
+ use users::get_group_by_name;
+
+ let group = get_group_by_name("www-data")
+ .ok_or_else(|| PmxcfsError::System("Unable to get www-data group".into()))?;
+
+ Ok(group.gid())
+}
+
+fn create_directories(gid: u32, paths: &PathConfig, is_test_mode: bool) -> Result<()> {
+ // Create varlib directory
+ fs::create_dir_all(&paths.varlib_dir)
+ .with_context(|| format!("Failed to create {}", paths.varlib_dir.display()))?;
+
+ // Create run directory
+ fs::create_dir_all(&paths.run_dir)
+ .with_context(|| format!("Failed to create {}", paths.run_dir.display()))?;
+
+ // Set ownership for run directory (skip in test mode - doesn't require root)
+ if !is_test_mode {
+ let run_dir_cstr =
+ std::ffi::CString::new(paths.run_dir.to_string_lossy().as_ref()).unwrap();
+ unsafe {
+ if libc::chown(run_dir_cstr.as_ptr(), 0, gid as libc::gid_t) != 0 {
+ return Err(PmxcfsError::System(format!(
+ "Failed to set ownership on {}",
+ paths.run_dir.display()
+ ))
+ .into());
+ }
+ }
+ }
+
+ Ok(())
+}
+
+fn import_corosync_conf(memdb: &MemDb, corosync_conf_path: &std::path::Path) -> Result<()> {
+ if let Ok(content) = fs::read_to_string(corosync_conf_path) {
+ info!("Importing corosync.conf from {}", corosync_conf_path.display());
+ let mtime = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ memdb.create("/corosync.conf", 0, 0, mtime)?;
+ memdb.write("/corosync.conf", 0, 0, mtime, content.as_bytes(), false)?;
+ }
+
+ Ok(())
+}
+
+/// Initialize cluster services (DFSM, QuorumService)
+///
+/// Returns (database_dfsm, status_dfsm, quorum_service) for cluster mode
+fn setup_cluster_services(
+ memdb: &MemDb,
+ config: Arc<Config>,
+ status: Arc<status::Status>,
+ corosync_conf_path: &std::path::Path,
+) -> Result<ClusterServices> {
+ // Sync corosync configuration
+ memdb.sync_corosync_conf(Some(corosync_conf_path.to_str().unwrap()), true)?;
+
+ // Create main DFSM for database synchronization (pmxcfs_v1 CPG group)
+ // Note: nodeid will be obtained via cpg_local_get() during init_cpg()
+ info!("Creating main DFSM instance (pmxcfs_v1)");
+ let database_callbacks = MemDbCallbacks::new(memdb.clone(), status.clone());
+ let database_dfsm = Arc::new(Dfsm::new(
+ config.cluster_name().to_string(),
+ database_callbacks.clone(),
+ )?);
+ database_callbacks.set_dfsm(&database_dfsm);
+ info!("Main DFSM created successfully");
+
+ // Create status DFSM for ephemeral data synchronization (pve_kvstore_v1 CPG group)
+ // Note: nodeid will be obtained via cpg_local_get() during init_cpg()
+ // IMPORTANT: Use protocol version 0 to match C implementation's kvstore DFSM
+ info!("Creating status DFSM instance (pve_kvstore_v1)");
+ let status_callbacks: Arc<dyn Callbacks<Message = KvStoreMessage>> =
+ Arc::new(StatusCallbacks::new(status.clone()));
+ let status_dfsm = Arc::new(Dfsm::new_with_protocol_version(
+ "pve_kvstore_v1".to_string(),
+ status_callbacks,
+ 0, // Protocol version 0 to match C's kvstore
+ )?);
+ info!("Status DFSM created successfully");
+
+ // Create QuorumService (owns quorum handle, matching C's service_quorum)
+ info!("Creating QuorumService");
+ let quorum_service = Arc::new(QuorumService::new(status));
+ info!("QuorumService created successfully");
+
+ Ok((database_dfsm, status_dfsm, quorum_service))
+}
+
+/// Setup and mount FUSE filesystem
+///
+/// Returns a task handle for the FUSE loop
+fn setup_fuse(
+ mount_path: &std::path::Path,
+ memdb: MemDb,
+ config: Arc<Config>,
+ dfsm: Option<Arc<Dfsm<FuseMessage>>>,
+ plugins: Arc<plugins::PluginRegistry>,
+ status: Arc<status::Status>,
+) -> Result<tokio::task::JoinHandle<()>> {
+ // Unmount if already mounted (matching C's umount2(CFSDIR, MNT_FORCE))
+ let mount_path_cstr = std::ffi::CString::new(mount_path.to_string_lossy().as_ref()).unwrap();
+ unsafe {
+ libc::umount2(mount_path_cstr.as_ptr(), libc::MNT_FORCE);
+ }
+
+ // Create mount directory
+ fs::create_dir_all(mount_path)
+ .with_context(|| format!("Failed to create mount point {}", mount_path.display()))?;
+
+ // Spawn FUSE filesystem in background task
+ let mount_path = mount_path.to_path_buf();
+ let fuse_task = tokio::spawn(async move {
+ if let Err(e) = fuse::mount_fuse(&mount_path, memdb, config, dfsm, plugins, status).await {
+ tracing::error!("FUSE filesystem error: {}", e);
+ }
+ });
+
+ Ok(fuse_task)
+}
+
+/// Setup cluster services (quorum, confdb, dcdb, status sync)
+///
+/// Returns a shutdown handle if services were started, None otherwise
+fn setup_services(
+ dfsm: Option<&Arc<Dfsm<FuseMessage>>>,
+ status_dfsm: Option<&Arc<Dfsm<KvStoreMessage>>>,
+ quorum_service: Option<Arc<pmxcfs_rs::quorum_service::QuorumService>>,
+ has_corosync_conf: bool,
+ force_local: bool,
+ status: Arc<status::Status>,
+) -> Result<Option<ServiceManagerHandle>> {
+ if dfsm.is_none() && status_dfsm.is_none() && quorum_service.is_none() {
+ return Ok(None);
+ }
+
+ let mut manager = ServiceManager::new();
+
+ // Add ClusterDatabaseService (service_dcdb equivalent)
+ if let Some(dfsm_instance) = dfsm {
+ info!("Adding ClusterDatabaseService to ServiceManager");
+ manager.add_service(Box::new(ClusterDatabaseService::new(Arc::clone(
+ dfsm_instance,
+ ))))?;
+ }
+
+ // Add StatusSyncService (service_status / kvstore equivalent)
+ if let Some(status_dfsm_instance) = status_dfsm {
+ info!("Adding StatusSyncService to ServiceManager");
+ manager.add_service(Box::new(StatusSyncService::new(Arc::clone(
+ status_dfsm_instance,
+ ))))?;
+ }
+
+ // Add ClusterConfigService (service_confdb equivalent) - monitors Corosync configuration
+ if has_corosync_conf && !force_local {
+ info!("Adding ClusterConfigService to ServiceManager");
+ manager.add_service(Box::new(ClusterConfigService::new(status)))?;
+ }
+
+ // Add QuorumService (service_quorum equivalent)
+ if let Some(quorum_instance) = quorum_service {
+ info!("Adding QuorumService to ServiceManager");
+ // Extract QuorumService from Arc - ServiceManager will manage it
+ match Arc::try_unwrap(quorum_instance) {
+ Ok(service) => {
+ manager.add_service(Box::new(service))?;
+ }
+ Err(_) => {
+ anyhow::bail!("Cannot unwrap QuorumService Arc - multiple references exist");
+ }
+ }
+ }
+
+ // Get shutdown token before spawning (for graceful shutdown)
+ let shutdown_token = manager.shutdown_token();
+
+ // Spawn ServiceManager in background task
+ let handle = manager.spawn();
+
+ Ok(Some(ServiceManagerHandle {
+ shutdown_token,
+ task: handle,
+ }))
+}
+
+/// Handle for managing ServiceManager lifecycle
+struct ServiceManagerHandle {
+ shutdown_token: tokio_util::sync::CancellationToken,
+ task: tokio::task::JoinHandle<()>,
+}
+
+impl ServiceManagerHandle {
+ /// Gracefully shutdown the ServiceManager with timeout
+ ///
+ /// Signals shutdown via cancellation token, then awaits task completion
+ /// with a timeout. Matches C's cfs_loop_stop_worker() behavior.
+ async fn shutdown(self, timeout: std::time::Duration) -> Result<()> {
+ // Signal graceful shutdown (matches C's stop_worker_flag)
+ self.shutdown_token.cancel();
+
+ // Await completion with timeout
+ match tokio::time::timeout(timeout, self.task).await {
+ Ok(Ok(())) => {
+ info!("ServiceManager shut down cleanly");
+ Ok(())
+ }
+ Ok(Err(e)) => {
+ tracing::warn!("ServiceManager task panicked: {}", e);
+ Err(anyhow::anyhow!("ServiceManager task panicked: {}", e))
+ }
+ Err(_) => {
+ tracing::warn!("ServiceManager shutdown timed out after {:?}", timeout);
+ Err(anyhow::anyhow!("ServiceManager shutdown timed out"))
+ }
+ }
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/memdb_callbacks.rs b/src/pmxcfs-rs/pmxcfs/src/memdb_callbacks.rs
new file mode 100644
index 000000000..02a4a317c
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/memdb_callbacks.rs
@@ -0,0 +1,663 @@
+/// DFSM callbacks implementation for memdb synchronization
+///
+/// This module implements the DfsmCallbacks trait to integrate the DFSM
+/// state machine with the memdb database for cluster-wide synchronization.
+use anyhow::{Context, Result};
+use parking_lot::RwLock;
+use std::sync::{Arc, Weak};
+use std::time::{SystemTime, UNIX_EPOCH};
+
+use pmxcfs_dfsm::{Callbacks, DfsmBroadcast, FuseMessage, NodeSyncInfo};
+use pmxcfs_memdb::{MemDb, MemDbIndex};
+
+/// DFSM callbacks for memdb synchronization
+pub struct MemDbCallbacks {
+ memdb: MemDb,
+ status: Arc<pmxcfs_status::Status>,
+ dfsm: RwLock<Weak<pmxcfs_dfsm::Dfsm<FuseMessage>>>,
+}
+
+impl MemDbCallbacks {
+ /// Create new callbacks for a memdb instance
+ pub fn new(memdb: MemDb, status: Arc<pmxcfs_status::Status>) -> Arc<Self> {
+ Arc::new(Self {
+ memdb,
+ status,
+ dfsm: RwLock::new(Weak::new()),
+ })
+ }
+
+ /// Set the DFSM instance (called after DFSM is created)
+ pub fn set_dfsm(&self, dfsm: &Arc<pmxcfs_dfsm::Dfsm<FuseMessage>>) {
+ *self.dfsm.write() = Arc::downgrade(dfsm);
+ }
+
+ /// Get the DFSM instance if available
+ fn get_dfsm(&self) -> Option<Arc<pmxcfs_dfsm::Dfsm<FuseMessage>>> {
+ self.dfsm.read().upgrade()
+ }
+
+ /// Update version counters based on path changes
+ /// Matches the C implementation's update_node_status_version logic
+ fn update_version_counters(&self, path: &str) {
+ // Trim leading slash but use FULL path for version tracking
+ let path = path.trim_start_matches('/');
+
+ // Update path-specific version counter (use full path, not just first component)
+ self.status.increment_path_version(path);
+
+ // Update vmlist version for VM configuration changes
+ if path.starts_with("qemu-server/") || path.starts_with("lxc/") {
+ self.status.increment_vmlist_version();
+ }
+ }
+}
+
+impl Callbacks for MemDbCallbacks {
+ type Message = FuseMessage;
+
+ /// Deliver an application message
+ /// Returns (message_result, processed) where processed indicates if message was handled
+ fn deliver_message(
+ &self,
+ nodeid: u32,
+ pid: u32,
+ fuse_message: FuseMessage,
+ timestamp: u64,
+ ) -> Result<(i32, bool)> {
+ // C-style delivery: ALL nodes (including originator) process messages
+ // No loopback check needed - the originator waits for this delivery
+ // and uses the result as the FUSE operation return value
+
+ tracing::debug!(
+ "MemDbCallbacks: delivering FUSE message from node {}/{} at timestamp {}",
+ nodeid,
+ pid,
+ timestamp
+ );
+
+ let mtime = timestamp as u32;
+
+ // Dispatch to dedicated handler for each message type
+ match fuse_message {
+ FuseMessage::Create { ref path } => {
+ let result = self.handle_create(path, mtime);
+ Ok((result, result >= 0))
+ }
+ FuseMessage::Mkdir { ref path } => {
+ let result = self.handle_mkdir(path, mtime);
+ Ok((result, result >= 0))
+ }
+ FuseMessage::Write {
+ ref path,
+ offset,
+ ref data,
+ } => {
+ let result = self.handle_write(path, offset, data, mtime);
+ Ok((result, result >= 0))
+ }
+ FuseMessage::Delete { ref path } => {
+ let result = self.handle_delete(path);
+ Ok((result, result >= 0))
+ }
+ FuseMessage::Rename { ref from, ref to } => {
+ let result = self.handle_rename(from, to);
+ Ok((result, result >= 0))
+ }
+ FuseMessage::Mtime { ref path, mtime: msg_mtime } => {
+ // Use mtime from message, not from timestamp (C: dcdb.c:900-901)
+ let result = self.handle_mtime(path, nodeid, msg_mtime);
+ Ok((result, result >= 0))
+ }
+ FuseMessage::UnlockRequest { path } => {
+ self.handle_unlock_request(path)?;
+ Ok((0, true))
+ }
+ FuseMessage::Unlock { path } => {
+ self.handle_unlock(path)?;
+ Ok((0, true))
+ }
+ }
+ }
+
+ /// Compute state checksum for verification
+ /// Should compute SHA-256 checksum of current state
+ fn compute_checksum(&self, output: &mut [u8; 32]) -> Result<()> {
+ tracing::debug!("MemDbCallbacks: computing database checksum");
+
+ let checksum = self
+ .memdb
+ .compute_database_checksum()
+ .context("Failed to compute database checksum")?;
+
+ output.copy_from_slice(&checksum);
+
+ tracing::debug!("MemDbCallbacks: checksum = {:016x?}", &checksum[..8]);
+ Ok(())
+ }
+
+ /// Get current state for synchronization
+ fn get_state(&self) -> Result<Vec<u8>> {
+ tracing::debug!("MemDbCallbacks: generating state for synchronization");
+
+ // Generate MemDbIndex from current database
+ let index = self
+ .memdb
+ .encode_index()
+ .context("Failed to encode database index")?;
+
+ // Serialize to wire format
+ let serialized = index.serialize();
+
+ tracing::info!(
+ "MemDbCallbacks: state generated - version={}, entries={}, bytes={}",
+ index.version,
+ index.size,
+ serialized.len()
+ );
+
+ Ok(serialized)
+ }
+
+ /// Process state update during synchronization
+ /// Called when all states have been collected from nodes
+ fn process_state_update(&self, states: &[NodeSyncInfo]) -> Result<bool> {
+ tracing::info!(
+ "MemDbCallbacks: processing state update from {} nodes",
+ states.len()
+ );
+
+ // Parse all indices from node states
+ let mut indices: Vec<(u32, u32, MemDbIndex)> = Vec::new();
+
+ for node in states {
+ if let Some(state_data) = &node.state {
+ match MemDbIndex::deserialize(state_data) {
+ Ok(index) => {
+ tracing::info!(
+ "MemDbCallbacks: node {}/{} - version={}, entries={}, mtime={}",
+ node.node_id,
+ node.pid,
+ index.version,
+ index.size,
+ index.mtime
+ );
+ indices.push((node.node_id, node.pid, index));
+ }
+ Err(e) => {
+ tracing::error!(
+ "MemDbCallbacks: failed to parse index from node {}/{}: {}",
+ node.node_id,
+ node.pid,
+ e
+ );
+ }
+ }
+ }
+ }
+
+ if indices.is_empty() {
+ tracing::warn!("MemDbCallbacks: no valid indices from any node");
+ return Ok(true);
+ }
+
+ // Find leader (highest version, or if tie, highest mtime)
+ // Matches C's dcdb_choose_leader_with_highest_index()
+ let mut leader_idx = 0;
+ for i in 1..indices.len() {
+ let (_, _, current_index) = &indices[i];
+ let (_, _, leader_index) = &indices[leader_idx];
+
+ if current_index > leader_index {
+ leader_idx = i;
+ }
+ }
+
+ let (leader_nodeid, leader_pid, leader_index) = &indices[leader_idx];
+ tracing::info!(
+ "MemDbCallbacks: elected leader: {}/{} (version={}, mtime={})",
+ leader_nodeid,
+ leader_pid,
+ leader_index.version,
+ leader_index.mtime
+ );
+
+ // Build list of synced nodes (those whose index matches leader exactly)
+ let mut synced_nodes = Vec::new();
+ for (nodeid, pid, index) in &indices {
+ // Check if indices are identical (same version, mtime, and all entries)
+ let is_synced = index.version == leader_index.version
+ && index.mtime == leader_index.mtime
+ && index.size == leader_index.size
+ && index.entries.len() == leader_index.entries.len()
+ && index
+ .entries
+ .iter()
+ .zip(leader_index.entries.iter())
+ .all(|(a, b)| a.inode == b.inode && a.digest == b.digest);
+
+ if is_synced {
+ synced_nodes.push((*nodeid, *pid));
+ tracing::info!(
+ "MemDbCallbacks: node {}/{} is synced with leader",
+ nodeid,
+ pid
+ );
+ } else {
+ tracing::info!("MemDbCallbacks: node {}/{} needs updates", nodeid, pid);
+ }
+ }
+
+ // Get DFSM instance to check if we're the leader
+ let dfsm = self.get_dfsm();
+
+ // Determine if WE are the leader
+ let we_are_leader = dfsm
+ .as_ref()
+ .map(|d| d.get_nodeid() == *leader_nodeid && d.get_pid() == *leader_pid)
+ .unwrap_or(false);
+
+ // Determine if WE are synced
+ let we_are_synced = dfsm
+ .as_ref()
+ .map(|d| {
+ let our_nodeid = d.get_nodeid();
+ let our_pid = d.get_pid();
+ synced_nodes
+ .iter()
+ .any(|(nid, pid)| *nid == our_nodeid && *pid == our_pid)
+ })
+ .unwrap_or(false);
+
+ if we_are_leader {
+ tracing::info!("MemDbCallbacks: we are the leader, sending updates to followers");
+
+ // Send updates to followers
+ if let Some(dfsm) = dfsm {
+ self.send_updates_to_followers(&dfsm, leader_index, &indices)?;
+ } else {
+ tracing::error!("MemDbCallbacks: cannot send updates - DFSM not available");
+ }
+
+ // Leader is always synced
+ Ok(true)
+ } else if we_are_synced {
+ tracing::info!("MemDbCallbacks: we are synced with leader");
+ Ok(true)
+ } else {
+ tracing::info!("MemDbCallbacks: we need updates from leader, entering Update mode");
+ Ok(false)
+ }
+ }
+
+ /// Process incremental update from leader
+ ///
+ /// Deserializes a TreeEntry from the wire format and applies it to the local database.
+ /// Matches C's dcdb_parse_update_inode() function.
+ fn process_update(&self, nodeid: u32, pid: u32, data: &[u8]) -> Result<()> {
+ tracing::debug!(
+ "MemDbCallbacks: processing update from {}/{} ({} bytes)",
+ nodeid,
+ pid,
+ data.len()
+ );
+
+ // Deserialize TreeEntry from C wire format
+ let tree_entry = pmxcfs_memdb::TreeEntry::deserialize_from_update(data)
+ .context("Failed to deserialize TreeEntry from update message")?;
+
+ tracing::info!(
+ "MemDbCallbacks: received update for inode {} ({}), version={}",
+ tree_entry.inode,
+ tree_entry.name,
+ tree_entry.version
+ );
+
+ // Apply the entry to our local database
+ self.memdb
+ .apply_tree_entry(tree_entry)
+ .context("Failed to apply TreeEntry to database")?;
+
+ tracing::debug!("MemDbCallbacks: update applied successfully");
+ Ok(())
+ }
+
+ /// Commit synchronized state
+ fn commit_state(&self) -> Result<()> {
+ tracing::info!("MemDbCallbacks: committing synchronized state");
+ // Database commits are automatic in our implementation
+
+ // Increment all path versions to notify clients of database reload
+ // Matches C's record_memdb_reload() called in database.c:607
+ self.status.increment_all_path_versions();
+
+ // Recreate VM list after database changes (matching C's bdb_backend_commit_update)
+ // This ensures VM list is updated whenever the cluster database is synchronized
+ self.status.scan_vmlist(&self.memdb);
+
+ Ok(())
+ }
+
+ /// Called when cluster becomes synced
+ fn on_synced(&self) {
+ tracing::info!("MemDbCallbacks: cluster is now fully synchronized");
+ }
+}
+
+// Helper methods for MemDbCallbacks (not part of trait)
+impl MemDbCallbacks {
+ /// Handle Create message - create an empty file
+ /// Returns 0 on success, negative errno on failure
+ fn handle_create(&self, path: &str, mtime: u32) -> i32 {
+ match self.memdb.create(path, 0, 0, mtime) {
+ Ok(_) => {
+ tracing::info!("MemDbCallbacks: created file '{}'", path);
+ self.update_version_counters(path);
+ 0
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to create '{}': {}", path, e);
+ -libc::EACCES
+ }
+ }
+ }
+
+ /// Handle Mkdir message - create a directory
+ /// Returns 0 on success, negative errno on failure
+ fn handle_mkdir(&self, path: &str, mtime: u32) -> i32 {
+ match self.memdb.create(path, libc::S_IFDIR, 0, mtime) {
+ Ok(_) => {
+ tracing::info!("MemDbCallbacks: created directory '{}'", path);
+ self.update_version_counters(path);
+ 0
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to mkdir '{}': {}", path, e);
+ -libc::EACCES
+ }
+ }
+ }
+
+ /// Handle Write message - write data to a file
+ /// Returns 0 on success, negative errno on failure
+ fn handle_write(&self, path: &str, offset: u64, data: &[u8], mtime: u32) -> i32 {
+ // Create file if it doesn't exist
+ if let Err(e) = self.memdb.exists(path) {
+ tracing::warn!("MemDbCallbacks: failed to check if '{}' exists: {}", path, e);
+ return -libc::EIO;
+ }
+
+ if !self.memdb.exists(path).unwrap_or(false) {
+ if let Err(e) = self.memdb.create(path, 0, 0, mtime) {
+ tracing::warn!("MemDbCallbacks: failed to create '{}': {}", path, e);
+ return -libc::EACCES;
+ }
+ }
+
+ // Write data
+ if !data.is_empty() {
+ match self.memdb.write(path, offset, 0, mtime, data, false) {
+ Ok(_) => {
+ tracing::info!(
+ "MemDbCallbacks: wrote {} bytes to '{}' at offset {}",
+ data.len(),
+ path,
+ offset
+ );
+ self.update_version_counters(path);
+ 0
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to write to '{}': {}", path, e);
+ -libc::EACCES
+ }
+ }
+ } else {
+ 0
+ }
+ }
+
+ /// Handle Delete message - delete a file or directory
+ /// Returns 0 on success, negative errno on failure
+ fn handle_delete(&self, path: &str) -> i32 {
+ match self.memdb.exists(path) {
+ Ok(exists) if exists => match self.memdb.delete(path, 0, SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as u32) {
+ Ok(_) => {
+ tracing::info!("MemDbCallbacks: deleted '{}'", path);
+ self.update_version_counters(path);
+ 0
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to delete '{}': {}", path, e);
+ -libc::EACCES
+ }
+ },
+ Ok(_) => {
+ tracing::debug!("MemDbCallbacks: path '{}' already deleted", path);
+ 0 // Not an error - already deleted
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to check if '{}' exists: {}", path, e);
+ -libc::EIO
+ }
+ }
+ }
+
+ /// Handle Rename message - rename a file or directory
+ /// Returns 0 on success, negative errno on failure
+ fn handle_rename(&self, from: &str, to: &str) -> i32 {
+ match self.memdb.exists(from) {
+ Ok(exists) if exists => match self.memdb.rename(from, to, 0, SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as u32) {
+ Ok(_) => {
+ tracing::info!("MemDbCallbacks: renamed '{}' to '{}'", from, to);
+ self.update_version_counters(from);
+ self.update_version_counters(to);
+ 0
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to rename '{}' to '{}': {}", from, to, e);
+ -libc::EACCES
+ }
+ },
+ Ok(_) => {
+ tracing::debug!("MemDbCallbacks: source path '{}' not found for rename", from);
+ -libc::ENOENT
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to check if '{}' exists: {}", from, e);
+ -libc::EIO
+ }
+ }
+ }
+
+ /// Handle Mtime message - update modification time
+ /// Returns 0 on success, negative errno on failure
+ fn handle_mtime(&self, path: &str, nodeid: u32, mtime: u32) -> i32 {
+ match self.memdb.exists(path) {
+ Ok(exists) if exists => match self.memdb.set_mtime(path, nodeid, mtime) {
+ Ok(_) => {
+ tracing::info!(
+ "MemDbCallbacks: updated mtime for '{}' from node {}",
+ path,
+ nodeid
+ );
+ self.update_version_counters(path);
+ 0
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to update mtime for '{}': {}", path, e);
+ -libc::EACCES
+ }
+ },
+ Ok(_) => {
+ tracing::debug!("MemDbCallbacks: path '{}' not found for mtime update", path);
+ -libc::ENOENT
+ }
+ Err(e) => {
+ tracing::warn!("MemDbCallbacks: failed to check if '{}' exists: {}", path, e);
+ -libc::EIO
+ }
+ }
+ }
+
+ /// Handle UnlockRequest message - check if lock expired and broadcast Unlock if needed
+ ///
+ /// Only the leader processes unlock requests (C: dcdb.c:830-838)
+ fn handle_unlock_request(&self, path: String) -> Result<()> {
+ tracing::debug!("MemDbCallbacks: processing unlock request for: {}", path);
+
+ // Only the leader (lowest nodeid) should process unlock requests
+ if let Some(dfsm) = self.get_dfsm() {
+ if !dfsm.is_leader() {
+ tracing::debug!("Not leader, ignoring unlock request for: {}", path);
+ return Ok(());
+ }
+ } else {
+ tracing::warn!("DFSM not available, cannot process unlock request");
+ return Ok(());
+ }
+
+ // Get the lock entry to compute checksum
+ if let Some(entry) = self.memdb.lookup_path(&path)
+ && entry.is_dir()
+ && pmxcfs_memdb::is_lock_path(&path)
+ {
+ let csum = entry.compute_checksum();
+
+ // Check if lock expired (C: dcdb.c:834)
+ if self.memdb.lock_expired(&path, &csum) {
+ tracing::info!("Lock expired, sending unlock message for: {}", path);
+ // Send Unlock message to cluster (C: dcdb.c:836)
+ self.get_dfsm().broadcast(FuseMessage::Unlock { path: path.clone() });
+ } else {
+ tracing::debug!("Lock not expired for: {}", path);
+ }
+ }
+
+ Ok(())
+ }
+
+ /// Handle Unlock message - delete an expired lock
+ ///
+ /// This is broadcast by the leader when a lock expires (C: dcdb.c:834)
+ fn handle_unlock(&self, path: String) -> Result<()> {
+ tracing::info!("MemDbCallbacks: processing unlock message for: {}", path);
+
+ // Delete the lock directory
+ if let Err(e) = self.memdb.delete(&path, 0, SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as u32) {
+ tracing::warn!("Failed to delete lock {}: {}", path, e);
+ } else {
+ tracing::info!("Successfully deleted lock: {}", path);
+ self.update_version_counters(&path);
+ }
+
+ Ok(())
+ }
+
+ /// Send updates to followers (leader only)
+ ///
+ /// Compares the leader index with each follower and sends Update messages
+ /// for entries that differ. Matches C's dcdb_create_and_send_updates().
+ fn send_updates_to_followers(
+ &self,
+ dfsm: &pmxcfs_dfsm::Dfsm<FuseMessage>,
+ leader_index: &MemDbIndex,
+ all_indices: &[(u32, u32, MemDbIndex)],
+ ) -> Result<()> {
+ use std::collections::HashSet;
+
+ // Collect all inodes that need updating across all followers
+ let mut inodes_to_update: HashSet<u64> = HashSet::new();
+ let mut any_follower_needs_updates = false;
+
+ for (_nodeid, _pid, follower_index) in all_indices {
+ // Skip if this is us (the leader) - check if indices are identical
+ // Must match the same check in process_state_update()
+ let is_synced = follower_index.version == leader_index.version
+ && follower_index.mtime == leader_index.mtime
+ && follower_index.size == leader_index.size
+ && follower_index.entries.len() == leader_index.entries.len();
+
+ if is_synced {
+ continue;
+ }
+
+ // This follower needs updates
+ any_follower_needs_updates = true;
+
+ // Find differences between leader and this follower
+ let diffs = leader_index.find_differences(follower_index);
+ tracing::debug!(
+ "MemDbCallbacks: found {} differing inodes for follower",
+ diffs.len()
+ );
+ inodes_to_update.extend(diffs);
+ }
+
+ // If no follower needs updates at all, we're done
+ if !any_follower_needs_updates {
+ tracing::info!("MemDbCallbacks: no updates needed, all nodes are synced");
+ dfsm.send_update_complete()?;
+ return Ok(());
+ }
+
+ tracing::info!(
+ "MemDbCallbacks: sending updates ({} differing entries)",
+ inodes_to_update.len()
+ );
+
+ // Send Update message for each differing inode
+ // IMPORTANT: Do NOT send the root directory entry (inode ROOT_INODE)!
+ // C uses inode 0 for root and never stores it in the database.
+ // The root exists only in memory and is recreated on database reload.
+ // Only send regular files and directories (inode > ROOT_INODE).
+ let mut sent_count = 0;
+ for inode in inodes_to_update {
+ // Skip root - it should never be sent as an UPDATE
+ if inode == pmxcfs_memdb::ROOT_INODE {
+ tracing::debug!("MemDbCallbacks: skipping root entry (inode {})", inode);
+ continue;
+ }
+
+ // Look up the TreeEntry for this inode
+ match self.memdb.get_entry_by_inode(inode) {
+ Some(tree_entry) => {
+ tracing::info!(
+ "MemDbCallbacks: sending UPDATE for inode {:#018x} (name='{}', parent={:#018x}, type={}, version={}, size={})",
+ inode,
+ tree_entry.name,
+ tree_entry.parent,
+ tree_entry.entry_type,
+ tree_entry.version,
+ tree_entry.size
+ );
+
+ if let Err(e) = dfsm.send_update(tree_entry) {
+ tracing::error!(
+ "MemDbCallbacks: failed to send update for inode {}: {}",
+ inode,
+ e
+ );
+ // Continue sending other updates even if one fails
+ } else {
+ sent_count += 1;
+ }
+ }
+ None => {
+ tracing::error!(
+ "MemDbCallbacks: cannot find TreeEntry for inode {} in database",
+ inode
+ );
+ }
+ }
+ }
+
+ tracing::info!("MemDbCallbacks: sent {} updates", sent_count);
+
+ // Send UpdateComplete to signal end of updates
+ dfsm.send_update_complete()?;
+ tracing::info!("MemDbCallbacks: sent UpdateComplete");
+
+ Ok(())
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/README.md b/src/pmxcfs-rs/pmxcfs/src/plugins/README.md
new file mode 100644
index 000000000..53b0249cb
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/README.md
@@ -0,0 +1,203 @@
+# PMXCFS Plugin System
+
+## Overview
+
+The plugin system provides dynamic virtual files in the `/etc/pve` filesystem that generate content on-the-fly. These files provide cluster status, configuration, and monitoring data.
+
+## Plugin Types
+
+### Function Plugins
+
+These plugins generate dynamic content when read:
+
+- `.version` - Cluster version and status information
+- `.members` - Cluster membership information
+- `.vmlist` - List of VMs and containers
+- `.rrd` - Round-robin database dump
+- `.clusterlog` - Cluster log entries
+- `.debug` - Debug mode toggle
+
+### Symlink Plugins
+
+These plugins create symlinks to node-specific directories:
+
+- `local/` → `nodes/{nodename}/`
+- `qemu-server/` → `nodes/{nodename}/qemu-server/`
+- `lxc/` → `nodes/{nodename}/lxc/`
+- `openvz/` → `nodes/{nodename}/openvz/` (legacy)
+
+## Plugin File Formats
+
+### .version Plugin
+
+**Format**: JSON
+
+**Fields**:
+- `api` - API version (integer)
+- `clinfo` - Cluster info version (integer)
+- `cluster` - Cluster information object
+ - `name` - Cluster name (string)
+ - `nodes` - Number of nodes (integer)
+ - `quorate` - Quorum status (1 or 0)
+- `starttime` - Daemon start time (Unix timestamp)
+- `version` - Software version (string)
+- `vmlist` - VM list version (integer)
+
+**Example**:
+```json
+{
+ "api": 1,
+ "clinfo": 2,
+ "cluster": {
+ "name": "pmxcfs",
+ "nodes": 3,
+ "quorate": 1
+ },
+ "starttime": 1699876543,
+ "version": "9.0.6",
+ "vmlist": 5
+}
+```
+
+### .members Plugin
+
+**Format**: JSON with sections
+
+**Fields**:
+- `cluster` - Cluster information object
+ - `name` - Cluster name (string)
+ - `version` - Cluster version (integer)
+ - `nodes` - Number of nodes (integer)
+ - `quorate` - Quorum status (1 or 0)
+- `nodelist` - Array of node objects
+ - `id` - Node ID (integer)
+ - `name` - Node name (string)
+ - `online` - Online status (1 or 0)
+ - `ip` - Node IP address (string)
+
+**Example**:
+```json
+{
+ "cluster": {
+ "name": "pmxcfs",
+ "version": 2,
+ "nodes": 3,
+ "quorate": 1
+ },
+ "nodelist": [
+ {
+ "id": 1,
+ "name": "node1",
+ "online": 1,
+ "ip": "192.168.1.10"
+ },
+ {
+ "id": 2,
+ "name": "node2",
+ "online": 1,
+ "ip": "192.168.1.11"
+ },
+ {
+ "id": 3,
+ "name": "node3",
+ "online": 0,
+ "ip": "192.168.1.12"
+ }
+ ]
+}
+```
+
+### .vmlist Plugin
+
+**Format**: INI-style with sections
+
+**Sections**:
+- `[qemu]` - QEMU/KVM virtual machines
+- `[lxc]` - Linux containers
+
+**Entry Format**: `VMID<TAB>NODE<TAB>VERSION`
+- `VMID` - VM/container ID (integer)
+- `NODE` - Node name where the VM is defined (string)
+- `VERSION` - Configuration version (integer)
+
+**Example**:
+```
+[qemu]
+100 node1 2
+101 node2 1
+
+[lxc]
+200 node1 1
+201 node3 2
+```
+
+### .rrd Plugin
+
+**Format**: Text format with schema-based key-value pairs (one per line)
+
+**Line Format**: `{schema}/{id}:{timestamp}:{field1}:{field2}:...`
+- `schema` - RRD schema name (e.g., `pve-node-9.0`, `pve-vm-9.0`, `pve-storage-9.0`)
+- `id` - Resource identifier (node name, VMID, or storage name)
+- `timestamp` - Unix timestamp
+- `fields` - Colon-separated metric values
+
+Schemas include node metrics, VM metrics, and storage metrics with appropriate fields for each type.
+
+### .clusterlog Plugin
+
+**Format**: JSON with data array
+
+**Fields**:
+- `data` - Array of log entry objects
+ - `time` - Unix timestamp (integer)
+ - `node` - Node name (string)
+ - `priority` - Syslog priority (integer)
+ - `ident` - Process identifier (string)
+ - `tag` - Log tag (string)
+ - `message` - Log message (string)
+
+**Example**:
+```json
+{
+ "data": [
+ {
+ "time": 1699876543,
+ "node": "node1",
+ "priority": 6,
+ "ident": "pvedaemon",
+ "tag": "task",
+ "message": "Started VM 100"
+ }
+ ]
+}
+```
+
+### .debug Plugin
+
+**Format**: Plain text (single character)
+
+**Values**:
+- `0` - Debug mode disabled
+- `1` - Debug mode enabled
+
+**Behavior**:
+- Reading returns current debug state
+- Writing `1` enables debug logging
+- Writing `0` disables debug logging
+
+## Implementation Details
+
+### Registry
+
+The plugin registry (`registry.rs`) maintains all plugin definitions and handles lookups.
+
+### Plugin Trait
+
+All plugins implement a common trait that defines:
+- `get_content()` - Generate plugin content
+- `set_content()` - Handle writes (for `.debug` plugin)
+- `get_attr()` - Return file attributes
+
+### Integration with FUSE
+
+Plugins are integrated into the FUSE filesystem layer and appear as regular files in `/etc/pve`.
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/clusterlog.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/clusterlog.rs
new file mode 100644
index 000000000..d9fd59c44
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/clusterlog.rs
@@ -0,0 +1,293 @@
+/// .clusterlog Plugin - Cluster Log Entries
+///
+/// This plugin provides cluster log entries in JSON format matching C implementation:
+/// ```json
+/// {
+/// "data": [
+/// {"uid": 1, "time": 1234567890, "pri": 6, "tag": "cluster", "pid": 0, "node": "node1", "user": "root", "msg": "starting cluster log"}
+/// ]
+/// }
+/// ```
+///
+/// The format is compatible with the C implementation which uses clog_dump_json
+/// to write JSON data to clients.
+///
+/// Default max_entries: 50 (matching C implementation)
+use pmxcfs_status::Status;
+use serde_json::json;
+use std::sync::Arc;
+
+use super::Plugin;
+
+/// Clusterlog plugin - provides cluster log entries
+pub struct ClusterlogPlugin {
+ status: Arc<Status>,
+ max_entries: usize,
+}
+
+impl ClusterlogPlugin {
+ pub fn new(status: Arc<Status>) -> Self {
+ Self {
+ status,
+ max_entries: 50,
+ }
+ }
+
+ /// Create with custom entry limit
+ #[allow(dead_code)] // Used in tests for custom entry limits
+ pub fn new_with_limit(status: Arc<Status>, max_entries: usize) -> Self {
+ Self {
+ status,
+ max_entries,
+ }
+ }
+
+ /// Generate clusterlog content (C-compatible JSON format)
+ fn generate_content(&self) -> String {
+ let entries = self.status.get_log_entries(self.max_entries);
+
+ // Convert to JSON format matching C implementation
+ // C format: {"data": [{"uid": ..., "time": ..., "pri": ..., "tag": ..., "pid": ..., "node": ..., "user": ..., "msg": ...}]}
+ let data: Vec<_> = entries
+ .iter()
+ .enumerate()
+ .map(|(idx, entry)| {
+ json!({
+ "uid": idx + 1, // Sequential ID starting from 1
+ "time": entry.timestamp, // Unix timestamp
+ "pri": entry.priority, // Priority level (numeric)
+ "tag": entry.tag, // Tag field
+ "pid": 0, // Process ID (we don't track this, set to 0)
+ "node": entry.node, // Node name
+ "user": entry.ident, // User/ident field
+ "msg": entry.message // Log message
+ })
+ })
+ .collect();
+
+ let result = json!({
+ "data": data
+ });
+
+ // Convert to JSON string with formatting
+ serde_json::to_string_pretty(&result).unwrap_or_else(|_| "{}".to_string())
+ }
+}
+
+impl Plugin for ClusterlogPlugin {
+ fn name(&self) -> &str {
+ ".clusterlog"
+ }
+
+ fn read(&self) -> anyhow::Result<Vec<u8>> {
+ Ok(self.generate_content().into_bytes())
+ }
+
+ fn mode(&self) -> u32 {
+ 0o440
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use pmxcfs_status as status;
+ use std::time::{SystemTime, UNIX_EPOCH};
+
+ /// Test helper: add a log message to the cluster log
+ fn add_log_message(
+ status: &status::Status,
+ node: String,
+ priority: u8,
+ ident: String,
+ tag: String,
+ message: String,
+ ) {
+ let timestamp = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap()
+ .as_secs();
+ let entry = status::ClusterLogEntry {
+ uid: 0,
+ timestamp,
+ priority,
+ tag,
+ pid: 0,
+ node,
+ ident,
+ message,
+ };
+ status.add_log_entry(entry);
+ }
+
+ #[tokio::test]
+ async fn test_clusterlog_format() {
+ // Initialize status subsystem without RRD persistence (not needed for test)
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = status::init_with_config(config);
+
+ // Test that it returns valid JSON
+ let plugin = ClusterlogPlugin::new(status);
+ let result = plugin.generate_content();
+
+ // Should be valid JSON
+ assert!(
+ serde_json::from_str::<serde_json::Value>(&result).is_ok(),
+ "Should return valid JSON"
+ );
+ }
+
+ #[tokio::test]
+ async fn test_clusterlog_with_entries() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = status::init_with_config(config);
+
+ // Clear any existing log entries from other tests
+ status.clear_cluster_log();
+
+ // Add some log entries
+ add_log_message(
+ &status,
+ "node1".to_string(),
+ 6, // Info priority
+ "pmxcfs".to_string(),
+ "cluster".to_string(),
+ "Node joined cluster".to_string(),
+ );
+
+ add_log_message(
+ &status,
+ "node2".to_string(),
+ 4, // Warning priority
+ "pvestatd".to_string(),
+ "status".to_string(),
+ "High load detected".to_string(),
+ );
+
+ // Get clusterlog
+ let plugin = ClusterlogPlugin::new(status);
+ let result = plugin.generate_content();
+
+ // Parse JSON
+ let json: serde_json::Value = serde_json::from_str(&result).expect("Should be valid JSON");
+
+ // Verify structure
+ assert!(json.get("data").is_some(), "Should have 'data' field");
+ let data = json["data"].as_array().expect("data should be array");
+
+ // Should have at least 2 entries
+ assert!(data.len() >= 2, "Should have at least 2 entries");
+
+ // Verify first entry has all required fields
+ let first_entry = &data[0];
+ assert!(first_entry.get("uid").is_some(), "Should have uid");
+ assert!(first_entry.get("time").is_some(), "Should have time");
+ assert!(first_entry.get("pri").is_some(), "Should have pri");
+ assert!(first_entry.get("tag").is_some(), "Should have tag");
+ assert!(first_entry.get("pid").is_some(), "Should have pid");
+ assert!(first_entry.get("node").is_some(), "Should have node");
+ assert!(first_entry.get("user").is_some(), "Should have user");
+ assert!(first_entry.get("msg").is_some(), "Should have msg");
+
+ // Verify uid starts at 1
+ assert_eq!(
+ first_entry["uid"].as_u64().unwrap(),
+ 1,
+ "First uid should be 1"
+ );
+ }
+
+ #[tokio::test]
+ async fn test_clusterlog_entry_limit() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = status::init_with_config(config);
+
+ // Add 10 log entries
+ for i in 0..10 {
+ add_log_message(
+ &status,
+ format!("node{i}"),
+ 6,
+ "test".to_string(),
+ "test".to_string(),
+ format!("Test message {i}"),
+ );
+ }
+
+ // Request only 5 entries
+ let plugin = ClusterlogPlugin::new_with_limit(status, 5);
+ let result = plugin.generate_content();
+ let json: serde_json::Value = serde_json::from_str(&result).unwrap();
+ let data = json["data"].as_array().unwrap();
+
+ // Should have at most 5 entries
+ assert!(data.len() <= 5, "Should respect entry limit");
+ }
+
+ #[tokio::test]
+ async fn test_clusterlog_field_types() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = status::init_with_config(config);
+
+ add_log_message(
+ &status,
+ "testnode".to_string(),
+ 5,
+ "testident".to_string(),
+ "testtag".to_string(),
+ "Test message content".to_string(),
+ );
+
+ let plugin = ClusterlogPlugin::new(status);
+ let result = plugin.generate_content();
+ let json: serde_json::Value = serde_json::from_str(&result).unwrap();
+ let data = json["data"].as_array().unwrap();
+
+ if let Some(entry) = data.first() {
+ // uid should be number
+ assert!(entry["uid"].is_u64(), "uid should be number");
+
+ // time should be number
+ assert!(entry["time"].is_u64(), "time should be number");
+
+ // pri should be number
+ assert!(entry["pri"].is_u64(), "pri should be number");
+
+ // tag should be string
+ assert!(entry["tag"].is_string(), "tag should be string");
+ assert_eq!(entry["tag"].as_str().unwrap(), "testtag");
+
+ // pid should be number (0)
+ assert!(entry["pid"].is_u64(), "pid should be number");
+ assert_eq!(entry["pid"].as_u64().unwrap(), 0);
+
+ // node should be string
+ assert!(entry["node"].is_string(), "node should be string");
+ assert_eq!(entry["node"].as_str().unwrap(), "testnode");
+
+ // user should be string
+ assert!(entry["user"].is_string(), "user should be string");
+ assert_eq!(entry["user"].as_str().unwrap(), "testident");
+
+ // msg should be string
+ assert!(entry["msg"].is_string(), "msg should be string");
+ assert_eq!(entry["msg"].as_str().unwrap(), "Test message content");
+ }
+ }
+
+ #[tokio::test]
+ async fn test_clusterlog_empty() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = status::init_with_config(config);
+
+ // Get clusterlog without any entries (or clear existing ones)
+ let plugin = ClusterlogPlugin::new_with_limit(status, 0);
+ let result = plugin.generate_content();
+ let json: serde_json::Value = serde_json::from_str(&result).unwrap();
+
+ // Should have data field with empty array
+ assert!(json.get("data").is_some());
+ let data = json["data"].as_array().unwrap();
+ assert_eq!(data.len(), 0, "Should have empty data array");
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/debug.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/debug.rs
new file mode 100644
index 000000000..a8e2c8851
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/debug.rs
@@ -0,0 +1,145 @@
+/// .debug Plugin - Debug Level Control
+///
+/// This plugin provides read/write access to debug settings, matching the C implementation.
+/// Format: "0\n" or "1\n" (debug level as text)
+///
+/// When written, this actually changes the tracing filter level at runtime,
+/// matching the C implementation's behavior where cfs.debug controls cfs_debug() macro output.
+use anyhow::Result;
+use pmxcfs_config::Config;
+use std::sync::Arc;
+
+use super::Plugin;
+
+/// Debug plugin - provides debug level control
+pub struct DebugPlugin {
+ config: Arc<Config>,
+}
+
+impl DebugPlugin {
+ pub fn new(config: Arc<Config>) -> Self {
+ Self { config }
+ }
+
+ /// Generate debug setting content (read operation)
+ fn generate_content(&self) -> String {
+ let level = self.config.debug_level();
+ format!("{level}\n")
+ }
+
+ /// Handle debug plugin write operation
+ ///
+ /// This changes the tracing filter level at runtime to match C implementation behavior.
+ /// In C, writing to .debug sets cfs.debug which controls cfs_debug() macro output.
+ fn handle_write(&self, data: &str) -> Result<()> {
+ let level: u8 = data
+ .trim()
+ .parse()
+ .map_err(|_| anyhow::anyhow!("Invalid debug level: must be a number"))?;
+
+ // Update debug level in config
+ self.config.set_debug_level(level);
+
+ // Actually change the tracing filter level at runtime
+ // This matches C implementation where cfs.debug controls logging
+ if let Err(e) = crate::logging::set_debug_level(level) {
+ tracing::error!("Failed to update log level: {}", e);
+ // Don't fail - just log error. The level is still stored.
+ }
+
+ if level > 0 {
+ tracing::info!("Debug mode enabled (level {})", level);
+ tracing::debug!("Debug logging is now active");
+ } else {
+ tracing::info!("Debug mode disabled");
+ }
+
+ Ok(())
+ }
+}
+
+impl Plugin for DebugPlugin {
+ fn name(&self) -> &str {
+ ".debug"
+ }
+
+ fn read(&self) -> anyhow::Result<Vec<u8>> {
+ Ok(self.generate_content().into_bytes())
+ }
+
+ fn write(&self, data: &[u8]) -> Result<()> {
+ let text = std::str::from_utf8(data)?;
+ self.handle_write(text)
+ }
+
+ fn mode(&self) -> u32 {
+ 0o640
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_debug_read() {
+ let config = Arc::new(Config::new(
+ "test".to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 33,
+ false,
+ false,
+ "pmxcfs".to_string(),
+ ));
+ let plugin = DebugPlugin::new(config);
+ let result = plugin.generate_content();
+ assert_eq!(result, "0\n");
+ }
+
+ #[test]
+ fn test_debug_write() {
+ let config = Arc::new(Config::new(
+ "test".to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 33,
+ false,
+ false,
+ "pmxcfs".to_string(),
+ ));
+
+ let plugin = DebugPlugin::new(config.clone());
+ let result = plugin.handle_write("1");
+ // Note: This will fail to actually change the log level if the reload handle
+ // hasn't been initialized (which is expected in unit tests without full setup).
+ // The function should still succeed - it just warns about not being able to reload.
+ assert!(result.is_ok());
+
+ // Verify the stored level changed
+ assert_eq!(config.debug_level(), 1);
+
+ // Test setting it back to 0
+ let result = plugin.handle_write("0");
+ assert!(result.is_ok());
+ assert_eq!(config.debug_level(), 0);
+ }
+
+ #[test]
+ fn test_invalid_debug_level() {
+ let config = Arc::new(Config::new(
+ "test".to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 33,
+ false,
+ false,
+ "pmxcfs".to_string(),
+ ));
+
+ let plugin = DebugPlugin::new(config.clone());
+
+ let result = plugin.handle_write("invalid");
+ assert!(result.is_err());
+
+ let result = plugin.handle_write("");
+ assert!(result.is_err());
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/members.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/members.rs
new file mode 100644
index 000000000..6a584a45f
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/members.rs
@@ -0,0 +1,198 @@
+/// .members Plugin - Cluster Member Information
+///
+/// This plugin provides information about cluster members in JSON format:
+/// {
+/// "nodename": "node1",
+/// "version": 5,
+/// "cluster": {
+/// "name": "mycluster",
+/// "version": 1,
+/// "nodes": 3,
+/// "quorate": 1
+/// },
+/// "nodelist": {
+/// "node1": { "id": 1, "online": 1, "ip": "192.168.1.10" },
+/// "node2": { "id": 2, "online": 1, "ip": "192.168.1.11" }
+/// }
+/// }
+use pmxcfs_config::Config;
+use pmxcfs_status::Status;
+use serde_json::json;
+use std::sync::Arc;
+
+use super::Plugin;
+
+/// Members plugin - provides cluster member information
+pub struct MembersPlugin {
+ config: Arc<Config>,
+ status: Arc<Status>,
+}
+
+impl MembersPlugin {
+ pub fn new(config: Arc<Config>, status: Arc<Status>) -> Self {
+ Self { config, status }
+ }
+
+ /// Generate members information content
+ fn generate_content(&self) -> String {
+ let nodename = self.config.nodename();
+ let cluster_name = self.config.cluster_name();
+
+ // Get cluster info from status (matches C's cfs_status access)
+ let cluster_info = self.status.get_cluster_info();
+ let cluster_version = self.status.get_cluster_version();
+
+ // Get quorum status and members from status
+ let quorate = self.status.is_quorate();
+
+ // Get cluster members (for online status tracking)
+ let members = self.status.get_members();
+
+ // Create a set of online node IDs from current members
+ let mut online_nodes = std::collections::HashSet::new();
+ for member in &members {
+ online_nodes.insert(member.node_id);
+ }
+
+ // Count unique nodes
+ let node_count = online_nodes.len();
+
+ // Build nodelist from cluster_info
+ let mut nodelist = serde_json::Map::new();
+
+ if let Some(cluster_info) = cluster_info {
+ // Add all registered nodes to nodelist
+ for (name, node_id) in &cluster_info.nodes_by_name {
+ if let Some(node) = cluster_info.nodes_by_id.get(node_id) {
+ let is_online = online_nodes.contains(&node.node_id);
+ let node_info = json!({
+ "id": node.node_id,
+ "online": if is_online { 1 } else { 0 },
+ "ip": node.ip
+ });
+ nodelist.insert(name.clone(), node_info);
+ }
+ }
+
+ // Build the complete response
+ let response = json!({
+ "nodename": nodename,
+ "version": cluster_version,
+ "cluster": {
+ "name": cluster_info.cluster_name,
+ "version": 1, // Cluster format version (always 1)
+ "nodes": node_count.max(1), // At least 1 (ourselves)
+ "quorate": if quorate { 1 } else { 0 }
+ },
+ "nodelist": nodelist
+ });
+
+ response.to_string()
+ } else {
+ // No cluster info yet, return minimal response with just local node
+ let node_info = json!({
+ "id": 0, // Unknown ID
+ "online": 1, // Assume online since we're running
+ "ip": self.config.node_ip()
+ });
+
+ let mut nodelist = serde_json::Map::new();
+ nodelist.insert(nodename.to_string(), node_info);
+
+ let response = json!({
+ "nodename": nodename,
+ "version": cluster_version,
+ "cluster": {
+ "name": cluster_name,
+ "version": 1,
+ "nodes": 1,
+ "quorate": if quorate { 1 } else { 0 }
+ },
+ "nodelist": nodelist
+ });
+
+ response.to_string()
+ }
+ }
+}
+
+impl Plugin for MembersPlugin {
+ fn name(&self) -> &str {
+ ".members"
+ }
+
+ fn read(&self) -> anyhow::Result<Vec<u8>> {
+ Ok(self.generate_content().into_bytes())
+ }
+
+ fn mode(&self) -> u32 {
+ 0o440
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[tokio::test]
+ async fn test_members_format() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ let config = Arc::new(Config::new(
+ "testnode".to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 33,
+ false,
+ false,
+ "testcluster".to_string(),
+ ));
+
+ // Initialize cluster
+ status.init_cluster("testcluster".to_string());
+
+ let plugin = MembersPlugin::new(config, status);
+ let result = plugin.generate_content();
+ let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
+
+ // Should have nodename
+ assert_eq!(parsed["nodename"], "testnode");
+
+ // Should have version
+ assert!(parsed["version"].is_number());
+
+ // Should have cluster info
+ assert_eq!(parsed["cluster"]["name"], "testcluster");
+ assert!(parsed["cluster"]["nodes"].is_number());
+ assert!(parsed["cluster"]["quorate"].is_number());
+
+ // Should have nodelist (might be empty without actual cluster members)
+ assert!(parsed["nodelist"].is_object());
+ }
+
+ #[tokio::test]
+ async fn test_members_no_cluster() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ let config = Arc::new(Config::new(
+ "standalone".to_string(),
+ "192.168.1.100".parse().unwrap(),
+ 33,
+ false,
+ false,
+ "testcluster".to_string(),
+ ));
+
+ // Don't set cluster info - should still work
+ let plugin = MembersPlugin::new(config, status);
+ let result = plugin.generate_content();
+ let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
+
+ // Should have minimal response
+ assert_eq!(parsed["nodename"], "standalone");
+ assert!(parsed["cluster"].is_object());
+ assert!(parsed["nodelist"].is_object());
+ assert!(parsed["nodelist"]["standalone"].is_object());
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/mod.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/mod.rs
new file mode 100644
index 000000000..9af9f8024
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/mod.rs
@@ -0,0 +1,30 @@
+/// Plugin system for special files and dynamic content
+///
+/// This module implements plugins for:
+/// - func: Dynamic files generated by callbacks (.version, .members, etc.)
+/// - link: Symbolic links
+///
+/// Each plugin is implemented in its own source file:
+/// - version.rs: .version plugin - cluster version information
+/// - members.rs: .members plugin - cluster member list
+/// - vmlist.rs: .vmlist plugin - VM/CT list
+/// - rrd.rs: .rrd plugin - system metrics
+/// - clusterlog.rs: .clusterlog plugin - cluster log entries
+/// - debug.rs: .debug plugin - debug level control
+mod clusterlog;
+mod debug;
+mod members;
+mod registry;
+mod rrd;
+mod types;
+mod version;
+mod vmlist;
+
+// Re-export core types (only Plugin trait is used outside this module)
+pub use types::Plugin;
+
+// Re-export registry
+pub use registry::{PluginRegistry, init_plugins};
+
+#[cfg(test)]
+pub use registry::init_plugins_for_test;
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/registry.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/registry.rs
new file mode 100644
index 000000000..425af9d2e
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/registry.rs
@@ -0,0 +1,305 @@
+/// Plugin registry and initialization
+use parking_lot::RwLock;
+use std::collections::HashMap;
+use std::sync::Arc;
+
+use super::clusterlog::ClusterlogPlugin;
+use super::debug::DebugPlugin;
+use super::members::MembersPlugin;
+use super::rrd::RrdPlugin;
+use super::types::{LinkPlugin, Plugin};
+use super::version::VersionPlugin;
+use super::vmlist::VmlistPlugin;
+
+/// Plugin registry
+pub struct PluginRegistry {
+ plugins: RwLock<HashMap<String, Arc<dyn Plugin>>>,
+}
+
+impl Default for PluginRegistry {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl PluginRegistry {
+ pub fn new() -> Self {
+ Self {
+ plugins: RwLock::new(HashMap::new()),
+ }
+ }
+
+ /// Register a plugin
+ pub fn register(&self, plugin: Arc<dyn Plugin>) {
+ let name = plugin.name().to_string();
+ self.plugins.write().insert(name, plugin);
+ }
+
+ /// Get a plugin by name
+ pub fn get(&self, name: &str) -> Option<Arc<dyn Plugin>> {
+ self.plugins.read().get(name).cloned()
+ }
+
+ /// Check if a path is a plugin
+ pub fn is_plugin(&self, name: &str) -> bool {
+ self.plugins.read().contains_key(name)
+ }
+
+ /// List all plugin names
+ pub fn list(&self) -> Vec<String> {
+ self.plugins.read().keys().cloned().collect()
+ }
+}
+
+/// Initialize the plugin registry with default plugins
+pub fn init_plugins(
+ config: Arc<pmxcfs_config::Config>,
+ status: Arc<pmxcfs_status::Status>,
+) -> Arc<PluginRegistry> {
+ tracing::info!("Initializing plugin system for node: {}", config.nodename());
+
+ let registry = Arc::new(PluginRegistry::new());
+
+ // .version - cluster version information
+ let version_plugin = Arc::new(VersionPlugin::new(config.clone(), status.clone()));
+ registry.register(version_plugin);
+
+ // .members - cluster member list
+ let members_plugin = Arc::new(MembersPlugin::new(config.clone(), status.clone()));
+ registry.register(members_plugin);
+
+ // .vmlist - VM list
+ let vmlist_plugin = Arc::new(VmlistPlugin::new(status.clone()));
+ registry.register(vmlist_plugin);
+
+ // .rrd - RRD data
+ let rrd_plugin = Arc::new(RrdPlugin::new(status.clone()));
+ registry.register(rrd_plugin);
+
+ // .clusterlog - cluster log
+ let clusterlog_plugin = Arc::new(ClusterlogPlugin::new(status.clone()));
+ registry.register(clusterlog_plugin);
+
+ // .debug - debug settings (read/write)
+ let debug_plugin = Arc::new(DebugPlugin::new(config.clone()));
+ registry.register(debug_plugin);
+
+ // Symbolic link plugins - point to nodes/{nodename}/ subdirectories
+ // These provide convenient access to node-specific directories from the root
+ let nodename = config.nodename();
+
+ // local -> nodes/{nodename}/local
+ let local_link = Arc::new(LinkPlugin::new("local", format!("nodes/{nodename}")));
+ registry.register(local_link);
+
+ // qemu-server -> nodes/{nodename}/qemu-server
+ let qemu_link = Arc::new(LinkPlugin::new(
+ "qemu-server",
+ format!("nodes/{nodename}/qemu-server"),
+ ));
+ registry.register(qemu_link);
+
+ // openvz -> nodes/{nodename}/openvz (legacy support)
+ let openvz_link = Arc::new(LinkPlugin::new(
+ "openvz",
+ format!("nodes/{nodename}/openvz"),
+ ));
+ registry.register(openvz_link);
+
+ // lxc -> nodes/{nodename}/lxc
+ let lxc_link = Arc::new(LinkPlugin::new("lxc", format!("nodes/{nodename}/lxc")));
+ registry.register(lxc_link);
+
+ tracing::info!(
+ "Registered {} plugins ({} func plugins, 4 link plugins)",
+ registry.list().len(),
+ registry.list().len() - 4
+ );
+
+ registry
+}
+
+#[cfg(test)]
+/// Test-only helper to create a plugin registry with a simple nodename
+pub fn init_plugins_for_test(nodename: &str) -> Arc<PluginRegistry> {
+ use pmxcfs_config::Config;
+
+ // Create config with the specified nodename for testing
+ let config = Config::shared(
+ nodename.to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 33, // www-data gid
+ false,
+ false,
+ "pmxcfs".to_string(),
+ );
+ let status = pmxcfs_status::init_with_config(config.clone());
+
+ init_plugins(config, status)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_registry_func_plugins_exist() {
+ let registry = init_plugins_for_test("testnode");
+
+ let func_plugins = vec![
+ ".version",
+ ".members",
+ ".vmlist",
+ ".rrd",
+ ".clusterlog",
+ ".debug",
+ ];
+
+ for plugin_name in func_plugins {
+ assert!(
+ registry.is_plugin(plugin_name),
+ "{plugin_name} should be registered"
+ );
+
+ let plugin = registry.get(plugin_name);
+ assert!(plugin.is_some(), "{plugin_name} should be accessible");
+ assert_eq!(plugin.unwrap().name(), plugin_name);
+ }
+ }
+
+ #[test]
+ fn test_registry_link_plugins_exist() {
+ let registry = init_plugins_for_test("testnode");
+
+ let link_plugins = vec!["local", "qemu-server", "openvz", "lxc"];
+
+ for plugin_name in link_plugins {
+ assert!(
+ registry.is_plugin(plugin_name),
+ "{plugin_name} link should be registered"
+ );
+
+ let plugin = registry.get(plugin_name);
+ assert!(plugin.is_some(), "{plugin_name} link should be accessible");
+ assert_eq!(plugin.unwrap().name(), plugin_name);
+ }
+ }
+
+ #[test]
+ fn test_registry_link_targets_use_nodename() {
+ // Test with different nodenames
+ let test_cases = vec![
+ ("node1", "nodes/node1"),
+ ("pve-test", "nodes/pve-test"),
+ ("cluster-node-03", "nodes/cluster-node-03"),
+ ];
+
+ for (nodename, expected_local_target) in test_cases {
+ let registry = init_plugins_for_test(nodename);
+
+ // Test local link
+ let local = registry.get("local").expect("local link should exist");
+ let data = local.read().expect("should read link target");
+ let target = String::from_utf8(data).expect("target should be UTF-8");
+ assert_eq!(
+ target, expected_local_target,
+ "local link should point to nodes/{nodename} for {nodename}"
+ );
+
+ // Test qemu-server link
+ let qemu = registry
+ .get("qemu-server")
+ .expect("qemu-server link should exist");
+ let data = qemu.read().expect("should read link target");
+ let target = String::from_utf8(data).expect("target should be UTF-8");
+ assert_eq!(
+ target,
+ format!("nodes/{nodename}/qemu-server"),
+ "qemu-server link should include nodename"
+ );
+
+ // Test lxc link
+ let lxc = registry.get("lxc").expect("lxc link should exist");
+ let data = lxc.read().expect("should read link target");
+ let target = String::from_utf8(data).expect("target should be UTF-8");
+ assert_eq!(
+ target,
+ format!("nodes/{nodename}/lxc"),
+ "lxc link should include nodename"
+ );
+
+ // Test openvz link (legacy)
+ let openvz = registry.get("openvz").expect("openvz link should exist");
+ let data = openvz.read().expect("should read link target");
+ let target = String::from_utf8(data).expect("target should be UTF-8");
+ assert_eq!(
+ target,
+ format!("nodes/{nodename}/openvz"),
+ "openvz link should include nodename"
+ );
+ }
+ }
+
+ #[test]
+ fn test_registry_nonexistent_plugin() {
+ let registry = init_plugins_for_test("testnode");
+
+ assert!(!registry.is_plugin(".nonexistent"));
+ assert!(registry.get(".nonexistent").is_none());
+ }
+
+ #[test]
+ fn test_registry_plugin_modes() {
+ let registry = init_plugins_for_test("testnode");
+
+ // .debug should be writable (0o640)
+ let debug = registry.get(".debug").expect(".debug should exist");
+ assert_eq!(debug.mode(), 0o640, ".debug should have writable mode");
+
+ // All other func plugins should be read-only (0o440)
+ let readonly_plugins = vec![".version", ".members", ".vmlist", ".rrd", ".clusterlog"];
+ for plugin_name in readonly_plugins {
+ let plugin = registry.get(plugin_name).unwrap();
+ assert_eq!(plugin.mode(), 0o440, "{plugin_name} should be read-only");
+ }
+
+ // Link plugins should have 0o777
+ let links = vec!["local", "qemu-server", "openvz", "lxc"];
+ for link_name in links {
+ let link = registry.get(link_name).unwrap();
+ assert_eq!(link.mode(), 0o777, "{link_name} should have 777 mode");
+ }
+ }
+
+ #[test]
+ fn test_link_plugins_are_symlinks() {
+ let registry = init_plugins_for_test("testnode");
+
+ // Link plugins should be identified as symlinks
+ let link_plugins = vec!["local", "qemu-server", "openvz", "lxc"];
+ for link_name in link_plugins {
+ let link = registry.get(link_name).unwrap();
+ assert!(
+ link.is_symlink(),
+ "{link_name} should be identified as a symlink"
+ );
+ }
+
+ // Func plugins should NOT be identified as symlinks
+ let func_plugins = vec![
+ ".version",
+ ".members",
+ ".vmlist",
+ ".rrd",
+ ".clusterlog",
+ ".debug",
+ ];
+ for plugin_name in func_plugins {
+ let plugin = registry.get(plugin_name).unwrap();
+ assert!(
+ !plugin.is_symlink(),
+ "{plugin_name} should NOT be identified as a symlink"
+ );
+ }
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/rrd.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/rrd.rs
new file mode 100644
index 000000000..406b76727
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/rrd.rs
@@ -0,0 +1,97 @@
+/// .rrd Plugin - RRD (Round-Robin Database) Metrics
+///
+/// This plugin provides system metrics in text format matching C implementation:
+/// ```text
+/// pve2-node/nodename:timestamp:uptime:loadavg:maxcpu:cpu:iowait:memtotal:memused:...
+/// pve2.3-vm/100:timestamp:status:uptime:...
+/// ```
+///
+/// The format is compatible with the C implementation which uses rrd_update
+/// to write data to RRD files on disk.
+///
+/// Data aging: Entries older than 5 minutes are automatically removed.
+use pmxcfs_status::Status;
+use std::sync::Arc;
+
+use super::Plugin;
+
+/// RRD plugin - provides system metrics
+pub struct RrdPlugin {
+ status: Arc<Status>,
+}
+
+impl RrdPlugin {
+ pub fn new(status: Arc<Status>) -> Self {
+ Self { status }
+ }
+
+ /// Generate RRD content (C-compatible text format)
+ fn generate_content(&self) -> String {
+ // Get RRD dump in text format from status module
+ // Format: "key:data\n" for each entry
+ // The status module handles data aging (removes entries >5 minutes old)
+ self.status.get_rrd_dump()
+ }
+}
+
+impl Plugin for RrdPlugin {
+ fn name(&self) -> &str {
+ ".rrd"
+ }
+
+ fn read(&self) -> anyhow::Result<Vec<u8>> {
+ Ok(self.generate_content().into_bytes())
+ }
+
+ fn mode(&self) -> u32 {
+ 0o440
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[tokio::test]
+ async fn test_rrd_empty() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ let plugin = RrdPlugin::new(status);
+ let result = plugin.generate_content();
+ // Empty RRD data should return just NUL terminator (C compatibility)
+ assert_eq!(result, "\0");
+ }
+
+ #[tokio::test]
+ async fn test_rrd_with_data() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ // Add some RRD data with proper schema
+ // Note: RRD file creation will fail (no rrdcached in tests), but in-memory storage works
+ // Node RRD (pve2 format): timestamp + 12 values
+ // (loadavg, maxcpu, cpu, iowait, memtotal, memused, swaptotal, swapused, roottotal, rootused, netin, netout)
+ let _ = status.set_rrd_data(
+ "pve2-node/testnode".to_string(),
+ "1234567890:0.5:4:1.2:0.25:8000000000:4000000000:2000000000:100000000:10000000000:5000000000:1000000:500000".to_string(),
+ ).await; // May fail if rrdcached not running, but in-memory storage succeeds
+
+ // VM RRD (pve2.3 format): timestamp + 10 values
+ // (maxcpu, cpu, maxmem, mem, maxdisk, disk, netin, netout, diskread, diskwrite)
+ let _ = status
+ .set_rrd_data(
+ "pve2.3-vm/100".to_string(),
+ "1234567890:4:2.5:4096:2048:100000:50000:1000000:500000:10000:5000".to_string(),
+ )
+ .await; // May fail if rrdcached not running, but in-memory storage succeeds
+
+ let plugin = RrdPlugin::new(status);
+ let result = plugin.generate_content();
+
+ // Should contain both entries (from in-memory storage)
+ assert!(result.contains("pve2-node/testnode"));
+ assert!(result.contains("pve2.3-vm/100"));
+ assert!(result.contains("1234567890"));
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/types.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/types.rs
new file mode 100644
index 000000000..fb013b1a2
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/types.rs
@@ -0,0 +1,112 @@
+/// Core plugin types and trait definitions
+use anyhow::Result;
+
+/// Plugin trait for special file handlers
+///
+/// Note: We can't use `const NAME: &'static str` as an associated constant because
+/// it would make the trait not object-safe (dyn Plugin wouldn't work). Instead,
+/// each implementation provides the name via the name() method.
+pub trait Plugin: Send + Sync {
+ /// Get plugin name
+ fn name(&self) -> &str;
+
+ /// Read content from this plugin
+ fn read(&self) -> Result<Vec<u8>>;
+
+ /// Write content to this plugin (if supported)
+ fn write(&self, _data: &[u8]) -> Result<()> {
+ Err(anyhow::anyhow!("Write not supported for this plugin"))
+ }
+
+ /// Get file mode
+ fn mode(&self) -> u32;
+
+ /// Check if this is a symbolic link
+ fn is_symlink(&self) -> bool {
+ false
+ }
+}
+
+/// Link plugin - symbolic links
+pub struct LinkPlugin {
+ name: &'static str,
+ target: String,
+}
+
+impl LinkPlugin {
+ pub fn new(name: &'static str, target: impl Into<String>) -> Self {
+ Self {
+ name,
+ target: target.into(),
+ }
+ }
+}
+
+impl Plugin for LinkPlugin {
+ fn name(&self) -> &str {
+ self.name
+ }
+
+ fn read(&self) -> Result<Vec<u8>> {
+ Ok(self.target.as_bytes().to_vec())
+ }
+
+ fn mode(&self) -> u32 {
+ 0o777 // Symbolic links
+ }
+
+ fn is_symlink(&self) -> bool {
+ true
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ // ===== LinkPlugin Tests =====
+
+ #[test]
+ fn test_link_plugin_creation() {
+ let plugin = LinkPlugin::new("testlink", "/target/path");
+ assert_eq!(plugin.name(), "testlink");
+ assert!(plugin.is_symlink());
+ }
+
+ #[test]
+ fn test_link_plugin_read_target() {
+ let target = "/path/to/target";
+ let plugin = LinkPlugin::new("mylink", target);
+
+ let result = plugin.read().unwrap();
+ assert_eq!(result, target.as_bytes());
+ }
+
+ #[test]
+ fn test_link_plugin_mode() {
+ let plugin = LinkPlugin::new("link", "/target");
+ assert_eq!(
+ plugin.mode(),
+ 0o777,
+ "Symbolic links should have mode 0o777"
+ );
+ }
+
+ #[test]
+ fn test_link_plugin_write_not_supported() {
+ let plugin = LinkPlugin::new("readonly", "/target");
+ let result = plugin.write(b"test data");
+
+ assert!(result.is_err(), "LinkPlugin should not support write");
+ assert!(result.unwrap_err().to_string().contains("not supported"));
+ }
+
+ #[test]
+ fn test_link_plugin_with_unicode_target() {
+ let target = "/path/with/üñïçödé/target";
+ let plugin = LinkPlugin::new("unicode", target);
+
+ let result = plugin.read().unwrap();
+ assert_eq!(String::from_utf8(result).unwrap(), target);
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/version.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/version.rs
new file mode 100644
index 000000000..bf3ab5874
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/version.rs
@@ -0,0 +1,178 @@
+/// .version Plugin - Cluster Version Information
+///
+/// This plugin provides comprehensive version information in JSON format:
+/// {
+/// "starttime": 1234567890,
+/// "clinfo": 5,
+/// "vmlist": 12,
+/// "qemu-server": 3,
+/// "lxc": 2,
+/// "nodes": 1
+/// }
+///
+/// All version counters are now maintained in the Status module (status/mod.rs)
+/// to match the C implementation where they are stored in cfs_status.
+use pmxcfs_config::Config;
+use pmxcfs_status::Status;
+use serde_json::json;
+use std::sync::Arc;
+
+use super::Plugin;
+
+/// Version plugin - provides cluster version information
+pub struct VersionPlugin {
+ config: Arc<Config>,
+ status: Arc<Status>,
+}
+
+impl VersionPlugin {
+ pub fn new(config: Arc<Config>, status: Arc<Status>) -> Self {
+ Self { config, status }
+ }
+
+ /// Generate version information content
+ fn generate_content(&self) -> String {
+ // Get cluster state from status (matches C's cfs_status access)
+ let members = self.status.get_members();
+ let quorate = self.status.is_quorate();
+
+ // Count unique nodes
+ let mut unique_nodes = std::collections::HashSet::new();
+ for member in &members {
+ unique_nodes.insert(member.node_id);
+ }
+ let node_count = unique_nodes.len().max(1); // At least 1 (ourselves)
+
+ // Build base response with all version counters
+ let mut response = serde_json::Map::new();
+
+ // Basic version info
+ response.insert("version".to_string(), json!(env!("CARGO_PKG_VERSION")));
+ response.insert("api".to_string(), json!(1));
+
+ // Daemon start time (from Status)
+ response.insert("starttime".to_string(), json!(self.status.get_start_time()));
+
+ // Cluster info version (from Status)
+ response.insert(
+ "clinfo".to_string(),
+ json!(self.status.get_cluster_version()),
+ );
+
+ // VM list version (from Status)
+ response.insert(
+ "vmlist".to_string(),
+ json!(self.status.get_vmlist_version()),
+ );
+
+ // MemDB path versions (from Status)
+ // These are the paths that clients commonly monitor for changes
+ let path_versions = self.status.get_all_path_versions();
+ for (path, version) in path_versions {
+ if version > 0 {
+ response.insert(path, json!(version));
+ }
+ }
+
+ // Cluster info (legacy format for compatibility)
+ response.insert(
+ "cluster".to_string(),
+ json!({
+ "name": self.config.cluster_name(),
+ "nodes": node_count,
+ "quorate": if quorate { 1 } else { 0 }
+ }),
+ );
+
+ serde_json::Value::Object(response).to_string()
+ }
+}
+
+impl Plugin for VersionPlugin {
+ fn name(&self) -> &str {
+ ".version"
+ }
+
+ fn read(&self) -> anyhow::Result<Vec<u8>> {
+ Ok(self.generate_content().into_bytes())
+ }
+
+ fn mode(&self) -> u32 {
+ 0o440
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[tokio::test]
+ async fn test_version_format() {
+ // Create Status instance without RRD persistence (not needed for test)
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ // Create Config instance
+ let config = Arc::new(Config::new(
+ "testnode".to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 33,
+ false,
+ false,
+ "testcluster".to_string(),
+ ));
+
+ // Initialize cluster
+ status.init_cluster("testcluster".to_string());
+
+ let plugin = VersionPlugin::new(config, status);
+ let result = plugin.generate_content();
+ let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
+
+ // Should have version
+ assert!(parsed["version"].is_string());
+
+ // Should have api
+ assert_eq!(parsed["api"], 1);
+
+ // Should have starttime
+ assert!(parsed["starttime"].is_number());
+
+ // Should have clinfo and vmlist
+ assert!(parsed["clinfo"].is_number());
+ assert!(parsed["vmlist"].is_number());
+
+ // Should have cluster info
+ assert_eq!(parsed["cluster"]["name"], "testcluster");
+ assert!(parsed["cluster"]["nodes"].is_number());
+ assert!(parsed["cluster"]["quorate"].is_number());
+ }
+
+ #[tokio::test]
+ async fn test_increment_versions() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ let initial_clinfo = status.get_cluster_version();
+ status.increment_cluster_version();
+ assert_eq!(status.get_cluster_version(), initial_clinfo + 1);
+
+ let initial_vmlist = status.get_vmlist_version();
+ status.increment_vmlist_version();
+ assert_eq!(status.get_vmlist_version(), initial_vmlist + 1);
+ }
+
+ #[tokio::test]
+ async fn test_path_versions() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ // Use actual paths from memdb_change_array
+ status.increment_path_version("corosync.conf");
+ status.increment_path_version("corosync.conf");
+ assert!(status.get_path_version("corosync.conf") >= 2);
+
+ status.increment_path_version("user.cfg");
+ assert!(status.get_path_version("user.cfg") >= 1);
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/plugins/vmlist.rs b/src/pmxcfs-rs/pmxcfs/src/plugins/vmlist.rs
new file mode 100644
index 000000000..0ccab7752
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/plugins/vmlist.rs
@@ -0,0 +1,120 @@
+/// .vmlist Plugin - Virtual Machine List
+///
+/// This plugin provides VM/CT list in JSON format:
+/// {
+/// "version": 1,
+/// "ids": {
+/// "100": { "node": "node1", "type": "qemu", "version": 1 },
+/// "101": { "node": "node2", "type": "lxc", "version": 1 }
+/// }
+/// }
+use pmxcfs_status::Status;
+use serde_json::json;
+use std::sync::Arc;
+
+use super::Plugin;
+
+/// Vmlist plugin - provides VM/CT list
+pub struct VmlistPlugin {
+ status: Arc<Status>,
+}
+
+impl VmlistPlugin {
+ pub fn new(status: Arc<Status>) -> Self {
+ Self { status }
+ }
+
+ /// Generate vmlist content
+ fn generate_content(&self) -> String {
+ let vmlist = self.status.get_vmlist();
+ let vmlist_version = self.status.get_vmlist_version();
+
+ // Convert to JSON format expected by Proxmox
+ // Format: {"version":N,"ids":{vmid:{"node":"nodename","type":"qemu|lxc","version":M}}}
+ let mut ids = serde_json::Map::new();
+
+ for (vmid, entry) in vmlist {
+ let vm_obj = json!({
+ "node": entry.node,
+ "type": entry.vmtype.to_string(),
+ "version": entry.version
+ });
+
+ ids.insert(vmid.to_string(), vm_obj);
+ }
+
+ json!({
+ "version": vmlist_version,
+ "ids": ids
+ })
+ .to_string()
+ }
+}
+
+impl Plugin for VmlistPlugin {
+ fn name(&self) -> &str {
+ ".vmlist"
+ }
+
+ fn read(&self) -> anyhow::Result<Vec<u8>> {
+ Ok(self.generate_content().into_bytes())
+ }
+
+ fn mode(&self) -> u32 {
+ 0o440
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[tokio::test]
+ async fn test_vmlist_format() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ let plugin = VmlistPlugin::new(status);
+ let result = plugin.generate_content();
+ let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
+
+ // Should have version
+ assert!(parsed["version"].is_number());
+
+ // Should have ids object
+ assert!(parsed["ids"].is_object());
+ }
+
+ #[tokio::test]
+ async fn test_vmlist_versions() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ // Register a VM
+ status.register_vm(100, pmxcfs_status::VmType::Qemu, "node1".to_string());
+
+ let plugin = VmlistPlugin::new(status.clone());
+ let result = plugin.generate_content();
+ let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
+
+ // Root version should be >= 1
+ assert!(parsed["version"].as_u64().unwrap() >= 1);
+
+ // VM should have version 1
+ assert_eq!(parsed["ids"]["100"]["version"], 1);
+ assert_eq!(parsed["ids"]["100"]["type"], "qemu");
+ assert_eq!(parsed["ids"]["100"]["node"], "node1");
+
+ // Update the VM - version should increment
+ status.register_vm(100, pmxcfs_status::VmType::Qemu, "node1".to_string());
+
+ let result2 = plugin.generate_content();
+ let parsed2: serde_json::Value = serde_json::from_str(&result2).unwrap();
+
+ // Root version should have incremented
+ assert!(parsed2["version"].as_u64().unwrap() > parsed["version"].as_u64().unwrap());
+
+ // VM version should have incremented to 2
+ assert_eq!(parsed2["ids"]["100"]["version"], 2);
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/quorum_service.rs b/src/pmxcfs-rs/pmxcfs/src/quorum_service.rs
new file mode 100644
index 000000000..81b25f060
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/quorum_service.rs
@@ -0,0 +1,207 @@
+//! Quorum service for cluster membership tracking
+//!
+//! This service tracks quorum status via Corosync quorum API and updates Status.
+//! It implements the Service trait for automatic retry and lifecycle management.
+
+use async_trait::async_trait;
+use parking_lot::RwLock;
+use pmxcfs_services::{Service, ServiceError};
+use rust_corosync::{self as corosync, CsError, NodeId, quorum};
+use std::sync::Arc;
+
+use pmxcfs_status::Status;
+
+/// Quorum service (matching C's service_quorum)
+///
+/// Tracks cluster quorum status and member list changes. Automatically
+/// retries connection if Corosync is unavailable or restarts.
+pub struct QuorumService {
+ quorum_handle: RwLock<Option<quorum::Handle>>,
+ status: Arc<Status>,
+ /// Context pointer for callbacks (leaked Arc)
+ context_ptr: RwLock<Option<u64>>,
+}
+
+impl QuorumService {
+ /// Create a new quorum service
+ pub fn new(status: Arc<Status>) -> Self {
+ Self {
+ quorum_handle: RwLock::new(None),
+ status,
+ context_ptr: RwLock::new(None),
+ }
+ }
+
+ /// Check if cluster is quorate (delegates to Status)
+ pub fn is_quorate(&self) -> bool {
+ self.status.is_quorate()
+ }
+}
+
+#[async_trait]
+impl Service for QuorumService {
+ fn name(&self) -> &str {
+ "quorum"
+ }
+
+ async fn initialize(&mut self) -> pmxcfs_services::Result<std::os::unix::io::RawFd> {
+ tracing::info!("Initializing quorum tracking");
+
+ // Quorum notification callback
+ fn quorum_notification(
+ handle: &quorum::Handle,
+ quorate: bool,
+ ring_id: quorum::RingId,
+ member_list: Vec<NodeId>,
+ ) {
+ tracing::info!(
+ "Quorum notification: quorate={}, ring_id=({},{}), members={:?}",
+ quorate,
+ u32::from(ring_id.nodeid),
+ ring_id.seq,
+ member_list
+ );
+
+ if quorate {
+ tracing::info!("Cluster is now quorate with {} members", member_list.len());
+ } else {
+ tracing::warn!("Cluster lost quorum");
+ }
+
+ // Retrieve QuorumService from handle context
+ let context = match quorum::context_get(*handle) {
+ Ok(ctx) => ctx,
+ Err(e) => {
+ tracing::error!(
+ "Failed to get quorum context: {} - quorum status not updated",
+ e
+ );
+ return;
+ }
+ };
+
+ if context == 0 {
+ tracing::error!("BUG: Quorum context is null - quorum status not updated");
+ return;
+ }
+
+ // Safety: We stored a valid Arc<QuorumService> pointer in initialize()
+ unsafe {
+ let service_ptr = context as *const QuorumService;
+ let service = &*service_ptr;
+ service.status.set_quorate(quorate);
+ }
+ }
+
+ // Nodelist change notification callback
+ fn nodelist_notification(
+ _handle: &quorum::Handle,
+ ring_id: quorum::RingId,
+ member_list: Vec<NodeId>,
+ joined_list: Vec<NodeId>,
+ left_list: Vec<NodeId>,
+ ) {
+ tracing::info!(
+ "Nodelist change: ring_id=({},{}), members={:?}, joined={:?}, left={:?}",
+ u32::from(ring_id.nodeid),
+ ring_id.seq,
+ member_list,
+ joined_list,
+ left_list
+ );
+ }
+
+ let model_data = quorum::ModelData::ModelV1(quorum::Model1Data {
+ flags: quorum::Model1Flags::None,
+ quorum_notification_fn: Some(quorum_notification),
+ nodelist_notification_fn: Some(nodelist_notification),
+ });
+
+ // Initialize quorum connection
+ let (handle, _quorum_type) = quorum::initialize(&model_data, 0).map_err(|e| {
+ ServiceError::InitializationFailed(format!("quorum_initialize failed: {e:?}"))
+ })?;
+
+ // Store self pointer as context for callbacks
+ // We create a stable pointer that won't move - it's a pointer to self
+ // which is already on the heap as part of the Box<dyn Service>
+ let self_ptr = self as *const Self as u64;
+ quorum::context_set(handle, self_ptr).map_err(|e| {
+ quorum::finalize(handle).ok();
+ ServiceError::InitializationFailed(format!("Failed to set quorum context: {e:?}"))
+ })?;
+
+ *self.context_ptr.write() = Some(self_ptr);
+ tracing::debug!("Stored QuorumService context: 0x{:x}", self_ptr);
+
+ // Start tracking
+ quorum::trackstart(handle, corosync::TrackFlags::Changes).map_err(|e| {
+ quorum::finalize(handle).ok();
+ ServiceError::InitializationFailed(format!("quorum_trackstart failed: {e:?}"))
+ })?;
+
+ // Get file descriptor for event monitoring
+ let fd = quorum::fd_get(handle).map_err(|e| {
+ quorum::finalize(handle).ok();
+ ServiceError::InitializationFailed(format!("quorum_fd_get failed: {e:?}"))
+ })?;
+
+ // Dispatch once to get initial state
+ if let Err(e) = quorum::dispatch(handle, corosync::DispatchFlags::One) {
+ tracing::warn!("Initial quorum dispatch failed: {:?}", e);
+ }
+
+ *self.quorum_handle.write() = Some(handle);
+
+ tracing::info!("Quorum tracking initialized successfully with fd {}", fd);
+ Ok(fd)
+ }
+
+ async fn dispatch(&mut self) -> pmxcfs_services::Result<bool> {
+ let handle = self.quorum_handle.read().ok_or_else(|| {
+ ServiceError::DispatchFailed("Quorum handle not initialized".to_string())
+ })?;
+
+ // Dispatch all pending events
+ match quorum::dispatch(handle, corosync::DispatchFlags::All) {
+ Ok(_) => Ok(true),
+ Err(CsError::CsErrTryAgain) => {
+ // TRY_AGAIN is expected, continue normally
+ Ok(true)
+ }
+ Err(CsError::CsErrLibrary) | Err(CsError::CsErrBadHandle) => {
+ // Connection lost, need to reinitialize
+ tracing::warn!(
+ "Quorum connection lost (library error), requesting reinitialization"
+ );
+ Ok(false)
+ }
+ Err(e) => {
+ tracing::error!("Quorum dispatch failed: {:?}", e);
+ Err(ServiceError::DispatchFailed(format!(
+ "quorum_dispatch failed: {e:?}"
+ )))
+ }
+ }
+ }
+
+ async fn finalize(&mut self) -> pmxcfs_services::Result<()> {
+ tracing::info!("Finalizing quorum service");
+
+ // Clear quorate status
+ self.status.set_quorate(false);
+
+ // Finalize quorum handle
+ if let Some(handle) = self.quorum_handle.write().take()
+ && let Err(e) = quorum::finalize(handle)
+ {
+ tracing::warn!("Error finalizing quorum: {:?}", e);
+ }
+
+ // Clear context pointer
+ *self.context_ptr.write() = None;
+
+ tracing::info!("Quorum service finalized");
+ Ok(())
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/restart_flag.rs b/src/pmxcfs-rs/pmxcfs/src/restart_flag.rs
new file mode 100644
index 000000000..3c897b3af
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/restart_flag.rs
@@ -0,0 +1,60 @@
+//! Restart flag management
+//!
+//! This module provides RAII-based restart flag management. The flag is
+//! created on shutdown to signal that pmxcfs is restarting (not stopping).
+
+use std::ffi::CString;
+use std::fs::File;
+use std::io::Write;
+use std::path::{Path, PathBuf};
+use tracing::{info, warn};
+
+/// RAII wrapper for restart flag
+///
+/// Creates a flag file on construction to signal pmxcfs restart.
+/// The file is NOT automatically removed (it's consumed by the next startup).
+pub struct RestartFlag;
+
+impl RestartFlag {
+ /// Create a restart flag file
+ ///
+ /// This signals that pmxcfs is restarting (not permanently shutting down).
+ ///
+ /// # Arguments
+ ///
+ /// * `path` - Path where the restart flag should be created
+ /// * `gid` - Group ID to set for the file
+ pub fn create(path: PathBuf, gid: u32) -> Self {
+ // Create the restart flag file
+ match File::create(&path) {
+ Ok(mut file) => {
+ if let Err(e) = file.flush() {
+ warn!(error = %e, path = %path.display(), "Failed to flush restart flag");
+ }
+
+ // Set ownership (root:gid)
+ Self::set_ownership(&path, gid);
+ info!(path = %path.display(), "Created restart flag");
+ }
+ Err(e) => {
+ warn!(error = %e, path = %path.display(), "Failed to create restart flag");
+ }
+ }
+
+ Self
+ }
+
+ /// Set file ownership to root:gid
+ fn set_ownership(path: &Path, gid: u32) {
+ let path_str = path.to_string_lossy();
+ if let Ok(path_cstr) = CString::new(path_str.as_ref()) {
+ // Safety: chown is called with a valid C string and valid UID/GID
+ unsafe {
+ if libc::chown(path_cstr.as_ptr(), 0, gid as libc::gid_t) != 0 {
+ let error = std::io::Error::last_os_error();
+ warn!(error = %error, "Failed to change ownership of restart flag");
+ }
+ }
+ }
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/src/status_callbacks.rs b/src/pmxcfs-rs/pmxcfs/src/status_callbacks.rs
new file mode 100644
index 000000000..918ebee1a
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/src/status_callbacks.rs
@@ -0,0 +1,352 @@
+//! DFSM Callbacks for Status Synchronization (kvstore)
+//!
+//! This module implements the DfsmCallbacks trait for the status kvstore DFSM instance.
+//! It handles synchronization of ephemeral status data across the cluster:
+//! - Key-value status updates from nodes (RRD data, IP addresses, etc.)
+//! - Cluster log entries
+//!
+//! Equivalent to C implementation's kvstore DFSM callbacks in status.c
+//!
+//! Note: The kvstore DFSM doesn't use FuseMessage like the main database DFSM.
+//! It uses raw CPG messages for lightweight status synchronization.
+//! Most DfsmCallbacks methods are stubbed since status data is ephemeral and
+//! doesn't require the full database synchronization machinery.
+
+use pmxcfs_dfsm::{Callbacks, KvStoreMessage, NodeSyncInfo};
+use pmxcfs_status::Status;
+use std::sync::Arc;
+use tracing::{debug, warn};
+
+/// Callbacks for status synchronization DFSM (kvstore)
+///
+/// This implements the DfsmCallbacks trait but only uses basic CPG event handling.
+/// Most methods are stubbed since kvstore doesn't use database synchronization.
+pub struct StatusCallbacks {
+ status: Arc<Status>,
+}
+
+impl StatusCallbacks {
+ /// Create new status callbacks
+ pub fn new(status: Arc<Status>) -> Self {
+ Self { status }
+ }
+}
+
+impl Callbacks for StatusCallbacks {
+ type Message = KvStoreMessage;
+
+ /// Deliver a message - handles KvStore messages for status synchronization
+ ///
+ /// The kvstore DFSM handles KvStore messages (UPDATE, LOG, etc.) for
+ /// ephemeral status data synchronization across the cluster.
+ fn deliver_message(
+ &self,
+ nodeid: u32,
+ pid: u32,
+ kvstore_message: KvStoreMessage,
+ timestamp: u64,
+ ) -> anyhow::Result<(i32, bool)> {
+ debug!(nodeid, pid, timestamp, "Delivering KvStore message");
+
+ // Handle different KvStore message types
+ match kvstore_message {
+ KvStoreMessage::Update { key, value } => {
+ debug!(key, value_len = value.len(), "KvStore UPDATE");
+
+ // Store the key-value data for this node (matches C's cfs_kvstore_node_set)
+ self.status.set_node_kv(nodeid, key, value);
+ Ok((0, true))
+ }
+ KvStoreMessage::Log {
+ time,
+ priority,
+ node,
+ ident,
+ tag,
+ message,
+ } => {
+ debug!(
+ time, priority, %node, %ident, %tag, %message,
+ "KvStore LOG"
+ );
+
+ // Add log entry to cluster log
+ if let Err(e) = self
+ .status
+ .add_remote_cluster_log(time, priority, node, ident, tag, message)
+ {
+ warn!(error = %e, "Failed to add cluster log entry");
+ }
+
+ Ok((0, true))
+ }
+ KvStoreMessage::UpdateComplete => {
+ debug!("KvStore UpdateComplete");
+ Ok((0, true))
+ }
+ }
+ }
+
+ /// Compute checksum (not used by kvstore - ephemeral data doesn't need checksums)
+ fn compute_checksum(&self, output: &mut [u8; 32]) -> anyhow::Result<()> {
+ // Status data is ephemeral and doesn't use checksums
+ output.fill(0);
+ Ok(())
+ }
+
+ /// Get state for synchronization (returns cluster log state)
+ ///
+ /// Returns the cluster log in C-compatible binary format (clog_base_t).
+ /// This enables mixed C/Rust cluster operation - C nodes can deserialize
+ /// the state we send, and we can deserialize states from C nodes.
+ fn get_state(&self) -> anyhow::Result<Vec<u8>> {
+ debug!("Status kvstore: get_state called - serializing cluster log");
+ self.status.get_cluster_log_state()
+ }
+
+ /// Process state update (handles cluster log state sync)
+ ///
+ /// Deserializes cluster log states from remote nodes and merges them with
+ /// the local log. This enables cluster-wide log synchronization in mixed
+ /// C/Rust clusters.
+ fn process_state_update(&self, states: &[NodeSyncInfo]) -> anyhow::Result<bool> {
+ debug!(
+ "Status kvstore: process_state_update called with {} states",
+ states.len()
+ );
+
+ if states.is_empty() {
+ return Ok(true);
+ }
+
+ self.status.merge_cluster_log_states(states)?;
+ Ok(true)
+ }
+
+ /// Process incremental update (not used by kvstore)
+ ///
+ /// Kvstore uses direct CPG messages (UPDATE, LOG) instead of incremental sync
+ fn process_update(&self, _nodeid: u32, _pid: u32, _data: &[u8]) -> anyhow::Result<()> {
+ warn!("Status kvstore: received unexpected process_update call");
+ Ok(())
+ }
+
+ /// Commit state (no-op for kvstore - ephemeral data, no database commit)
+ fn commit_state(&self) -> anyhow::Result<()> {
+ // No commit needed for ephemeral status data
+ Ok(())
+ }
+
+ /// Called when cluster becomes synced
+ fn on_synced(&self) {
+ debug!("Status kvstore: cluster synced");
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use pmxcfs_dfsm::KvStoreMessage;
+ use pmxcfs_status::ClusterLogEntry;
+
+ #[test]
+ fn test_kvstore_update_message_handling() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status.clone());
+
+ // Initialize cluster and register node 2
+ status.init_cluster("test-cluster".to_string());
+ status.register_node(2, "node2".to_string(), "192.168.1.11".to_string());
+
+ // Simulate receiving a kvstore UPDATE message from node 2
+ let key = "test-key".to_string();
+ let value = b"test-value".to_vec();
+ let message = KvStoreMessage::Update {
+ key: key.clone(),
+ value: value.clone(),
+ };
+
+ let result = callbacks.deliver_message(2, 1000, message, 12345);
+ assert!(result.is_ok(), "deliver_message should succeed");
+
+ let (res, continue_processing) = result.unwrap();
+ assert_eq!(res, 0, "Result code should be 0 for success");
+ assert!(continue_processing, "Should continue processing");
+
+ // Verify the data was stored in kvstore
+ let stored_value = status.get_node_kv(2, &key);
+ assert_eq!(
+ stored_value,
+ Some(value),
+ "Should store the key-value pair for node 2"
+ );
+ }
+
+ #[test]
+ fn test_kvstore_update_multiple_nodes() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status.clone());
+
+ // Initialize cluster and register nodes
+ status.init_cluster("test-cluster".to_string());
+ status.register_node(1, "node1".to_string(), "192.168.1.10".to_string());
+ status.register_node(2, "node2".to_string(), "192.168.1.11".to_string());
+
+ // Store data from multiple nodes
+ let msg1 = KvStoreMessage::Update {
+ key: "ip".to_string(),
+ value: b"192.168.1.10".to_vec(),
+ };
+ let msg2 = KvStoreMessage::Update {
+ key: "ip".to_string(),
+ value: b"192.168.1.11".to_vec(),
+ };
+
+ callbacks.deliver_message(1, 1000, msg1, 12345).unwrap();
+ callbacks.deliver_message(2, 1001, msg2, 12346).unwrap();
+
+ // Verify each node's data is stored separately
+ assert_eq!(
+ status.get_node_kv(1, "ip"),
+ Some(b"192.168.1.10".to_vec()),
+ "Node 1 IP should be stored"
+ );
+ assert_eq!(
+ status.get_node_kv(2, "ip"),
+ Some(b"192.168.1.11".to_vec()),
+ "Node 2 IP should be stored"
+ );
+ }
+
+ #[test]
+ fn test_kvstore_log_message_handling() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status.clone());
+
+ // Clear any existing log entries
+ status.clear_cluster_log();
+
+ // Simulate receiving a LOG message
+ let message = KvStoreMessage::Log {
+ time: 1234567890,
+ priority: 6, // LOG_INFO
+ node: "node1".to_string(),
+ ident: "pmxcfs".to_string(),
+ tag: "cluster".to_string(),
+ message: "Test log entry".to_string(),
+ };
+
+ let result = callbacks.deliver_message(1, 1000, message, 12345);
+ assert!(result.is_ok(), "LOG message delivery should succeed");
+
+ // Verify the log entry was added
+ let log_entries = status.get_log_entries(10);
+ assert_eq!(log_entries.len(), 1, "Should have 1 log entry");
+ assert_eq!(log_entries[0].node, "node1");
+ assert_eq!(log_entries[0].message, "Test log entry");
+ assert_eq!(log_entries[0].priority, 6);
+ }
+
+ #[test]
+ fn test_kvstore_update_complete_message() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status.clone());
+
+ let message = KvStoreMessage::UpdateComplete;
+
+ let result = callbacks.deliver_message(1, 1000, message, 12345);
+ assert!(result.is_ok(), "UpdateComplete should succeed");
+
+ let (res, continue_processing) = result.unwrap();
+ assert_eq!(res, 0);
+ assert!(continue_processing);
+ }
+
+ #[test]
+ fn test_compute_checksum_returns_zeros() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status);
+
+ let mut checksum = [0u8; 32];
+ let result = callbacks.compute_checksum(&mut checksum);
+
+ assert!(result.is_ok(), "compute_checksum should succeed");
+ assert_eq!(
+ checksum, [0u8; 32],
+ "Checksum should be all zeros for ephemeral data"
+ );
+ }
+
+ #[test]
+ fn test_get_state_returns_cluster_log() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status.clone());
+
+ // Add a log entry first
+ status.clear_cluster_log();
+ let entry = ClusterLogEntry {
+ uid: 0,
+ timestamp: 1234567890,
+ priority: 6,
+ tag: "test".to_string(),
+ pid: 0,
+ node: "node1".to_string(),
+ ident: "pmxcfs".to_string(),
+ message: "Test message".to_string(),
+ };
+ status.add_log_entry(entry);
+
+ // Get state should return serialized cluster log
+ let result = callbacks.get_state();
+ assert!(result.is_ok(), "get_state should succeed");
+
+ let state = result.unwrap();
+ assert!(
+ !state.is_empty(),
+ "State should not be empty when cluster log has entries"
+ );
+ }
+
+ #[test]
+ fn test_process_state_update_with_empty_states() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status);
+
+ let states: Vec<NodeSyncInfo> = vec![];
+ let result = callbacks.process_state_update(&states);
+
+ assert!(result.is_ok(), "Empty state update should succeed");
+ assert!(result.unwrap(), "Should return true for empty states");
+ }
+
+ #[test]
+ fn test_process_update_logs_warning() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status);
+
+ // process_update is not used by kvstore, but should not fail
+ let result = callbacks.process_update(1, 1000, &[1, 2, 3]);
+ assert!(
+ result.is_ok(),
+ "process_update should succeed even though not used"
+ );
+ }
+
+ #[test]
+ fn test_commit_state_is_noop() {
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = Arc::new(Status::new(config, None));
+ let callbacks = StatusCallbacks::new(status);
+
+ let result = callbacks.commit_state();
+ assert!(result.is_ok(), "commit_state should succeed (no-op)");
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/common/mod.rs b/src/pmxcfs-rs/pmxcfs/tests/common/mod.rs
new file mode 100644
index 000000000..a134c948b
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/common/mod.rs
@@ -0,0 +1,221 @@
+//! Common test utilities for pmxcfs integration tests
+//!
+//! This module provides shared test setup and helper functions to ensure
+//! consistency across all integration tests and reduce code duplication.
+
+use anyhow::Result;
+use pmxcfs_config::Config;
+use pmxcfs_memdb::MemDb;
+use pmxcfs_status::Status;
+use std::sync::Arc;
+use tempfile::TempDir;
+
+// Test constants
+pub const TEST_MTIME: u32 = 1234567890;
+pub const TEST_NODE_NAME: &str = "testnode";
+pub const TEST_CLUSTER_NAME: &str = "test-cluster";
+pub const TEST_WWW_DATA_GID: u32 = 33;
+
+/// Creates a standard test configuration
+///
+/// # Arguments
+/// * `local_mode` - Whether to run in local mode (no cluster)
+///
+/// # Returns
+/// Arc-wrapped Config suitable for testing
+pub fn create_test_config(local_mode: bool) -> Arc<Config> {
+ Config::shared(
+ TEST_NODE_NAME.to_string(),
+ "127.0.0.1".parse().unwrap(),
+ TEST_WWW_DATA_GID,
+ false, // debug mode
+ local_mode,
+ TEST_CLUSTER_NAME.to_string(),
+ )
+}
+
+/// Creates a test database with standard directory structure
+///
+/// Creates the following directories:
+/// - /nodes/{nodename}/qemu-server
+/// - /nodes/{nodename}/lxc
+/// - /nodes/{nodename}/priv
+/// - /priv/lock/qemu-server
+/// - /priv/lock/lxc
+/// - /qemu-server
+/// - /lxc
+///
+/// # Returns
+/// (TempDir, MemDb) - The temp directory must be kept alive for database to persist
+pub fn create_test_db() -> Result<(TempDir, MemDb)> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let db = MemDb::open(&db_path, true)?;
+
+ // Create standard directory structure
+ let now = TEST_MTIME;
+
+ // Node-specific directories
+ db.create("/nodes", libc::S_IFDIR, 0, now)?;
+ db.create(&format!("/nodes/{}", TEST_NODE_NAME), libc::S_IFDIR, 0, now)?;
+ db.create(
+ &format!("/nodes/{}/qemu-server", TEST_NODE_NAME), libc::S_IFDIR, 0,
+ now,
+ )?;
+ db.create(
+ &format!("/nodes/{}/lxc", TEST_NODE_NAME), libc::S_IFDIR, 0,
+ now,
+ )?;
+ db.create(
+ &format!("/nodes/{}/priv", TEST_NODE_NAME), libc::S_IFDIR, 0,
+ now,
+ )?;
+
+ // Global directories
+ db.create("/priv", libc::S_IFDIR, 0, now)?;
+ db.create("/priv/lock", libc::S_IFDIR, 0, now)?;
+ db.create("/priv/lock/qemu-server", libc::S_IFDIR, 0, now)?;
+ db.create("/priv/lock/lxc", libc::S_IFDIR, 0, now)?;
+ db.create("/qemu-server", libc::S_IFDIR, 0, now)?;
+ db.create("/lxc", libc::S_IFDIR, 0, now)?;
+
+ Ok((temp_dir, db))
+}
+
+/// Creates a minimal test database (no standard directories)
+///
+/// Use this when you want full control over database structure
+///
+/// # Returns
+/// (TempDir, MemDb) - The temp directory must be kept alive for database to persist
+#[allow(dead_code)]
+pub fn create_minimal_test_db() -> Result<(TempDir, MemDb)> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let db = MemDb::open(&db_path, true)?;
+ Ok((temp_dir, db))
+}
+
+/// Creates a test status instance
+///
+/// NOTE: This uses the global Status singleton. Be aware that tests using this
+/// will share the same Status instance and may interfere with each other if run
+/// in parallel. Consider running Status-dependent tests serially using:
+/// `#[serial]` attribute from the `serial_test` crate.
+///
+/// # Returns
+/// Arc-wrapped Status instance
+pub fn create_test_status() -> Arc<Status> {
+ pmxcfs_status::init()
+}
+
+/// Clears all VMs from the status subsystem
+///
+/// Useful for ensuring clean state before tests that register VMs.
+///
+/// # Arguments
+/// * `status` - The status instance to clear
+#[allow(dead_code)]
+pub fn clear_test_vms(status: &Arc<Status>) {
+ let existing_vms: Vec<u32> = status.get_vmlist().keys().copied().collect();
+ for vmid in existing_vms {
+ status.delete_vm(vmid);
+ }
+}
+
+/// Creates test VM configuration content
+///
+/// # Arguments
+/// * `vmid` - VM ID
+/// * `cores` - Number of CPU cores
+/// * `memory` - Memory in MB
+///
+/// # Returns
+/// Configuration file content as bytes
+#[allow(dead_code)]
+pub fn create_vm_config(vmid: u32, cores: u32, memory: u32) -> Vec<u8> {
+ format!(
+ "name: test-vm-{}\ncores: {}\nmemory: {}\nbootdisk: scsi0\n",
+ vmid, cores, memory
+ )
+ .into_bytes()
+}
+
+/// Creates test CT (container) configuration content
+///
+/// # Arguments
+/// * `vmid` - Container ID
+/// * `cores` - Number of CPU cores
+/// * `memory` - Memory in MB
+///
+/// # Returns
+/// Configuration file content as bytes
+#[allow(dead_code)]
+pub fn create_ct_config(vmid: u32, cores: u32, memory: u32) -> Vec<u8> {
+ format!(
+ "cores: {}\nmemory: {}\nrootfs: local:100/vm-{}-disk-0.raw\n",
+ cores, memory, vmid
+ )
+ .into_bytes()
+}
+
+/// Creates a test lock path for a VM config
+///
+/// # Arguments
+/// * `vmid` - VM ID
+/// * `vm_type` - "qemu-server" or "lxc"
+///
+/// # Returns
+/// Lock path in format `/priv/lock/{vm_type}/{vmid}.conf`
+pub fn create_lock_path(vmid: u32, vm_type: &str) -> String {
+ format!("/priv/lock/{}/{}.conf", vm_type, vmid)
+}
+
+/// Creates a test config path for a VM
+///
+/// # Arguments
+/// * `vmid` - VM ID
+/// * `vm_type` - "qemu-server" or "lxc"
+///
+/// # Returns
+/// Config path in format `/{vm_type}/{vmid}.conf`
+pub fn create_config_path(vmid: u32, vm_type: &str) -> String {
+ format!("/{}/{}.conf", vm_type, vmid)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_create_test_config() {
+ let config = create_test_config(true);
+ assert_eq!(config.nodename(), TEST_NODE_NAME);
+ assert_eq!(config.cluster_name(), TEST_CLUSTER_NAME);
+ assert!(config.is_local_mode());
+ }
+
+ #[test]
+ fn test_create_test_db() -> Result<()> {
+ let (_temp_dir, db) = create_test_db()?;
+
+ // Verify standard directories exist
+ assert!(db.exists("/nodes")?, "Should have /nodes");
+ assert!(db.exists("/qemu-server")?, "Should have /qemu-server");
+ assert!(db.exists("/priv/lock")?, "Should have /priv/lock");
+
+ Ok(())
+ }
+
+ #[test]
+ fn test_path_helpers() {
+ assert_eq!(
+ create_lock_path(100, "qemu-server"),
+ "/priv/lock/qemu-server/100.conf"
+ );
+ assert_eq!(
+ create_config_path(100, "qemu-server"),
+ "/qemu-server/100.conf"
+ );
+ }
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/fuse_basic_test.rs b/src/pmxcfs-rs/pmxcfs/tests/fuse_basic_test.rs
new file mode 100644
index 000000000..0fb77d639
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/fuse_basic_test.rs
@@ -0,0 +1,216 @@
+/// Basic FUSE subsystem test
+///
+/// This test verifies core FUSE functionality without actually mounting
+/// to avoid test complexity and timeouts
+use anyhow::Result;
+use pmxcfs_config::Config;
+use pmxcfs_memdb::MemDb;
+use pmxcfs_rs::plugins;
+use tempfile::TempDir;
+
+#[test]
+fn test_fuse_subsystem_components() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+
+ // 1. Create memdb with test data
+ let memdb = MemDb::open(&db_path, true)?;
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ memdb.create("/testdir", libc::S_IFDIR, 0, now)?;
+ memdb.create("/testdir/file1.txt", libc::S_IFREG, 0, now)?;
+ memdb.write("/testdir/file1.txt", 0, 0, now, b"Hello pmxcfs!", false)?;
+
+ // 2. Create config
+ println!("\n2. Creating FUSE configuration...");
+ let config = Config::shared(
+ "testnode".to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 1000,
+ false,
+ true,
+ "test-cluster".to_string(),
+ );
+
+ // 3. Initialize status and plugins
+ println!("\n3. Initializing status and plugin registry...");
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status);
+ let plugin_list = plugins.list();
+ println!(" Available plugins: {:?}", plugin_list);
+ assert!(plugin_list.len() > 0, "Should have some plugins");
+
+ // 4. Verify plugin functionality
+ for plugin_name in &plugin_list {
+ if let Some(plugin) = plugins.get(plugin_name) {
+ match plugin.read() {
+ Ok(data) => {
+ println!(
+ " [OK] Plugin '{}' readable ({} bytes)",
+ plugin_name,
+ data.len()
+ );
+ }
+ Err(e) => {
+ println!(" [WARN] Plugin '{}' error: {}", plugin_name, e);
+ }
+ }
+ }
+ }
+
+ // 5. Verify memdb data is accessible
+ println!("\n5. Verifying memdb data accessibility...");
+ assert!(memdb.exists("/testdir")?, "testdir should exist");
+ assert!(
+ memdb.exists("/testdir/file1.txt")?,
+ "file1.txt should exist"
+ );
+
+ let data = memdb.read("/testdir/file1.txt", 0, 1024)?;
+ assert_eq!(&data[..], b"Hello pmxcfs!");
+
+ // 6. Test write operations
+ let new_data = b"Modified!";
+ memdb.write("/testdir/file1.txt", 0, 0, now, new_data, true)?;
+ let data = memdb.read("/testdir/file1.txt", 0, 1024)?;
+ assert_eq!(&data[..], b"Modified!");
+
+ // 7. Test directory operations
+ memdb.create("/newdir", libc::S_IFDIR, 0, now)?;
+ memdb.create("/newdir/newfile.txt", libc::S_IFREG, 0, now)?;
+ memdb.write("/newdir/newfile.txt", 0, 0, now, b"New content", false)?;
+
+ let entries = memdb.readdir("/")?;
+ let dir_names: Vec<&String> = entries.iter().map(|e| &e.name).collect();
+ println!(" Root entries: {:?}", dir_names);
+ assert!(
+ dir_names.iter().any(|n| n == &"testdir"),
+ "testdir should be in root"
+ );
+ assert!(
+ dir_names.iter().any(|n| n == &"newdir"),
+ "newdir should be in root"
+ );
+
+ // 8. Test deletion
+ memdb.delete("/newdir/newfile.txt", 0, 1000)?;
+ memdb.delete("/newdir", 0, 1000)?;
+ assert!(!memdb.exists("/newdir")?, "newdir should be deleted");
+
+ Ok(())
+}
+
+#[test]
+fn test_fuse_private_path_detection() -> Result<()> {
+ // This tests the logic that would be used in the FUSE filesystem
+ // to determine if paths should have restricted permissions
+
+ let test_cases = vec![
+ ("/priv", true, "root priv should be private"),
+ ("/priv/test", true, "priv subdir should be private"),
+ ("/nodes/node1/priv", true, "node priv should be private"),
+ (
+ "/nodes/node1/priv/data",
+ true,
+ "node priv subdir should be private",
+ ),
+ (
+ "/nodes/node1/config",
+ false,
+ "node config should not be private",
+ ),
+ ("/testdir", false, "testdir should not be private"),
+ (
+ "/private",
+ false,
+ "private (not priv) should not be private",
+ ),
+ ];
+
+ for (path, expected, description) in test_cases {
+ let is_private = is_private_path(path);
+ assert_eq!(is_private, expected, "Failed for {}: {}", path, description);
+ }
+
+ Ok(())
+}
+
+// Helper function matching the logic in filesystem.rs
+fn is_private_path(path: &str) -> bool {
+ let path = path.trim_start_matches('/');
+
+ // Check if path starts with "priv" or "priv/"
+ if path.starts_with("priv") && (path.len() == 4 || path.as_bytes().get(4) == Some(&b'/')) {
+ return true;
+ }
+
+ // Check for "nodes/*/priv" or "nodes/*/priv/*" pattern
+ if let Some(after_nodes) = path.strip_prefix("nodes/") {
+ if let Some(slash_pos) = after_nodes.find('/') {
+ let after_nodename = &after_nodes[slash_pos..];
+
+ if after_nodename.starts_with("/priv") {
+ let priv_end = slash_pos + 5;
+ if after_nodes.len() == priv_end
+ || after_nodes.as_bytes().get(priv_end) == Some(&b'/')
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ false
+}
+
+#[test]
+fn test_fuse_inode_path_mapping() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let memdb = MemDb::open(&db_path, true)?;
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ // Create nested directory structure
+ memdb.create("/a", libc::S_IFDIR, 0, now)?;
+ memdb.create("/a/b", libc::S_IFDIR, 0, now)?;
+ memdb.create("/a/b/c", libc::S_IFDIR, 0, now)?;
+ memdb.create("/a/b/c/file.txt", libc::S_IFREG, 0, now)?;
+ memdb.write("/a/b/c/file.txt", 0, 0, now, b"deep file", false)?;
+
+ // Verify we can look up deep paths
+ let entry = memdb
+ .lookup_path("/a/b/c/file.txt")
+ .ok_or_else(|| anyhow::anyhow!("Failed to lookup deep path"))?;
+
+ println!(" Inode: {}", entry.inode);
+ println!(" Size: {}", entry.size);
+ assert!(entry.inode > 1, "Should have valid inode");
+ assert_eq!(entry.size, 9, "File size should match");
+
+ // Verify parent relationships
+ println!("\n3. Verifying parent relationships...");
+ let c_entry = memdb
+ .lookup_path("/a/b/c")
+ .ok_or_else(|| anyhow::anyhow!("Failed to lookup /a/b/c"))?;
+ let b_entry = memdb
+ .lookup_path("/a/b")
+ .ok_or_else(|| anyhow::anyhow!("Failed to lookup /a/b"))?;
+
+ assert_eq!(
+ entry.parent, c_entry.inode,
+ "file.txt parent should be c directory"
+ );
+ assert_eq!(
+ c_entry.parent, b_entry.inode,
+ "c parent should be b directory"
+ );
+
+ Ok(())
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/fuse_cluster_test.rs b/src/pmxcfs-rs/pmxcfs/tests/fuse_cluster_test.rs
new file mode 100644
index 000000000..007fa5f75
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/fuse_cluster_test.rs
@@ -0,0 +1,220 @@
+/// FUSE Cluster Synchronization Tests
+///
+/// Tests for pmxcfs FUSE operations that trigger DFSM broadcasts
+/// and synchronize across cluster nodes. These tests verify that
+/// file operations made through FUSE properly propagate to other nodes.
+use anyhow::Result;
+use pmxcfs_dfsm::{Callbacks, Dfsm, FuseMessage, NodeSyncInfo};
+use pmxcfs_memdb::MemDb;
+use pmxcfs_rs::fuse;
+use pmxcfs_rs::plugins;
+use std::fs;
+use std::io::Write;
+use std::sync::{Arc, Mutex};
+use std::time::Duration;
+use tempfile::TempDir;
+
+/// Verify that FUSE filesystem successfully mounted, panic if not
+async fn verify_fuse_mounted(path: &std::path::Path) {
+ // Use spawn_blocking to avoid blocking the async runtime
+ let path_buf = path.to_path_buf();
+ let read_result = tokio::task::spawn_blocking(move || std::fs::read_dir(&path_buf))
+ .await
+ .expect("spawn_blocking failed");
+
+ if read_result.is_ok() {
+ return; // Mount succeeded
+ }
+
+ // Double-check with mount command
+ use std::process::Command;
+ let output = Command::new("mount").output().ok();
+ let is_mounted = if let Some(output) = output {
+ let mount_output = String::from_utf8_lossy(&output.stdout);
+ mount_output.contains(&path.display().to_string())
+ } else {
+ false
+ };
+
+ if !is_mounted {
+ panic!("FUSE mount failed.\nCheck /etc/fuse.conf for user_allow_other setting.");
+ }
+}
+
+/// Test callbacks for DFSM - minimal implementation for testing
+struct TestDfsmCallbacks {
+ memdb: MemDb,
+ broadcasts: Arc<Mutex<Vec<String>>>, // Track broadcast operations
+}
+
+impl TestDfsmCallbacks {
+ fn new(memdb: MemDb) -> Self {
+ Self {
+ memdb,
+ broadcasts: Arc::new(Mutex::new(Vec::new())),
+ }
+ }
+
+ #[allow(dead_code)]
+ fn get_broadcasts(&self) -> Vec<String> {
+ self.broadcasts.lock().unwrap().clone()
+ }
+}
+
+impl Callbacks for TestDfsmCallbacks {
+ type Message = FuseMessage;
+
+ fn deliver_message(
+ &self,
+ _nodeid: u32,
+ _pid: u32,
+ message: FuseMessage,
+ _timestamp: u64,
+ ) -> Result<(i32, bool)> {
+ // Track the broadcast for testing
+ let msg_desc = match &message {
+ FuseMessage::Write { path, .. } => format!("write:{}", path),
+ FuseMessage::Create { path } => format!("create:{}", path),
+ FuseMessage::Mkdir { path } => format!("mkdir:{}", path),
+ FuseMessage::Delete { path } => format!("delete:{}", path),
+ FuseMessage::Rename { from, to } => format!("rename:{}→{}", from, to),
+ _ => "other".to_string(),
+ };
+ self.broadcasts.lock().unwrap().push(msg_desc);
+ Ok((0, true))
+ }
+
+ fn compute_checksum(&self, output: &mut [u8; 32]) -> Result<()> {
+ *output = self.memdb.compute_database_checksum()?;
+ Ok(())
+ }
+
+ fn process_state_update(&self, _states: &[NodeSyncInfo]) -> Result<bool> {
+ Ok(true) // Indicate we're in sync for testing
+ }
+
+ fn process_update(&self, _nodeid: u32, _pid: u32, _data: &[u8]) -> Result<()> {
+ Ok(())
+ }
+
+ fn commit_state(&self) -> Result<()> {
+ Ok(())
+ }
+
+ fn on_synced(&self) {}
+
+ fn get_state(&self) -> Result<Vec<u8>> {
+ // Return empty state for testing
+ Ok(Vec::new())
+ }
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (user_allow_other in /etc/fuse.conf)"]
+async fn test_fuse_write_triggers_broadcast() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ // Create test directory
+ memdb.create("/testdir", libc::S_IFDIR, 0, now)?;
+
+ // Create DFSM instance with test callbacks
+ let callbacks = Arc::new(TestDfsmCallbacks::new(memdb.clone()));
+ let dfsm = Arc::new(Dfsm::new("test-cluster".to_string(), callbacks.clone())?);
+
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ // Spawn FUSE mount with DFSM
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let dfsm_clone = dfsm.clone();
+ let fuse_task = tokio::spawn(async move {
+ if let Err(e) = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config,
+ Some(dfsm_clone),
+ plugins,
+ status,
+ )
+ .await
+ {
+ eprintln!("FUSE mount error: {}", e);
+ }
+ });
+
+ tokio::time::sleep(Duration::from_millis(2000)).await;
+ verify_fuse_mounted(&mount_path).await;
+
+ // Test: Write to file via FUSE should trigger broadcast
+ let test_file = mount_path.join("testdir/broadcast-test.txt");
+ let mut file = fs::File::create(&test_file)?;
+ file.write_all(b"test data for broadcast")?;
+ drop(file);
+ println!("[OK] File written via FUSE");
+
+ // Give time for broadcast
+ tokio::time::sleep(Duration::from_millis(100)).await;
+
+ // Verify file exists in memdb
+ assert!(
+ memdb.exists("/testdir/broadcast-test.txt")?,
+ "File should exist in memdb"
+ );
+ let data = memdb.read("/testdir/broadcast-test.txt", 0, 1024)?;
+ assert_eq!(&data[..], b"test data for broadcast");
+ println!("[OK] File data verified in memdb");
+
+ // Cleanup
+ fs::remove_file(&test_file)?;
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ let _ = std::process::Command::new("fusermount3")
+ .arg("-u")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
+
+/// Additional FUSE + DFSM tests can be added here following the same pattern
+#[test]
+fn test_dfsm_callbacks_implementation() {
+ // Verify our test callbacks work correctly
+ let temp_dir = TempDir::new().unwrap();
+ let db_path = temp_dir.path().join("test.db");
+ let memdb = MemDb::open(&db_path, true).unwrap();
+
+ let callbacks = TestDfsmCallbacks::new(memdb);
+
+ // Test checksum computation
+ let mut checksum = [0u8; 32];
+ assert!(callbacks.compute_checksum(&mut checksum).is_ok());
+
+ // Test message delivery tracking
+ let result = callbacks.deliver_message(
+ 1,
+ 100,
+ FuseMessage::Create {
+ path: "/test".to_string(),
+ },
+ 12345,
+ );
+ assert!(result.is_ok());
+
+ let broadcasts = callbacks.get_broadcasts();
+ assert_eq!(broadcasts.len(), 1);
+ assert_eq!(broadcasts[0], "create:/test");
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/fuse_integration_test.rs b/src/pmxcfs-rs/pmxcfs/tests/fuse_integration_test.rs
new file mode 100644
index 000000000..0e9f80076
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/fuse_integration_test.rs
@@ -0,0 +1,414 @@
+/// Integration tests for FUSE filesystem with proxmox-fuse-rs
+///
+/// These tests verify that the FUSE subsystem works correctly after
+/// migrating from fuser to proxmox-fuse-rs
+use anyhow::Result;
+use pmxcfs_memdb::MemDb;
+use pmxcfs_rs::fuse;
+use pmxcfs_rs::plugins;
+use std::fs;
+use std::io::{Read, Write};
+use std::time::Duration;
+use tempfile::TempDir;
+
+/// Verify that FUSE filesystem successfully mounted, panic if not
+fn verify_fuse_mounted(path: &std::path::Path) {
+ use std::process::Command;
+
+ let output = Command::new("mount").output().ok();
+
+ let is_mounted = if let Some(output) = output {
+ let mount_output = String::from_utf8_lossy(&output.stdout);
+ mount_output.contains(&format!(" {} ", path.display()))
+ } else {
+ false
+ };
+
+ if !is_mounted {
+ panic!(
+ "FUSE mount failed (likely permissions issue).\n\
+ To run FUSE integration tests, either:\n\
+ 1. Run with sudo: sudo -E cargo test --test fuse_integration_test\n\
+ 2. Enable user_allow_other in /etc/fuse.conf and add your user to the 'fuse' group\n\
+ 3. Or skip these tests: cargo test --test fuse_basic_test"
+ );
+ }
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_fuse_mount_and_basic_operations() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ // Create mount point
+ fs::create_dir_all(&mount_path)?;
+
+ // Create database
+ let memdb = MemDb::open(&db_path, true)?;
+
+ // Create some test data in memdb
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ memdb.create("/testdir", libc::S_IFDIR, 0, now)?;
+ memdb.create("/testdir/file1.txt", libc::S_IFREG, 0, now)?;
+ memdb.write("/testdir/file1.txt", 0, 0, now, b"Hello from pmxcfs!", false)?;
+
+ memdb.create("/nodes", libc::S_IFDIR, 0, now)?;
+ memdb.create("/nodes/testnode", libc::S_IFDIR, 0, now)?;
+ memdb.create("/nodes/testnode/config", libc::S_IFREG, 0, now)?;
+ memdb.write(
+ "/nodes/testnode/config", 0, 0, now, b"test=configuration", false,
+ )?;
+
+ // Create config and plugins (no RRD persistence needed for test)
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let plugins = {
+ let test_status = pmxcfs_status::init_with_config(config.clone());
+ plugins::init_plugins(config.clone(), test_status)
+ };
+
+ // Create status for FUSE (set quorate for tests)
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+
+ // Spawn FUSE mount in background
+ println!("\n2. Mounting FUSE filesystem...");
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let config_clone = config.clone();
+ let plugins_clone = plugins.clone();
+ let status_clone = status.clone();
+
+ let fuse_task = tokio::spawn(async move {
+ if let Err(e) = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config_clone,
+ None, // no cluster
+ plugins_clone,
+ status_clone,
+ )
+ .await
+ {
+ eprintln!("FUSE mount error: {}", e);
+ }
+ });
+
+ // Give FUSE time to initialize and check if mount succeeded
+ tokio::time::sleep(Duration::from_millis(500)).await;
+
+ // Verify FUSE mounted successfully
+ verify_fuse_mounted(&mount_path);
+
+ // Test 1: Check if mount point is accessible
+ let root_entries = fs::read_dir(&mount_path)?;
+ let mut entry_names: Vec<String> = root_entries
+ .filter_map(|e| e.ok())
+ .map(|e| e.file_name().to_string_lossy().to_string())
+ .collect();
+ entry_names.sort();
+
+ println!(" Root directory entries: {:?}", entry_names);
+ assert!(
+ entry_names.contains(&"testdir".to_string()),
+ "testdir should be visible"
+ );
+ assert!(
+ entry_names.contains(&"nodes".to_string()),
+ "nodes should be visible"
+ );
+
+ // Test 2: Read existing file
+ let file_path = mount_path.join("testdir/file1.txt");
+ let mut file = fs::File::open(&file_path)?;
+ let mut contents = String::new();
+ file.read_to_string(&mut contents)?;
+ assert_eq!(contents, "Hello from pmxcfs!");
+ println!(" Read: '{}'", contents);
+
+ // Test 3: Write to existing file
+ let mut file = fs::OpenOptions::new()
+ .write(true)
+ .truncate(true)
+ .open(&file_path)?;
+ file.write_all(b"Modified content!")?;
+ drop(file);
+
+ // Verify write
+ let mut file = fs::File::open(&file_path)?;
+ let mut contents = String::new();
+ file.read_to_string(&mut contents)?;
+ assert_eq!(contents, "Modified content!");
+ println!(" After write: '{}'", contents);
+
+ // Test 4: Create new file
+ let new_file_path = mount_path.join("testdir/newfile.txt");
+ eprintln!("DEBUG: About to create file at {:?}", new_file_path);
+ let mut new_file = match fs::File::create(&new_file_path) {
+ Ok(f) => {
+ eprintln!("DEBUG: File created OK");
+ f
+ }
+ Err(e) => {
+ eprintln!("DEBUG: File create FAILED: {:?}", e);
+ return Err(e.into());
+ }
+ };
+ eprintln!("DEBUG: Writing content");
+ new_file.write_all(b"New file content")?;
+ eprintln!("DEBUG: Content written");
+ drop(new_file);
+ eprintln!("DEBUG: File closed");
+
+ // Verify creation
+ let mut file = fs::File::open(&new_file_path)?;
+ let mut contents = String::new();
+ file.read_to_string(&mut contents)?;
+ assert_eq!(contents, "New file content");
+ println!(" Created and verified: newfile.txt");
+
+ // Test 5: Create directory
+ let new_dir_path = mount_path.join("newdir");
+ fs::create_dir(&new_dir_path)?;
+
+ // Verify directory exists
+ assert!(new_dir_path.exists());
+ assert!(new_dir_path.is_dir());
+
+ // Test 6: List directory
+ let testdir_entries = fs::read_dir(mount_path.join("testdir"))?;
+ let mut file_names: Vec<String> = testdir_entries
+ .filter_map(|e| e.ok())
+ .map(|e| e.file_name().to_string_lossy().to_string())
+ .collect();
+ file_names.sort();
+
+ println!(" testdir entries: {:?}", file_names);
+ assert!(
+ file_names.contains(&"file1.txt".to_string()),
+ "file1.txt should exist"
+ );
+ assert!(
+ file_names.contains(&"newfile.txt".to_string()),
+ "newfile.txt should exist"
+ );
+
+ // Test 7: Get file metadata
+ let metadata = fs::metadata(&file_path)?;
+ println!(" File size: {} bytes", metadata.len());
+ println!(" Is file: {}", metadata.is_file());
+ println!(" Is dir: {}", metadata.is_dir());
+ assert!(metadata.is_file());
+ assert!(!metadata.is_dir());
+
+ // Test 8: Test plugin files
+ let plugin_files = vec![".version", ".members", ".vmlist", ".rrd", ".clusterlog"];
+
+ for plugin_name in &plugin_files {
+ let plugin_path = mount_path.join(plugin_name);
+ if plugin_path.exists() {
+ match fs::File::open(&plugin_path) {
+ Ok(mut file) => {
+ let mut contents = Vec::new();
+ file.read_to_end(&mut contents)?;
+ println!(
+ " [OK] Plugin '{}' readable ({} bytes)",
+ plugin_name,
+ contents.len()
+ );
+ }
+ Err(e) => {
+ println!(
+ " [WARN] Plugin '{}' exists but not readable: {}",
+ plugin_name, e
+ );
+ }
+ }
+ } else {
+ println!(" ℹ Plugin '{}' not present", plugin_name);
+ }
+ }
+
+ // Test 9: Delete file
+ fs::remove_file(&new_file_path)?;
+ assert!(!new_file_path.exists());
+
+ // Test 10: Delete directory
+ fs::remove_dir(&new_dir_path)?;
+ assert!(!new_dir_path.exists());
+
+ // Test 11: Verify changes persisted to memdb
+ println!("\n13. Verifying memdb persistence...");
+ assert!(
+ memdb.exists("/testdir/file1.txt")?,
+ "file1.txt should exist in memdb"
+ );
+ assert!(
+ !memdb.exists("/testdir/newfile.txt")?,
+ "newfile.txt should be deleted from memdb"
+ );
+ assert!(
+ !memdb.exists("/newdir")?,
+ "newdir should be deleted from memdb"
+ );
+
+ let read_data = memdb.read("/testdir/file1.txt", 0, 1024)?;
+ assert_eq!(
+ &read_data[..],
+ b"Modified content!",
+ "File content should be updated in memdb"
+ );
+
+ // Cleanup: unmount filesystem
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+
+ // Force unmount
+ let _ = std::process::Command::new("umount")
+ .arg("-l")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_fuse_concurrent_operations() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ memdb.create("/testdir", libc::S_IFDIR, 0, now)?;
+
+ // Spawn FUSE mount
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let fuse_task = tokio::spawn(async move {
+ let _ = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config,
+ None,
+ plugins,
+ status,
+ )
+ .await;
+ });
+
+ tokio::time::sleep(Duration::from_millis(500)).await;
+
+ // Verify FUSE mounted successfully
+ verify_fuse_mounted(&mount_path);
+
+ // Create multiple files concurrently
+ let mut tasks = vec![];
+ for i in 0..5 {
+ let mount = mount_path.clone();
+ let task = tokio::task::spawn_blocking(move || -> Result<()> {
+ let file_path = mount.join(format!("testdir/file{}.txt", i));
+ let mut file = fs::File::create(&file_path)?;
+ file.write_all(format!("Content {}", i).as_bytes())?;
+ Ok(())
+ });
+ tasks.push(task);
+ }
+
+ // Wait for all tasks
+ for task in tasks {
+ task.await??;
+ }
+
+ // Read all files and verify
+ for i in 0..5 {
+ let file_path = mount_path.join(format!("testdir/file{}.txt", i));
+ let mut file = fs::File::open(&file_path)?;
+ let mut contents = String::new();
+ file.read_to_string(&mut contents)?;
+ assert_eq!(contents, format!("Content {}", i));
+ }
+
+ // Cleanup
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ let _ = std::process::Command::new("umount")
+ .arg("-l")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_fuse_error_handling() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ // Spawn FUSE mount
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let fuse_task = tokio::spawn(async move {
+ let _ = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config,
+ None,
+ plugins,
+ status,
+ )
+ .await;
+ });
+
+ tokio::time::sleep(Duration::from_millis(500)).await;
+
+ // Verify FUSE mounted successfully
+ verify_fuse_mounted(&mount_path);
+
+ let result = fs::File::open(mount_path.join("nonexistent.txt"));
+ assert!(result.is_err(), "Should fail to open non-existent file");
+
+ let result = fs::remove_file(mount_path.join("nonexistent.txt"));
+ assert!(result.is_err(), "Should fail to delete non-existent file");
+
+ let result = fs::create_dir(mount_path.join("nonexistent/subdir"));
+ assert!(
+ result.is_err(),
+ "Should fail to create dir in non-existent parent"
+ );
+
+ // Cleanup
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ let _ = std::process::Command::new("umount")
+ .arg("-l")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/fuse_locks_test.rs b/src/pmxcfs-rs/pmxcfs/tests/fuse_locks_test.rs
new file mode 100644
index 000000000..71b603955
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/fuse_locks_test.rs
@@ -0,0 +1,377 @@
+/// FUSE Lock Operations Tests
+///
+/// Tests for pmxcfs lock operations through the FUSE interface.
+/// Locks are implemented as directories under /priv/lock/ and use
+/// setattr(mtime) for renewal and release operations.
+use anyhow::Result;
+use pmxcfs_memdb::MemDb;
+use pmxcfs_rs::fuse;
+use pmxcfs_rs::plugins;
+use std::fs;
+use std::os::unix::fs::MetadataExt;
+use std::time::Duration;
+use tempfile::TempDir;
+
+/// Verify that FUSE filesystem successfully mounted, panic if not
+fn verify_fuse_mounted(path: &std::path::Path) {
+ use std::process::Command;
+
+ let output = Command::new("mount").output().ok();
+
+ let is_mounted = if let Some(output) = output {
+ let mount_output = String::from_utf8_lossy(&output.stdout);
+ mount_output.contains(&format!(" {} ", path.display()))
+ } else {
+ false
+ };
+
+ if !is_mounted {
+ panic!(
+ "FUSE mount failed (likely permissions issue).\n\
+ To run FUSE integration tests, either:\n\
+ 1. Run with sudo: sudo -E cargo test --test fuse_locks_test\n\
+ 2. Enable user_allow_other in /etc/fuse.conf\n\
+ 3. Or skip these tests: cargo test --lib"
+ );
+ }
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_lock_creation_and_access() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ // Create lock directory structure in memdb
+ memdb.create("/priv", libc::S_IFDIR, 0, now)?;
+ memdb.create("/priv/lock", libc::S_IFDIR, 0, now)?;
+
+ // Spawn FUSE mount
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let fuse_task = tokio::spawn(async move {
+ let _ = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config,
+ None, // no cluster
+ plugins,
+ status,
+ )
+ .await;
+ });
+
+ tokio::time::sleep(Duration::from_millis(500)).await;
+ verify_fuse_mounted(&mount_path);
+
+ // Test 1: Create lock directory via FUSE (mkdir)
+ let lock_path = mount_path.join("priv/lock/test-resource");
+ fs::create_dir(&lock_path)?;
+ println!("[OK] Lock directory created via FUSE");
+
+ // Test 2: Verify lock exists and is a directory
+ assert!(lock_path.exists(), "Lock should exist");
+ assert!(lock_path.is_dir(), "Lock should be a directory");
+ println!("[OK] Lock directory accessible");
+
+ // Test 3: Verify lock is in memdb
+ assert!(
+ memdb.exists("/priv/lock/test-resource")?,
+ "Lock should exist in memdb"
+ );
+ println!("[OK] Lock persisted to memdb");
+
+ // Test 4: Verify lock path detection
+ assert!(
+ pmxcfs_memdb::is_lock_path("/priv/lock/test-resource"),
+ "Path should be detected as lock path"
+ );
+ println!("[OK] Lock path correctly identified");
+
+ // Test 5: List locks via FUSE readdir
+ let lock_dir_entries: Vec<_> = fs::read_dir(mount_path.join("priv/lock"))?
+ .filter_map(|e| e.ok())
+ .map(|e| e.file_name().to_string_lossy().to_string())
+ .collect();
+ assert!(
+ lock_dir_entries.contains(&"test-resource".to_string()),
+ "Lock should appear in directory listing"
+ );
+ println!("[OK] Lock visible in readdir");
+
+ // Cleanup
+ fs::remove_dir(&lock_path)?;
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ let _ = std::process::Command::new("umount")
+ .arg("-l")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_lock_renewal_via_mtime_update() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ // Create lock directory structure
+ memdb.create("/priv", libc::S_IFDIR, 0, now)?;
+ memdb.create("/priv/lock", libc::S_IFDIR, 0, now)?;
+
+ // Spawn FUSE mount
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let fuse_task = tokio::spawn(async move {
+ let _ = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config,
+ None,
+ plugins,
+ status,
+ )
+ .await;
+ });
+
+ tokio::time::sleep(Duration::from_millis(500)).await;
+ verify_fuse_mounted(&mount_path);
+
+ // Create lock via FUSE
+ let lock_path = mount_path.join("priv/lock/renewal-test");
+ fs::create_dir(&lock_path)?;
+ println!("[OK] Lock directory created");
+
+ // Get initial metadata
+ let metadata1 = fs::metadata(&lock_path)?;
+ let mtime1 = metadata1.mtime();
+ println!(" Initial mtime: {}", mtime1);
+
+ // Wait a moment
+ tokio::time::sleep(Duration::from_millis(100)).await;
+
+ // Test lock renewal: update mtime using filetime crate
+ // (This simulates the lock renewal mechanism used by Proxmox VE)
+ use filetime::{FileTime, set_file_mtime};
+ let new_time = FileTime::now();
+ set_file_mtime(&lock_path, new_time)?;
+ println!("[OK] Lock mtime updated (renewal)");
+
+ // Verify mtime was updated
+ let metadata2 = fs::metadata(&lock_path)?;
+ let mtime2 = metadata2.mtime();
+ println!(" Updated mtime: {}", mtime2);
+
+ // Note: Due to filesystem timestamp granularity, we just verify the operation succeeded
+ // The actual lock renewal logic is tested at the memdb level
+ println!("[OK] Lock renewal operation completed");
+
+ // Cleanup
+ fs::remove_dir(&lock_path)?;
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ let _ = std::process::Command::new("umount")
+ .arg("-l")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_lock_unlock_via_mtime_zero() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ // Create lock directory structure
+ memdb.create("/priv", libc::S_IFDIR, 0, now)?;
+ memdb.create("/priv/lock", libc::S_IFDIR, 0, now)?;
+
+ // Spawn FUSE mount (without DFSM so unlock happens locally)
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let fuse_task = tokio::spawn(async move {
+ let _ = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config,
+ None,
+ plugins,
+ status,
+ )
+ .await;
+ });
+
+ tokio::time::sleep(Duration::from_millis(500)).await;
+ verify_fuse_mounted(&mount_path);
+
+ // Create lock via FUSE
+ let lock_path = mount_path.join("priv/lock/unlock-test");
+ fs::create_dir(&lock_path)?;
+ println!("[OK] Lock directory created");
+
+ // Verify lock exists
+ assert!(lock_path.exists(), "Lock should exist");
+ assert!(
+ memdb.exists("/priv/lock/unlock-test")?,
+ "Lock should exist in memdb"
+ );
+
+ // Test unlock: set mtime to 0 (Unix epoch)
+ // This is the unlock signal in pmxcfs
+ use filetime::{FileTime, set_file_mtime};
+ let zero_time = FileTime::from_unix_time(0, 0);
+ set_file_mtime(&lock_path, zero_time)?;
+ println!("[OK] Lock unlock requested (mtime=0)");
+
+ // Give time for unlock processing
+ tokio::time::sleep(Duration::from_millis(200)).await;
+
+ // When no DFSM, lock should be deleted locally if expired
+ // Since we just created it, it won't be expired, so it should still exist
+ // (This matches the C behavior: only delete if lock_expired() returns true)
+ assert!(
+ lock_path.exists(),
+ "Lock should still exist (not expired yet)"
+ );
+ println!("[OK] Unlock handled correctly (lock not expired, kept)");
+
+ // Cleanup
+ fs::remove_dir(&lock_path)?;
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ let _ = std::process::Command::new("umount")
+ .arg("-l")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_multiple_locks() -> Result<()> {
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("test.db");
+ let mount_path = temp_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ // Create lock directory structure
+ memdb.create("/priv", libc::S_IFDIR, 0, now)?;
+ memdb.create("/priv/lock", libc::S_IFDIR, 0, now)?;
+
+ // Spawn FUSE mount
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let fuse_task = tokio::spawn(async move {
+ let _ = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config,
+ None,
+ plugins,
+ status,
+ )
+ .await;
+ });
+
+ tokio::time::sleep(Duration::from_millis(500)).await;
+ verify_fuse_mounted(&mount_path);
+
+ // Test: Create multiple locks simultaneously
+ let lock_names = vec!["vm-100-disk-0", "vm-101-disk-0", "vm-102-disk-0"];
+
+ for name in &lock_names {
+ let lock_path = mount_path.join(format!("priv/lock/{}", name));
+ fs::create_dir(&lock_path)?;
+ println!("[OK] Lock '{}' created", name);
+ }
+
+ // Verify all locks exist
+ let lock_dir_entries: Vec<_> = fs::read_dir(mount_path.join("priv/lock"))?
+ .filter_map(|e| e.ok())
+ .map(|e| e.file_name().to_string_lossy().to_string())
+ .collect();
+
+ for name in &lock_names {
+ assert!(
+ lock_dir_entries.contains(&name.to_string()),
+ "Lock '{}' should be in directory listing",
+ name
+ );
+ assert!(
+ memdb.exists(&format!("/priv/lock/{}", name))?,
+ "Lock '{}' should exist in memdb",
+ name
+ );
+ }
+ println!("[OK] All locks accessible");
+
+ // Cleanup
+ for name in &lock_names {
+ let lock_path = mount_path.join(format!("priv/lock/{}", name));
+ fs::remove_dir(&lock_path)?;
+ }
+
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ let _ = std::process::Command::new("umount")
+ .arg("-l")
+ .arg(&mount_path)
+ .output();
+
+ Ok(())
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/local_integration.rs b/src/pmxcfs-rs/pmxcfs/tests/local_integration.rs
new file mode 100644
index 000000000..9f19f5802
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/local_integration.rs
@@ -0,0 +1,277 @@
+// Local integration tests that don't require containers
+// Tests for MemDb functionality and basic plugin integration
+
+mod common;
+
+use anyhow::Result;
+use pmxcfs_memdb::MemDb;
+use pmxcfs_rs::plugins;
+
+use common::*;
+
+/// Test basic MemDb CRUD operations
+#[test]
+fn test_memdb_create_read_write() -> Result<()> {
+ let (_temp_dir, memdb) = create_minimal_test_db()?;
+
+ // Create a file
+ memdb.create("/test-file.txt", libc::S_IFREG, 0, TEST_MTIME)?;
+
+ // Write content
+ let content = b"Hello, World!";
+ memdb.write("/test-file.txt", 0, 0, TEST_MTIME, content, false)?;
+
+ // Read it back
+ let data = memdb.read("/test-file.txt", 0, 1024)?;
+ assert_eq!(data, content, "File content should match");
+
+ Ok(())
+}
+
+/// Test directory operations
+#[test]
+fn test_memdb_directories() -> Result<()> {
+ let (_temp_dir, memdb) = create_minimal_test_db()?;
+
+ // Create directory structure
+ memdb.create("/nodes", libc::S_IFDIR, 0, TEST_MTIME)?;
+ memdb.create("/nodes/testnode", libc::S_IFDIR, 0, TEST_MTIME)?;
+ memdb.create("/nodes/testnode/qemu-server", libc::S_IFDIR, 0, TEST_MTIME)?;
+
+ // List directory
+ let entries = memdb.readdir("/nodes/testnode")?;
+ assert_eq!(entries.len(), 1, "Should have 1 entry");
+ assert_eq!(entries[0].name, "qemu-server");
+
+ // Verify directory exists
+ assert!(memdb.exists("/nodes")?);
+ assert!(memdb.exists("/nodes/testnode")?);
+ assert!(memdb.exists("/nodes/testnode/qemu-server")?);
+
+ Ok(())
+}
+
+/// Test file operations: rename and delete
+#[test]
+fn test_memdb_file_operations() -> Result<()> {
+ let (_temp_dir, memdb) = create_minimal_test_db()?;
+
+ // Create and write file
+ memdb.create("/old-name.txt", libc::S_IFREG, 0, TEST_MTIME)?;
+ memdb.write("/old-name.txt", 0, 0, TEST_MTIME, b"test", false)?;
+
+ // Test rename
+ memdb.rename("/old-name.txt", "/new-name.txt", 0, 1000)?;
+ assert!(!memdb.exists("/old-name.txt")?, "Old name should not exist");
+ assert!(memdb.exists("/new-name.txt")?, "New name should exist");
+
+ // Verify content survived rename
+ let data = memdb.read("/new-name.txt", 0, 1024)?;
+ assert_eq!(data, b"test");
+
+ // Test delete
+ memdb.delete("/new-name.txt", 0, 1000)?;
+ assert!(!memdb.exists("/new-name.txt")?, "File should be deleted");
+
+ Ok(())
+}
+
+/// Test database persistence across reopens
+#[test]
+fn test_memdb_persistence() -> Result<()> {
+ let temp_dir = tempfile::TempDir::new()?;
+ let db_path = temp_dir.path().join("persist.db");
+
+ // Create and populate database
+ {
+ let memdb = MemDb::open(&db_path, true)?;
+ memdb.create("/persistent.txt", libc::S_IFREG, 0, TEST_MTIME)?;
+ memdb.write("/persistent.txt", 0, 0, TEST_MTIME, b"persistent data", false)?;
+ }
+
+ // Reopen database and verify data persists
+ {
+ let memdb = MemDb::open(&db_path, false)?;
+ let data = memdb.read("/persistent.txt", 0, 1024)?;
+ assert_eq!(
+ data, b"persistent data",
+ "Data should persist across reopens"
+ );
+ }
+
+ Ok(())
+}
+
+/// Test write with offset (partial write/append)
+#[test]
+fn test_memdb_write_offset() -> Result<()> {
+ let (_temp_dir, memdb) = create_minimal_test_db()?;
+
+ memdb.create("/offset-test.txt", libc::S_IFREG, 0, TEST_MTIME)?;
+
+ // Write at offset 0
+ memdb.write("/offset-test.txt", 0, 0, TEST_MTIME, b"Hello", false)?;
+
+ // Write at offset 5 (append)
+ memdb.write("/offset-test.txt", 5, 0, TEST_MTIME, b", World!", false)?;
+
+ // Read full content
+ let data = memdb.read("/offset-test.txt", 0, 1024)?;
+ assert_eq!(data, b"Hello, World!");
+
+ Ok(())
+}
+
+/// Test write with truncation
+///
+/// Now tests CORRECT behavior after fixing the API bug.
+/// truncate=true should clear the file before writing.
+#[test]
+fn test_memdb_write_truncate() -> Result<()> {
+ let (_temp_dir, memdb) = create_minimal_test_db()?;
+
+ memdb.create("/truncate-test.txt", libc::S_IFREG, 0, TEST_MTIME)?;
+
+ // Write initial content
+ memdb.write("/truncate-test.txt", 0, 0, TEST_MTIME, b"Hello, World!", false)?;
+
+ // Overwrite with truncate=true (should clear first, then write)
+ memdb.write("/truncate-test.txt", 0, 0, TEST_MTIME, b"Hi", true)?;
+
+ // Should only have "Hi"
+ let data = memdb.read("/truncate-test.txt", 0, 1024)?;
+ assert_eq!(data, b"Hi", "Truncate should clear file before writing");
+
+ Ok(())
+}
+
+/// Test file size limit (C implementation limits to 1MB)
+#[test]
+fn test_memdb_file_size_limit() -> Result<()> {
+ let (_temp_dir, memdb) = create_minimal_test_db()?;
+
+ memdb.create("/large.bin", libc::S_IFREG, 0, TEST_MTIME)?;
+
+ // Exactly 1MB should be accepted
+ let one_mb = vec![0u8; 1024 * 1024];
+ assert!(
+ memdb
+ .write("/large.bin", 0, 0, TEST_MTIME, &one_mb, false)
+ .is_ok(),
+ "1MB file should be accepted"
+ );
+
+ // Over 1MB should fail
+ let over_one_mb = vec![0u8; 1024 * 1024 + 1];
+ assert!(
+ memdb
+ .write("/large.bin", 0, 0, TEST_MTIME, &over_one_mb, false)
+ .is_err(),
+ "Over 1MB file should be rejected"
+ );
+
+ Ok(())
+}
+
+/// Test plugin initialization and basic functionality
+#[test]
+fn test_plugin_initialization() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+
+ let plugin_registry = plugins::init_plugins(config, status);
+
+ // Verify plugins are registered
+ let plugin_list = plugin_registry.list();
+ assert!(!plugin_list.is_empty(), "Should have plugins registered");
+
+ // Verify expected plugins exist
+ assert!(
+ plugin_registry.get(".version").is_some(),
+ "Should have .version plugin"
+ );
+ assert!(
+ plugin_registry.get(".vmlist").is_some(),
+ "Should have .vmlist plugin"
+ );
+ assert!(
+ plugin_registry.get(".rrd").is_some(),
+ "Should have .rrd plugin"
+ );
+ assert!(
+ plugin_registry.get(".members").is_some(),
+ "Should have .members plugin"
+ );
+ assert!(
+ plugin_registry.get(".clusterlog").is_some(),
+ "Should have .clusterlog plugin"
+ );
+
+ Ok(())
+}
+
+/// Test .version plugin output
+#[test]
+fn test_version_plugin() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let plugins = plugins::init_plugins(config, status);
+
+ let version_plugin = plugins
+ .get(".version")
+ .expect(".version plugin should exist");
+
+ let version_data = version_plugin.read()?;
+ let version_str = String::from_utf8_lossy(&version_data);
+
+ // Verify it's valid JSON
+ let version_json: serde_json::Value = serde_json::from_slice(&version_data)?;
+ assert!(version_json.is_object(), "Version should be JSON object");
+
+ // Verify it contains expected fields
+ assert!(
+ version_str.contains("version"),
+ "Should contain 'version' field"
+ );
+
+ Ok(())
+}
+
+/// Test error case: reading non-existent file
+#[test]
+fn test_memdb_error_nonexistent_file() {
+ let (_temp_dir, memdb) = create_minimal_test_db().unwrap();
+
+ let result = memdb.read("/does-not-exist.txt", 0, 1024);
+ assert!(result.is_err(), "Reading non-existent file should fail");
+}
+
+/// Test error case: creating file in non-existent directory
+#[test]
+fn test_memdb_error_no_parent_directory() {
+ let (_temp_dir, memdb) = create_minimal_test_db().unwrap();
+
+ let result = memdb.create("/nonexistent/file.txt", libc::S_IFREG, 0, TEST_MTIME);
+ assert!(
+ result.is_err(),
+ "Creating file in non-existent directory should fail"
+ );
+}
+
+/// Test error case: writing to non-existent file
+#[test]
+fn test_memdb_error_write_nonexistent() {
+ let (_temp_dir, memdb) = create_minimal_test_db().unwrap();
+
+ let result = memdb.write("/does-not-exist.txt", 0, 0, TEST_MTIME, b"test", false);
+ assert!(result.is_err(), "Writing to non-existent file should fail");
+}
+
+/// Test error case: deleting non-existent file
+#[test]
+fn test_memdb_error_delete_nonexistent() {
+ let (_temp_dir, memdb) = create_minimal_test_db().unwrap();
+
+ let result = memdb.delete("/does-not-exist.txt", 0, 1000);
+ assert!(result.is_err(), "Deleting non-existent file should fail");
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/quorum_behavior.rs b/src/pmxcfs-rs/pmxcfs/tests/quorum_behavior.rs
new file mode 100644
index 000000000..d397ad099
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/quorum_behavior.rs
@@ -0,0 +1,274 @@
+/// Quorum-Dependent Behavior Tests
+///
+/// Tests for pmxcfs behavior that changes based on quorum state.
+/// These tests verify plugin behavior (especially symlinks) and
+/// operations that should be blocked/allowed based on quorum.
+///
+/// Note: These tests do NOT require FUSE mounting - they test the
+/// plugin layer directly, which is accessible without root permissions.
+mod common;
+
+use anyhow::Result;
+use common::*;
+use pmxcfs_rs::plugins;
+
+/// Test .members plugin behavior with and without quorum
+///
+/// According to C implementation:
+/// - With quorum: .members is regular file containing member list
+/// - Without quorum: .members becomes symlink to /etc/pve/error (ENOTCONN)
+#[test]
+fn test_members_plugin_quorum_behavior() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let plugins = plugins::init_plugins(config, status.clone());
+
+ let members_plugin = plugins
+ .get(".members")
+ .expect(".members plugin should exist");
+
+ // Test 1: With quorum, .members should be accessible
+ status.set_quorate(true);
+
+ let data = members_plugin.read()?;
+ assert!(!data.is_empty(), "With quorum, .members should return data");
+
+ // Verify it's valid JSON
+ let members_json: serde_json::Value = serde_json::from_slice(&data)?;
+ assert!(
+ members_json.is_object() || members_json.is_array(),
+ ".members should contain valid JSON"
+ );
+
+ // Test 2: Without quorum, behavior changes
+ // Note: Current implementation may not fully implement symlink behavior
+ // This test documents actual behavior
+ status.set_quorate(false);
+
+ let result = members_plugin.read();
+ // In local mode, .members might still be readable
+ // In cluster mode without quorum, it should error or return error indication
+ match result {
+ Ok(data) => {
+ // If readable, should still be valid structure
+ assert!(!data.is_empty(), "Data should not be empty if readable");
+ }
+ Err(_) => {
+ // Expected in non-local mode without quorum
+ }
+ }
+
+ Ok(())
+}
+
+/// Test .vmlist plugin behavior with and without quorum
+#[test]
+fn test_vmlist_plugin_quorum_behavior() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let plugins = plugins::init_plugins(config, status.clone());
+
+ // Register a test VM
+ clear_test_vms(&status);
+ status.register_vm(100, pmxcfs_status::VmType::Qemu, TEST_NODE_NAME.to_string());
+
+ let vmlist_plugin = plugins.get(".vmlist").expect(".vmlist plugin should exist");
+
+ // Test 1: With quorum, .vmlist works normally
+ status.set_quorate(true);
+
+ let data = vmlist_plugin.read()?;
+ let vmlist_str = String::from_utf8(data)?;
+
+ // Verify valid JSON
+ let vmlist_json: serde_json::Value = serde_json::from_str(&vmlist_str)?;
+ assert!(vmlist_json.is_object(), ".vmlist should be JSON object");
+
+ // Verify our test VM is present
+ assert!(
+ vmlist_str.contains("\"100\""),
+ "Should contain registered VM 100"
+ );
+
+ // Test 2: Without quorum (in local mode, should still work)
+ status.set_quorate(false);
+
+ let result = vmlist_plugin.read();
+ // In local mode, vmlist should still be accessible
+ assert!(
+ result.is_ok(),
+ "In local mode, .vmlist should work without quorum"
+ );
+
+ Ok(())
+}
+
+/// Test .version plugin is unaffected by quorum state
+#[test]
+fn test_version_plugin_unaffected_by_quorum() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let plugins = plugins::init_plugins(config, status.clone());
+
+ let version_plugin = plugins
+ .get(".version")
+ .expect(".version plugin should exist");
+
+ // Test with quorum
+ status.set_quorate(true);
+ let data_with = version_plugin.read()?;
+ let version_with: serde_json::Value = serde_json::from_slice(&data_with)?;
+ assert!(version_with.is_object(), "Version should be JSON object");
+ assert!(
+ version_with.get("version").is_some(),
+ "Should have version field"
+ );
+
+ // Test without quorum
+ status.set_quorate(false);
+ let data_without = version_plugin.read()?;
+ let version_without: serde_json::Value = serde_json::from_slice(&data_without)?;
+ assert!(version_without.is_object(), "Version should be JSON object");
+ assert!(
+ version_without.get("version").is_some(),
+ "Should have version field"
+ );
+
+ // Version should be same regardless of quorum
+ assert_eq!(
+ version_with.get("version"),
+ version_without.get("version"),
+ "Version should be same with/without quorum"
+ );
+
+ Ok(())
+}
+
+/// Test .rrd plugin behavior
+#[test]
+fn test_rrd_plugin_functionality() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let plugins = plugins::init_plugins(config, status.clone());
+
+ let rrd_plugin = plugins.get(".rrd").expect(".rrd plugin should exist");
+
+ status.set_quorate(true);
+
+ // RRD plugin should be readable (may be empty initially)
+ let data = rrd_plugin.read()?;
+ // Data should be valid (even if empty)
+ let rrd_str = String::from_utf8(data)?;
+ // Empty or contains RRD data lines
+ assert!(rrd_str.is_empty() || rrd_str.lines().count() > 0);
+
+ Ok(())
+}
+
+/// Test .clusterlog plugin behavior
+#[test]
+fn test_clusterlog_plugin_functionality() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let plugins = plugins::init_plugins(config, status.clone());
+
+ let log_plugin = plugins
+ .get(".clusterlog")
+ .expect(".clusterlog plugin should exist");
+
+ status.set_quorate(true);
+
+ // Clusterlog should be readable
+ let data = log_plugin.read()?;
+ // Should be valid text (even if empty)
+ let _log_str = String::from_utf8(data)?;
+
+ Ok(())
+}
+
+/// Test quorum state changes work correctly
+#[test]
+fn test_quorum_state_transitions() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let _plugins = plugins::init_plugins(config, status.clone());
+
+ // Test state transitions
+ status.set_quorate(false);
+ assert!(
+ !status.is_quorate(),
+ "Should not be quorate after set_quorate(false)"
+ );
+
+ status.set_quorate(true);
+ assert!(
+ status.is_quorate(),
+ "Should be quorate after set_quorate(true)"
+ );
+
+ status.set_quorate(false);
+ assert!(!status.is_quorate(), "Should not be quorate again");
+
+ // Multiple calls to same state should be idempotent
+ status.set_quorate(true);
+ status.set_quorate(true);
+ assert!(
+ status.is_quorate(),
+ "Multiple set_quorate(true) should work"
+ );
+
+ Ok(())
+}
+
+/// Test plugin registry lists all expected plugins
+#[test]
+fn test_plugin_registry_completeness() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let plugins = plugins::init_plugins(config, status);
+
+ let plugin_list = plugins.list();
+
+ // Verify minimum expected plugins exist
+ let expected_plugins = vec![".version", ".members", ".vmlist", ".rrd", ".clusterlog"];
+
+ for plugin_name in expected_plugins {
+ assert!(
+ plugin_list.contains(&plugin_name.to_string()),
+ "Plugin registry should contain {}",
+ plugin_name
+ );
+ }
+
+ assert!(!plugin_list.is_empty(), "Should have at least some plugins");
+ assert!(
+ plugin_list.len() >= 5,
+ "Should have at least 5 core plugins"
+ );
+
+ Ok(())
+}
+
+/// Test async quorum change notification
+#[tokio::test]
+async fn test_quorum_change_async() -> Result<()> {
+ let config = create_test_config(true);
+ let status = create_test_status();
+ let _plugins = plugins::init_plugins(config, status.clone());
+
+ // Initial state
+ status.set_quorate(true);
+ assert!(status.is_quorate());
+
+ // Simulate async quorum loss
+ status.set_quorate(false);
+ tokio::time::sleep(std::time::Duration::from_millis(10)).await;
+ assert!(!status.is_quorate(), "Quorum loss should be immediate");
+
+ // Simulate async quorum regain
+ status.set_quorate(true);
+ tokio::time::sleep(std::time::Duration::from_millis(10)).await;
+ assert!(status.is_quorate(), "Quorum regain should be immediate");
+
+ Ok(())
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/single_node_functional.rs b/src/pmxcfs-rs/pmxcfs/tests/single_node_functional.rs
new file mode 100644
index 000000000..fac828495
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/single_node_functional.rs
@@ -0,0 +1,361 @@
+/// Single-node functional test
+///
+/// This test simulates a complete single-node pmxcfs deployment
+/// without requiring root privileges or actual FUSE mounting.
+use anyhow::Result;
+use pmxcfs_config::Config;
+use pmxcfs_memdb::MemDb;
+use pmxcfs_rs::plugins::{PluginRegistry, init_plugins};
+use pmxcfs_status::{Status, VmType};
+use std::sync::Arc;
+use tempfile::TempDir;
+
+/// Helper to initialize plugins for testing
+fn init_test_plugins(nodename: &str, status: Arc<Status>) -> Arc<PluginRegistry> {
+ let config = Config::shared(
+ nodename.to_string(),
+ "127.0.0.1".parse().unwrap(),
+ 33, // www-data gid
+ false,
+ false,
+ "pmxcfs".to_string(),
+ );
+ init_plugins(config, status)
+}
+
+/// Test complete single-node workflow
+#[tokio::test]
+async fn test_single_node_workflow() -> Result<()> {
+ println!("\n=== Single-Node Functional Test ===\n");
+
+ // Initialize status subsystem
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ // Clear any VMs from previous tests
+ let existing_vms: Vec<u32> = status.get_vmlist().keys().copied().collect();
+ for vmid in existing_vms {
+ status.delete_vm(vmid);
+ }
+
+ let plugins = init_test_plugins("localhost", status.clone());
+ println!(
+ " [OK] Plugin system initialized ({} plugins)",
+ plugins.list().len()
+ );
+
+ // Create temporary database
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("pmxcfs.db");
+ println!("\n2. Creating database at {}", db_path.display());
+
+ let db = MemDb::open(&db_path, true)?;
+
+ // Test directory structure creation
+ println!("\n3. Creating directory structure...");
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ db.create("/nodes", libc::S_IFDIR, 0, now)?;
+ db.create("/nodes/localhost", libc::S_IFDIR, 0, now)?;
+ db.create("/nodes/localhost/qemu-server", libc::S_IFDIR, 0, now)?;
+ db.create("/nodes/localhost/lxc", libc::S_IFDIR, 0, now)?;
+ db.create("/nodes/localhost/priv", libc::S_IFDIR, 0, now)?;
+
+ db.create("/priv", libc::S_IFDIR, 0, now)?;
+ db.create("/priv/lock", libc::S_IFDIR, 0, now)?;
+ db.create("/priv/lock/qemu-server", libc::S_IFDIR, 0, now)?;
+ db.create("/priv/lock/lxc", libc::S_IFDIR, 0, now)?;
+ db.create("/qemu-server", libc::S_IFDIR, 0, now)?;
+ db.create("/lxc", libc::S_IFDIR, 0, now)?;
+
+ // Test configuration file creation
+ println!("\n4. Creating configuration files...");
+
+ // Create corosync.conf
+ let corosync_conf = b"totem {\n version: 2\n cluster_name: test\n}\n";
+ db.create("/corosync.conf", libc::S_IFREG, 0, now)?;
+ db.write("/corosync.conf", 0, 0, now, corosync_conf, false)?;
+ println!(
+ " [OK] Created /corosync.conf ({} bytes)",
+ corosync_conf.len()
+ );
+
+ // Create datacenter.cfg
+ let datacenter_cfg = b"keyboard: en-us\n";
+ db.create("/datacenter.cfg", libc::S_IFREG, 0, now)?;
+ db.write("/datacenter.cfg", 0, 0, now, datacenter_cfg, false)?;
+ println!(
+ " [OK] Created /datacenter.cfg ({} bytes)",
+ datacenter_cfg.len()
+ );
+
+ // Create some VM configs
+ let vm_config = b"cores: 2\nmemory: 2048\nnet0: virtio=00:00:00:00:00:01,bridge=vmbr0\n";
+ db.create("/qemu-server/100.conf", libc::S_IFREG, 0, now)?;
+ db.write("/qemu-server/100.conf", 0, 0, now, vm_config, false)?;
+
+ db.create("/qemu-server/101.conf", libc::S_IFREG, 0, now)?;
+ db.write("/qemu-server/101.conf", 0, 0, now, vm_config, false)?;
+
+ // Create LXC container config
+ let ct_config = b"cores: 1\nmemory: 512\nrootfs: local:100/vm-100-disk-0.raw\n";
+ db.create("/lxc/200.conf", libc::S_IFREG, 0, now)?;
+ db.write("/lxc/200.conf", 0, 0, now, ct_config, false)?;
+
+ // Create private file
+ let private_data = b"secret token data";
+ db.create("/priv/token.cfg", libc::S_IFREG, 0, now)?;
+ db.write("/priv/token.cfg", 0, 0, now, private_data, false)?;
+
+ // Test file operations
+
+ // Read back corosync.conf
+ let read_data = db.read("/corosync.conf", 0, 1024)?;
+ assert_eq!(&read_data[..], corosync_conf);
+
+ // Test file size limit (1MB)
+ let large_data = vec![0u8; 1024 * 1024]; // Exactly 1MB
+ db.create("/large.bin", libc::S_IFREG, 0, now)?;
+ let result = db.write("/large.bin", 0, 0, now, &large_data, false);
+ assert!(result.is_ok(), "1MB file should be accepted");
+
+ // Test directory listing
+ let entries = db.readdir("/qemu-server")?;
+ assert_eq!(entries.len(), 2, "Should have 2 VM configs");
+
+ // Test rename
+ db.rename("/qemu-server/101.conf", "/qemu-server/102.conf", 0, 1000)?;
+ assert!(db.exists("/qemu-server/102.conf")?);
+ assert!(!db.exists("/qemu-server/101.conf")?);
+
+ // Test delete
+ db.delete("/large.bin", 0, 1000)?;
+ assert!(!db.exists("/large.bin")?);
+
+ // Test VM list management
+
+ // Clear VMs again right before this section to avoid test interference
+ let existing_vms: Vec<u32> = status.get_vmlist().keys().copied().collect();
+ for vmid in existing_vms {
+ status.delete_vm(vmid);
+ }
+
+ status.register_vm(100, VmType::Qemu, "localhost".to_string());
+ status.register_vm(102, VmType::Qemu, "localhost".to_string());
+ status.register_vm(200, VmType::Lxc, "localhost".to_string());
+
+ let vmlist = status.get_vmlist();
+ assert_eq!(vmlist.len(), 3, "Should have 3 VMs registered");
+
+ // Verify VM types
+ assert_eq!(vmlist.get(&100).unwrap().vmtype, VmType::Qemu);
+ assert_eq!(vmlist.get(&200).unwrap().vmtype, VmType::Lxc);
+
+ // Test lock management
+
+ let lock_path = "/priv/lock/qemu-server/100.conf";
+ let csum = [1u8; 32];
+
+ db.acquire_lock(lock_path, &csum)?;
+ assert!(db.is_locked(lock_path));
+
+ db.release_lock(lock_path, &csum)?;
+ assert!(!db.is_locked(lock_path));
+
+ // Test checksum operations
+
+ let checksum = db.compute_database_checksum()?;
+ println!(
+ " [OK] Database checksum: {:02x}{:02x}{:02x}{:02x}...",
+ checksum[0], checksum[1], checksum[2], checksum[3]
+ );
+
+ // Modify database and verify checksum changes
+ db.write("/datacenter.cfg", 0, 0, now, b"keyboard: de\n", false)?;
+ let new_checksum = db.compute_database_checksum()?;
+ assert_ne!(
+ checksum, new_checksum,
+ "Checksum should change after modification"
+ );
+
+ // Test database encoding
+ let _encoded = db.encode_database()?;
+
+ // Test RRD data collection
+
+ // Set RRD data in C-compatible format
+ // Format: "key:timestamp:val1:val2:val3:..."
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs();
+
+ status
+ .set_rrd_data(
+ "pve2-node/localhost".to_string(),
+ format!(
+ "{}:0:1.5:4:45.5:2.1:8000000000:6000000000:0:0:0:0:1000000:500000",
+ now
+ ),
+ )
+ .await?;
+
+ let rrd_dump = status.get_rrd_dump();
+ assert!(
+ rrd_dump.contains("pve2-node/localhost"),
+ "Should have node data"
+ );
+ let num_entries = rrd_dump.lines().count();
+
+ // Test cluster log
+ use pmxcfs_status::ClusterLogEntry;
+ let log_entry = ClusterLogEntry {
+ uid: 0,
+ timestamp: now,
+ priority: 6, // Info priority
+ tag: "startup".to_string(),
+ pid: 0,
+ node: "localhost".to_string(),
+ ident: "pmxcfs".to_string(),
+ message: "Cluster filesystem started".to_string(),
+ };
+ status.add_log_entry(log_entry);
+
+ let log_entries = status.get_log_entries(100);
+ assert_eq!(log_entries.len(), 1);
+
+ // Test plugin system
+
+ // Test .version plugin
+ if let Some(plugin) = plugins.get(".version") {
+ let content = plugin.read()?;
+ let version_str = String::from_utf8(content)?;
+ assert!(version_str.contains("version"));
+ assert!(version_str.contains("9.0.6"));
+ }
+
+ // Test .vmlist plugin
+ if let Some(plugin) = plugins.get(".vmlist") {
+ let content = plugin.read()?;
+ let vmlist_str = String::from_utf8(content)?;
+ assert!(vmlist_str.contains("\"100\""));
+ assert!(vmlist_str.contains("\"200\""));
+ assert!(vmlist_str.contains("qemu"));
+ assert!(vmlist_str.contains("lxc"));
+ println!(
+ " [OK] .vmlist plugin: {} bytes, {} VMs",
+ vmlist_str.len(),
+ 3
+ );
+ }
+
+ // Test .rrd plugin
+ if let Some(plugin) = plugins.get(".rrd") {
+ let content = plugin.read()?;
+ let rrd_str = String::from_utf8(content)?;
+ // Should contain the node RRD data in C-compatible format
+ assert!(
+ rrd_str.contains("pve2-node/localhost"),
+ "RRD should contain node data"
+ );
+ }
+
+ // Test database persistence
+
+ drop(db); // Close database
+
+ // Reopen and verify data persists
+ let db = MemDb::open(&db_path, false)?;
+ assert!(db.exists("/corosync.conf")?);
+ assert!(db.exists("/qemu-server/100.conf")?);
+ assert!(db.exists("/lxc/200.conf")?);
+
+ let read_conf = db.read("/corosync.conf", 0, 1024)?;
+ assert_eq!(&read_conf[..], corosync_conf);
+
+ // Test state export
+
+ let all_entries = db.get_all_entries()?;
+
+ // Verify entry structure
+ let root_entry = db.lookup_path("/").expect("Root should exist");
+ assert_eq!(root_entry.inode, 0); // Root inode is 0
+ assert!(root_entry.is_dir());
+
+ println!("\n=== Single-Node Test Complete ===\n");
+ println!("\nTest Summary:");
+ println!("\nDatabase Statistics:");
+ println!(" • Total entries: {}", all_entries.len());
+ println!(" • VMs/CTs tracked: {}", vmlist.len());
+ println!(" • RRD entries: {}", num_entries);
+ println!(" • Cluster log entries: 1");
+ println!(
+ " • Database size: {} bytes",
+ std::fs::metadata(&db_path)?.len()
+ );
+
+ Ok(())
+}
+
+/// Test simulated multi-operation workflow
+#[tokio::test]
+async fn test_realistic_workflow() -> Result<()> {
+ println!("\n=== Realistic Workflow Test ===\n");
+
+ let temp_dir = TempDir::new()?;
+ let db_path = temp_dir.path().join("pmxcfs.db");
+ let db = MemDb::open(&db_path, true)?;
+
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config);
+
+ // Clear any VMs from previous tests
+ let existing_vms: Vec<u32> = status.get_vmlist().keys().copied().collect();
+ for vmid in existing_vms {
+ status.delete_vm(vmid);
+ }
+
+ let now = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)?
+ .as_secs() as u32;
+
+ println!("Scenario: Creating a new VM");
+
+ // 1. Check if VMID is available
+ let vmid = 103;
+ assert!(!status.vm_exists(vmid));
+
+ // 2. Acquire lock for VM creation
+ let lock_path = format!("/priv/lock/qemu-server/{}.conf", vmid);
+ let csum = [1u8; 32];
+
+ // Create lock directories first
+ db.create("/priv", libc::S_IFDIR, 0, now).ok();
+ db.create("/priv/lock", libc::S_IFDIR, 0, now).ok();
+ db.create("/priv/lock/qemu-server", libc::S_IFDIR, 0, now).ok();
+
+ db.acquire_lock(&lock_path, &csum)?;
+
+ // 3. Create VM configuration
+ let config_path = format!("/qemu-server/{}.conf", vmid);
+ db.create("/qemu-server", libc::S_IFDIR, 0, now).ok(); // May already exist
+ let vm_config = format!(
+ "name: test-vm-{}\ncores: 4\nmemory: 4096\nbootdisk: scsi0\n",
+ vmid
+ );
+ db.create(&config_path, libc::S_IFREG, 0, now)?;
+ db.write(&config_path, 0, 0, now, vm_config.as_bytes(), false)?;
+
+ // 4. Register VM in cluster
+ status.register_vm(vmid, VmType::Qemu, "localhost".to_string());
+
+ // 5. Release lock
+ db.release_lock(&lock_path, &csum)?;
+
+ // 6. Verify VM is accessible
+ assert!(db.exists(&config_path)?);
+ assert!(status.vm_exists(vmid));
+
+ Ok(())
+}
diff --git a/src/pmxcfs-rs/pmxcfs/tests/symlink_quorum_test.rs b/src/pmxcfs-rs/pmxcfs/tests/symlink_quorum_test.rs
new file mode 100644
index 000000000..49ea886df
--- /dev/null
+++ b/src/pmxcfs-rs/pmxcfs/tests/symlink_quorum_test.rs
@@ -0,0 +1,145 @@
+/// Test for quorum-aware symlink permissions
+///
+/// This test verifies that symlink plugins correctly adjust their permissions
+/// based on quorum status, matching the C implementation behavior in cfs-plug-link.c:68-72
+use pmxcfs_memdb::MemDb;
+use pmxcfs_rs::{fuse, plugins};
+use std::fs;
+use std::time::Duration;
+use tempfile::TempDir;
+
+#[tokio::test]
+#[ignore = "Requires FUSE mount permissions (run with sudo or configure /etc/fuse.conf)"]
+async fn test_symlink_permissions_with_quorum() -> Result<(), Box<dyn std::error::Error>> {
+ let test_dir = TempDir::new()?;
+ let db_path = test_dir.path().join("test.db");
+ let mount_path = test_dir.path().join("mnt");
+
+ fs::create_dir_all(&mount_path)?;
+
+ // Create MemDb and status (no RRD persistence needed for test)
+ let memdb = MemDb::open(&db_path, true)?;
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+
+ // Test with quorum enabled (should have 0o777 permissions)
+ status.set_quorate(true);
+ let plugins = plugins::init_plugins(config.clone(), status.clone());
+
+ // Spawn FUSE mount
+ let mount_path_clone = mount_path.clone();
+ let memdb_clone = memdb.clone();
+ let config_clone = config.clone();
+ let plugins_clone = plugins.clone();
+ let status_clone = status.clone();
+
+ let fuse_task = tokio::spawn(async move {
+ if let Err(e) = fuse::mount_fuse(
+ &mount_path_clone,
+ memdb_clone,
+ config_clone,
+ None,
+ plugins_clone,
+ status_clone,
+ )
+ .await
+ {
+ eprintln!("FUSE mount error: {}", e);
+ }
+ });
+
+ // Give FUSE time to mount
+ tokio::time::sleep(Duration::from_millis(2000)).await;
+
+ // Check if the symlink exists
+ let local_link = mount_path.join("local");
+ if local_link.exists() {
+ let metadata = fs::symlink_metadata(&local_link)?;
+ let permissions = metadata.permissions();
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ let mode = permissions.mode();
+ let link_perms = mode & 0o777;
+ println!(" Link 'local' permissions: {:04o}", link_perms);
+ // Note: On most systems, symlink permissions are always 0777
+ // This test mainly ensures the code path works correctly
+ }
+ } else {
+ println!(" [WARN] Symlink 'local' not visible (may be a FUSE mounting issue)");
+ }
+
+ // Cleanup
+ fuse_task.abort();
+ tokio::time::sleep(Duration::from_millis(100)).await;
+
+ // Remount with quorum disabled
+ let mount_path2 = test_dir.path().join("mnt2");
+ fs::create_dir_all(&mount_path2)?;
+
+ status.set_quorate(false);
+ let plugins2 = plugins::init_plugins(config.clone(), status.clone());
+
+ let mount_path_clone2 = mount_path2.clone();
+ let memdb_clone2 = memdb.clone();
+ let fuse_task2 = tokio::spawn(async move {
+ let _ = fuse::mount_fuse(
+ &mount_path_clone2,
+ memdb_clone2,
+ config,
+ None,
+ plugins2,
+ status,
+ )
+ .await;
+ });
+
+ tokio::time::sleep(Duration::from_millis(2000)).await;
+
+ let local_link2 = mount_path2.join("local");
+ if local_link2.exists() {
+ let metadata = fs::symlink_metadata(&local_link2)?;
+ let permissions = metadata.permissions();
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ let mode = permissions.mode();
+ let link_perms = mode & 0o777;
+ println!(" Link 'local' permissions: {:04o}", link_perms);
+ }
+ } else {
+ println!(" [WARN] Symlink 'local' not visible (may be a FUSE mounting issue)");
+ }
+
+ // Cleanup
+ fuse_task2.abort();
+
+ println!(" Note: Actual permission enforcement depends on FUSE and kernel");
+
+ Ok(())
+}
+
+#[test]
+fn test_link_plugin_has_quorum_aware_mode() {
+ // This is a unit test to verify the LinkPlugin mode is computed correctly
+ let _test_dir = TempDir::new().unwrap();
+
+ // Create status with quorum (no async needed, no RRD persistence)
+ let config = pmxcfs_test_utils::create_test_config(false);
+ let status = pmxcfs_status::init_with_config(config.clone());
+ status.set_quorate(true);
+ let registry_quorate = plugins::init_plugins(config.clone(), status.clone());
+
+ // Check that symlinks are identified correctly
+ let local_plugin = registry_quorate
+ .get("local")
+ .expect("local symlink should exist");
+ assert!(local_plugin.is_symlink(), "local should be a symlink");
+
+ // The mode itself is still 0o777, but the filesystem layer will use quorum status
+ assert_eq!(
+ local_plugin.mode(),
+ 0o777,
+ "Link plugin base mode should be 0o777"
+ );
+}
--
2.47.3
^ permalink raw reply related [relevance 1%]
* Re: [pve-devel] [RFC PATCH manager] WIP: api: implement node-independent bulk actions
2025-03-18 11:30 1% ` Stefan Hanreich
@ 2025-03-19 9:04 1% ` Dominik Csapak
0 siblings, 0 replies; 23+ results
From: Dominik Csapak @ 2025-03-19 9:04 UTC (permalink / raw)
To: Stefan Hanreich, Proxmox VE development discussion
On 3/18/25 12:30, Stefan Hanreich wrote:
> This would be really interesting for applying the SDN configuration as
> well, where I'm currently calling the existing bulk-call. Really like
> the design with the start / check callbacks, that should make this quite
> flexible.
>
> On 3/18/25 11:39, Dominik Csapak wrote:
>> To achieve this, we start a worker task and use our generic api client
>> to start the tasks on the relevant nodes. The client always points
>> to 'localhost' so we let the pveproxy worry about the proxying etc.
>>
>> We reuse some logic from the startall/stopall/etc. calls, like getting
>> the ordered guest info list.
>>
>> Not yet implemented are:
>> * filters
>> * failure mode resolution (we could implement this later too)
>> * token handling (not sure if we need this at all if we check the
>> permissions correctly upfront?)
>> * suspend
>> * some call specific parameters
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>> this is a pre-requisite for having bulk actions on PDM.
>> Since we normally don't do such things 'cluster-wide' I wanted to
>> send the patch early to get feedback on my design decisons like:
>> * using the api client this way
>> * api naming/location
>> * handling parallel requests
>> * etc.
>>
>> There are alternative methods to achieve similar results:
>> * use some kind of queuing system on the cluster (e.g. via pmxcfs)
>> * using the 'startall'/'stopall' calls from pve in PDM
>> * surely some other thing I didn't think about
>>
>> We can of course start with this, and change the underlying mechanism
>> later too.
>>
>> If we go this route, I could also rewrite the code in rust if wanted,
>> since there is nothing particularly dependent on perl here
>> (besides getting the vmlist, but that could stay in perl).
>> The bulk of the logic is how to start tasks + handle them finishing +
>> handling filter + concurrency.
>
> I'm actually reading the VM list in the firewall via this:
> https://git.proxmox.com/?p=proxmox-ve-rs.git;a=blob;f=proxmox-ve-config/src/guest/mod.rs;h=74fd8abc000aec0fa61898840d44ab8a4cd9018b;hb=HEAD#l69
>
> So we could build upon that if we want to implement it in Rust?
>
> I have something similar, *very* basic, implemented for running multiple
> tasks across clusters in my SDN patch series - so maybe we could
> repurpose that for a possible implementation, even generalize it?
Yeah sounds good if we want to do it this way, for my use case here we need to parse the config of
all guests though, not sure if we can do that in rust. maybe with just a minimal config like 'boot'
and such? Or we try to pull out the pve api types from pdm since there are parts of the config
already exposed i think...
>
>> PVE/API2/Cluster.pm | 7 +
>> PVE/API2/Cluster/Bulk.pm | 475 ++++++++++++++++++++++++++++++++++++++
>> PVE/API2/Cluster/Makefile | 1 +
>> PVE/API2/Nodes.pm | 24 +-
>> 4 files changed, 496 insertions(+), 11 deletions(-)
>> create mode 100644 PVE/API2/Cluster/Bulk.pm
>>
>> diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
>> index a0e5c11b..478610e6 100644
>> --- a/PVE/API2/Cluster.pm
>> +++ b/PVE/API2/Cluster.pm
>> @@ -25,6 +25,7 @@ use PVE::API2::ACMEAccount;
>> use PVE::API2::ACMEPlugin;
>> use PVE::API2::Backup;
>> use PVE::API2::Cluster::BackupInfo;
>> +use PVE::API2::Cluster::Bulk;
>> use PVE::API2::Cluster::Ceph;
>> use PVE::API2::Cluster::Mapping;
>> use PVE::API2::Cluster::Jobs;
>> @@ -103,6 +104,11 @@ __PACKAGE__->register_method ({
>> path => 'mapping',
>> });
>>
>> +__PACKAGE__->register_method ({
>> + subclass => "PVE::API2::Cluster::Bulk",
>> + path => 'bulk-actions',
>> +});
>> +
>> if ($have_sdn) {
>> __PACKAGE__->register_method ({
>> subclass => "PVE::API2::Network::SDN",
>> @@ -162,6 +168,7 @@ __PACKAGE__->register_method ({
>> { name => 'resources' },
>> { name => 'status' },
>> { name => 'tasks' },
>> + { name => 'bulk-actions' },
>> ];
>>
>> if ($have_sdn) {
>> diff --git a/PVE/API2/Cluster/Bulk.pm b/PVE/API2/Cluster/Bulk.pm
>> new file mode 100644
>> index 00000000..05a79155
>> --- /dev/null
>> +++ b/PVE/API2/Cluster/Bulk.pm
>> @@ -0,0 +1,475 @@
>> +package PVE::API2::Cluster::Bulk;
>
> We might wanna think about using sub-paths already, since I can see this
> growing quite fast (at least a sub-path for SDN would be interesting). I
> don't know how many other potential use-cases there are aside from that.
>
sure I would suggest it like this:
/cluster/bulk-actions/guest/{start,shutdown,...} -> PVE::API2::Cluster::Bulk(Actions?)::Guest;
/cluster/bulk-actions/sdn/{...} -> PVE::API2::Cluster::Bulk::SDN;
maybe in the future we can have:
/cluster/bulk-actions/node/{...} -> PVE::API2::Cluster::Bulk::Node;
>> +
>> +use strict;
>> +use warnings;
>> +
>> +use PVE::APIClient::LWP;
>> +use PVE::AccessControl;
>> +use PVE::Cluster;
>> +use PVE::Exception qw(raise raise_perm_exc raise_param_exc);
>> +use PVE::JSONSchema qw(get_standard_option);
>> +use PVE::RESTHandler;
>> +use PVE::RPCEnvironment;
>> +use PVE::Tools qw();
>> +
>> +use PVE::API2::Nodes;
>> +
>> +use base qw(PVE::RESTHandler);
>> +
>> +
>> +__PACKAGE__->register_method ({
>> + name => 'index',
>> + path => '',
>> + method => 'GET',
>> + description => "Bulk action index.",
>> + permissions => { user => 'all' },
>> + parameters => {
>> + additionalProperties => 0,
>> + properties => {},
>> + },
>> + returns => {
>> + type => 'array',
>> + items => {
>> + type => "object",
>> + properties => {},
>> + },
>> + links => [ { rel => 'child', href => "{name}" } ],
>> + },
>> + code => sub {
>> + my ($param) = @_;
>> +
>> + return [
>> + { name => 'start' },
>> + { name => 'shutdown' },
>> + { name => 'migrate' },
>> + ];
>> + }});
>> +
>> +sub create_client {
>> + my ($authuser, $request_timeout) = @_;
>> + my ($user, undef) = PVE::AccessControl::split_tokenid($authuser, 1);
>> +
>> + # TODO: How to handle Tokens?
>> + my $ticket = PVE::AccessControl::assemble_ticket($user || $authuser);
>> + my $csrf_token = PVE::AccessControl::assemble_csrf_prevention_token($user || $authuser);
>> +
>> + my $node = PVE::INotify::nodename();
>> + my $fingerprint = PVE::Cluster::get_node_fingerprint($node);
>> +
>> + my $conn_args = {
>> + protocol => 'https',
>> + host => 'localhost', # always call the api locally, let pveproxy handle the proxying
>> + port => 8006,
>> + ticket => $ticket,
>> + timeout => $request_timeout // 25, # default slightly shorter than the proxy->daemon timeout
>> + cached_fingerprints => {
>> + $fingerprint => 1,
>> + }
>> + };
>> +
>> + my $api_client = PVE::APIClient::LWP->new($conn_args->%*);
>> + if (defined($csrf_token)) {
>> + $api_client->update_csrftoken($csrf_token);
>> + }
>> +
>> + return $api_client;
>> +}
>> +
>> +# takes a vm list in the form of
>> +# {
>> +# 0 => {
>> +# 100 => { .. guest info ..},
>> +# 101 => { .. guest info ..},
>> +# },
>> +# 1 => {
>> +# 102 => { .. guest info ..},
>> +# 103 => { .. guest info ..},
>> +# },
>> +# }
>> +#
>> +# max_workers: how many parallel tasks should be started.
>> +# start_task: a sub that returns eiter a upid or 1 (undef means failure)
>> +# check_task: if start_task returned a upid, will wait for that to finish and
>> +# call check_task with the resulting task status
>> +sub foreach_guest {
>> + my ($startlist, $max_workers, $start_task, $check_task) = @_;
>> +
>> + my $rpcenv = PVE::RPCEnvironment::get();
>> + my $authuser = $rpcenv->get_user();
>> + my $api_client = create_client($authuser);
>> +
>> + my $failed = [];
>> + for my $order (sort {$a <=> $b} keys $startlist->%*) {
>> + my $vmlist = $startlist->{$order};
>> + my $workers = {};
>> +
>> + for my $vmid (sort {$a <=> $b} keys $vmlist->%*) {
>> +
>> + # wait until at least one slot is free
>> + while (scalar(keys($workers->%*)) >= $max_workers) {
>> + for my $upid (keys($workers->%*)) {
>> + my $worker = $workers->{$upid};
>> + my $node = $worker->{guest}->{node};
>> +
>> + my $task = $api_client->get("/nodes/$node/tasks/$upid/status");
>
> what happens if this call fails for any reason (iow status code != 2xx)?
> this is fallible afaict from a quick glance at the API client. should we
> handle errors here and retry / abort? We should certainly not just die
> here I'd say.
true, i'd probably do an eval {} here and have a failure mode (i'd begin with
'continue, but report an error at the end') that we could extend to
e.g. retry x-times, abort the job, ...
>
>> + if ($task->{status} ne 'running') {
>> + my $is_error = PVE::Tools::upid_status_is_error($task->{exitstatus});
>> + push $failed->@*, $worker->{vmid} if $is_error;
>> +
>> + $check_task->($api_client, $worker->{vmid}, $worker->{guest}, $is_error, $task);
>> +
>> + delete $workers->{$upid};
>> + }
>> + }
>> + sleep(1); # How much?
>> + }
>> +
>> + my $guest = $vmlist->{$vmid};
>> + my $upid = eval { $start_task->($api_client, $vmid, $guest) };
>> + warn $@ if $@;
>> +
>> + # success but no task necessary
>> + next if "$upid" eq "1";
>> +
>> + if (!defined($upid)) {
>> + push $failed->@*, $vmid;
>> + continue;
>> + }
>> +
>> + $workers->{$upid} = {
>> + vmid => $vmid,
>> + guest => $guest,
>> + };
>> + }
>> +
>> + # wait until current order is finished
>> + for my $upid (keys($workers->%*)) {
>> + my $worker = $workers->{$upid};
>> + my $node = $worker->{guest}->{node};
>> +
>> + my $task = wait_for_task_finished($api_client, $node, $upid);
>> + my $is_error = PVE::Tools::upid_status_is_error($task->{exitstatus});
>> + push $failed->@*, $worker->{vmid} if $is_error;
>> +
>> + $check_task->($api_client, $worker->{vmid}, $worker->{guest}, $is_error, $task);
>> +
>> + delete $workers->{$upid};
>
> Maybe extract that into a function, since it seems to be the same code
> as above?
>
> Or maybe even a do while would simplify things here? Haven't thought it
> through 100%, just an idea:
>
> do {
> // check for terminated workers and reap them
> // fill empty worker slots with new workers
> }
> while (workers_exist)
>
> Would maybe simplify things and not require the waiting part at the end?
it's not so easy sadly since the two blocks are not the same
we have two different mechanisms here
we have worker slots (max_workers) that we want to fill.
while we are going through an order (e.g. for start/shutdown) we don't
want to start with the next order while there are still workers running so
while we can still ad workers, we loop over the existing ones until one is
finished and queue the next. at the end of the 'order' we have wait for all
remaining workers before continuing to the next order.
>
>> + }
>> + }
>> +
>> + return $failed;
>> +}
>> +
>> +sub get_type_text {
>> + my ($type) = @_;
>> +
>> + if ($type eq 'lxc') {
>> + return 'CT';
>> + } elsif ($type eq 'qemu') {
>> + return 'VM';
>> + } else {
>> + die "unknown guest type $type\n";
>> + }
>> +}
>> +
>> +sub wait_for_task_finished {
>> + my ($client, $node, $upid) = @_;
>> +
>> + while (1) {
>> + my $task = $client->get("/nodes/$node/tasks/$upid/status");
>
> also some error handling / retry logic? maybe just at the call site though..
yes, i'd handle error from this at the call site
>
>> + return $task if $task->{status} ne 'running';
>> + sleep(1); # How much time?
>> + }
>> +}
>> +
>> +sub check_guest_permissions {
>> + my ($rpcenv, $authuser, $vmlist, $priv_list) = @_;
>> +
>> + my @vms = PVE::Tools::split_list($vmlist);
>> + if (scalar(@vms) > 0) {
>> + $rpcenv->check($authuser, "/vms/$_", $priv_list) for @vms;
>> + } elsif (!$rpcenv->check($authuser, "/", $priv_list, 1)) {
>> + raise_perm_exc("/, VM.PowerMgmt");
>> + }
>> +}
>> +
>> +__PACKAGE__->register_method({
>> + name => 'start',
>> + path => 'start',
>> + method => 'POST',
>> + description => "Bulk start all guests on the cluster.",
>> + permissions => { user => 'all' },
>
> Since the permissions check happens inside the API call, it would be
> nice to add a description here that states what checks are performed.
>
true, i did not add all descriptions yet.>> + protected => 1,
>> + parameters => {
>> + additionalProperties => 0,
>> + properties => {
>> + vms => {
>> + description => "Only consider guests from this comma separated list of VMIDs.",
>> + type => 'string', format => 'pve-vmid-list',
>> + optional => 1,
>> + },
>> + 'max-workers' => {
>> + description => "How many parallel tasks at maximum should be started.",
>> + optional => 1,
>> + default => 1,
>> + type => 'integer',
>> + },
>> + # TODO:
>> + # Failure resolution mode (fail, warn, retry?)
>
> Do you intend to pass this to foreach_guests or should this be handled
> by check_task? Depending on this, you can ignore the comments above
> w.r.t. fallibility. If check_task should handle it, we should be really
> careful with how we handle the API call failures inside and return them
> to check_task, so we can make informed decisions there.
yes, my intention was to let foreach_guest handle that. (probably a different name
would be good when it does so many things)
>
>> + # mode-limits (offline only, suspend only, ?)
>> + # filter (tags, name, ?)
>> + },
>> + },
>> + returns => {
>> + type => 'string',
>> + description => "UPID of the worker",
>> + },
>> + code => sub {
>> + my ($param) = @_;
>> +
>> + my $rpcenv = PVE::RPCEnvironment::get();
>> + my $authuser = $rpcenv->get_user();
>> +
>> + check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.PowerMgmt' ]);
>> +
>> + my $code = sub {
>> + my $startlist = PVE::API2::Nodes::Nodeinfo::get_start_stop_list(undef, undef, $param->{vms});
>> +
>> + my $start_task = sub {
>> + my ($api_client, $vmid, $guest) = @_;
>> + my $node = $guest->{node};
>> +
>> + my $type = $guest->{type};
>> + my $type_text = get_type_text($type);
>> +
>> + my $url = "/nodes/$node/$type/$vmid/status/start";
>> + print STDERR "Starting $type_text $vmid\n";
>> + return $api_client->post($url);
>> + };
>> +
>> + my $check_task = sub {
>> + my ($api_client, $vmid, $guest, $is_error, $task) = @_;
>> + my $node = $guest->{node};
>> +
>> + my $default_delay = 0;
>> +
>> + if (!$is_error) {
>> + my $delay = defined($guest->{up}) ? int($guest->{up}) : $default_delay;
>> + if ($delay > 0) {
>> + print STDERR "Waiting for $delay seconds (startup delay)\n" if $guest->{up};
>> + for (my $i = 0; $i < $delay; $i++) {
>> + sleep(1);
>> + }
>> + }
>> + } else {
>> + my $type_text = get_type_text($guest->{type});
>> + print STDERR "Starting $type_text $vmid failed: $task->{exitstatus}\n";
>> + }
>> + };
>> +
>> + my $max_workers = $param->{'max-workers'} // 1;
>> + my $failed = foreach_guest($startlist, $max_workers, $start_task, $check_task);
>> +
>> + if (scalar($failed->@*)) {
>> + die "Some guests failed to start: " . join(', ', $failed->@*) . "\n";
>> + }
>> + };
>> +
>> + return $rpcenv->fork_worker('bulkstart', undef, $authuser, $code);
>> + }});
>> +
>> +__PACKAGE__->register_method({
>> + name => 'shutdown',
>> + path => 'shutdown',
>> + method => 'POST',
>> + description => "Bulk shutdown all guests on the cluster.",
>> + permissions => { user => 'all' },
>
> description here as well
>
>> + protected => 1,
>> + parameters => {
>> + additionalProperties => 0,
>> + properties => {
>> + vms => {
>> + description => "Only consider guests from this comma separated list of VMIDs.",
>> + type => 'string', format => 'pve-vmid-list',
>> + optional => 1,
>> + },
>> + timeout => {
>> + description => "Default shutdown timeout in seconds if none is configured for the guest.",
>> + type => 'integer',
>> + default => 180,
>> + optional => 1,
>> + },
>> + 'max-workers' => {
>> + description => "How many parallel tasks at maximum should be started.",
>> + optional => 1,
>> + default => 1,
>> + type => 'integer',
>> + },
>> + # TODO:
>> + # Failure resolution mode (fail, warn, retry?)
>> + # mode-limits (offline only, suspend only, ?)
>> + # filter (tags, name, ?)
>> + },
>> + },
>> + returns => {
>> + type => 'string',
>> + description => "UPID of the worker",
>> + },
>> + code => sub {
>> + my ($param) = @_;
>> +
>> + my $rpcenv = PVE::RPCEnvironment::get();
>> + my $authuser = $rpcenv->get_user();
>> +
>> + check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.PowerMgmt' ]);
>> +
>> + my $code = sub {
>> + my $startlist = PVE::API2::Nodes::Nodeinfo::get_start_stop_list(undef, undef, $param->{vms});
>> +
>> + # reverse order for shutdown
>> + for my $order (keys $startlist->%*) {
>> + my $list = delete $startlist->{$order};
>> + $order = $order * -1;
>> + $startlist->{$order} = $list;
>> + }
>> +
>> + my $start_task = sub {
>> + my ($api_client, $vmid, $guest) = @_;
>> + my $node = $guest->{node};
>> +
>> + my $type = $guest->{type};
>> + my $type_text = get_type_text($type);
>> +
>> + my $timeout = int($guest->{down} // $param->{timeout} // 180);
>> +
>> + my $params = {
>> + forceStop => 1,
>> + timeout => $timeout,
>> + };
>> +
>> + my $url = "/nodes/$node/$type/$vmid/status/shutdown";
>> + print STDERR "Shutting down $type_text $vmid (Timeout = $timeout seconds)\n";
>> + return $api_client->post($url, $params);
>> + };
>> +
>> + my $check_task = sub {
>> + my ($api_client, $vmid, $guest, $is_error, $task) = @_;
>> + my $node = $guest->{node};
>> + if ($is_error) {
>> + my $type_text = get_type_text($guest->{type});
>> + print STDERR "Stopping $type_text $vmid failed: $task->{exitstatus}\n";
>> + }
>> + };
>> +
>> + my $max_workers = $param->{'max-workers'} // 1;
>> + my $failed = foreach_guest($startlist, $max_workers, $start_task, $check_task);
>> +
>> + if (scalar($failed->@*)) {
>> + die "Some guests failed to shutdown " . join(', ', $failed->@*) . "\n";
>> + }
>> + };
>> +
>> + return $rpcenv->fork_worker('bulkshutdown', undef, $authuser, $code);
>> + }});
>> +
>> +__PACKAGE__->register_method({
>> + name => 'migrate',
>> + path => 'migrate',
>> + method => 'POST',
>> + description => "Bulk migrate all guests on the cluster.",
>> + permissions => { user => 'all' },
>
> description here as well
>
>> + protected => 1,
>> + parameters => {
>> + additionalProperties => 0,
>> + properties => {
>> + vms => {
>> + description => "Only consider guests from this comma separated list of VMIDs.",
>> + type => 'string', format => 'pve-vmid-list',
>> + optional => 1,
>> + },
>> + 'target-node' => get_standard_option('pve-node', { description => "Target node." }),
>> + online => {
>> + type => 'boolean',
>> + description => "Enable live migration for VMs and restart migration for CTs.",
>> + optional => 1,
>> + },
>> + "with-local-disks" => {
>> + type => 'boolean',
>> + description => "Enable live storage migration for local disk",
>> + optional => 1,
>> + },
>> + 'max-workers' => {
>> + description => "How many parallel tasks at maximum should be started.",
>> + optional => 1,
>> + default => 1,
>> + type => 'integer',
>> + },
>> + # TODO:
>> + # Failure resolution mode (fail, warn, retry?)
>> + # mode-limits (offline only, suspend only, ?)
>> + # filter (tags, name, ?)
>> + },
>> + },
>> + returns => {
>> + type => 'string',
>> + description => "UPID of the worker",
>> + },
>> + code => sub {
>> + my ($param) = @_;
>> +
>> + my $rpcenv = PVE::RPCEnvironment::get();
>> + my $authuser = $rpcenv->get_user();
>> +
>> + check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.Migrate' ]);
>> +
>> + my $code = sub {
>> + my $list = PVE::API2::Nodes::Nodeinfo::get_filtered_vmlist(undef, $param->{vms}, 1, 1);
>> +
>> + my $start_task = sub {
>> + my ($api_client, $vmid, $guest) = @_;
>> + my $node = $guest->{node};
>> +
>> + my $type = $guest->{type};
>> + my $type_text = get_type_text($type);
>> +
>> + if ($node eq $param->{'target-node'}) {
>> + print STDERR "$type_text $vmid already on $node, skipping.\n";
>> + return 1;
>> + }
>> +
>> + my $params = {
>> + target => $param->{'target-node'},
>> + };
>> +
>> + if ($type eq 'lxc') {
>> + $params->{restart} = $param->{online} if defined($param->{online});
>> + } elsif ($type eq 'qemu') {
>> + $params->{online} = $param->{online} if defined($param->{online});
>> + $params->{'with-local-disks'} = $param->{'with-local-disks'} if defined($param->{'with-local-disks'});
>> + }
>> +
>> + my $url = "/nodes/$node/$type/$vmid/migrate";
>> + print STDERR "Migrating $type_text $vmid\n";
>> + return $api_client->post($url, $params);
>> + };
>> +
>> + my $check_task = sub {
>> + my ($api_client, $vmid, $guest, $is_error, $task) = @_;
>> + if ($is_error) {
>> + my $type_text = get_type_text($guest->{type});
>> + print STDERR "Migrating $type_text $vmid failed: $task->{exitstatus}\n";
>> + }
>> + };
>> +
>> + my $max_workers = $param->{'max-workers'} // 1;
>> + my $failed = foreach_guest({ '0' => $list }, $max_workers, $start_task, $check_task);
>> +
>> + if (scalar($failed->@*)) {
>> + die "Some guests failed to migrate " . join(', ', $failed->@*) . "\n";
>> + }
>> + };
>> +
>> + return $rpcenv->fork_worker('bulkmigrate', undef, $authuser, $code);
>> + }});
>> +
>> +1;
>> diff --git a/PVE/API2/Cluster/Makefile b/PVE/API2/Cluster/Makefile
>> index b109e5cb..ed02b4be 100644
>> --- a/PVE/API2/Cluster/Makefile
>> +++ b/PVE/API2/Cluster/Makefile
>> @@ -6,6 +6,7 @@ SUBDIRS=Mapping
>> # ensure we do not conflict with files shipped by pve-cluster!!
>> PERLSOURCE= \
>> BackupInfo.pm \
>> + Bulk.pm \
>> MetricServer.pm \
>> Mapping.pm \
>> Notifications.pm \
>> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
>> index 9cdf19db..02bc7299 100644
>> --- a/PVE/API2/Nodes.pm
>> +++ b/PVE/API2/Nodes.pm
>> @@ -1829,7 +1829,7 @@ __PACKAGE__->register_method({
>> # * vmid whitelist
>> # * guest is a template (default: skip)
>> # * guest is HA manged (default: skip)
>> -my $get_filtered_vmlist = sub {
>> +sub get_filtered_vmlist {
>> my ($nodename, $vmfilter, $templates, $ha_managed) = @_;
>>
>> my $vmlist = PVE::Cluster::get_vmlist();
>> @@ -1856,13 +1856,14 @@ my $get_filtered_vmlist = sub {
>> die "unknown virtual guest type '$d->{type}'\n";
>> }
>>
>> - my $conf = $class->load_config($vmid);
>> + my $conf = $class->load_config($vmid, $d->{node});
>> return if !$templates && $class->is_template($conf);
>> return if !$ha_managed && PVE::HA::Config::vm_is_ha_managed($vmid);
>>
>> $res->{$vmid}->{conf} = $conf;
>> $res->{$vmid}->{type} = $d->{type};
>> $res->{$vmid}->{class} = $class;
>> + $res->{$vmid}->{node} = $d->{node};
>> };
>> warn $@ if $@;
>> }
>> @@ -1871,13 +1872,13 @@ my $get_filtered_vmlist = sub {
>> };
>>
>> # return all VMs which should get started/stopped on power up/down
>> -my $get_start_stop_list = sub {
>> +sub get_start_stop_list {
>> my ($nodename, $autostart, $vmfilter) = @_;
>>
>> # do not skip HA vms on force or if a specific VMID set is wanted
>> my $include_ha_managed = defined($vmfilter) ? 1 : 0;
>>
>> - my $vmlist = $get_filtered_vmlist->($nodename, $vmfilter, undef, $include_ha_managed);
>> + my $vmlist = get_filtered_vmlist($nodename, $vmfilter, undef, $include_ha_managed);
>>
>> my $resList = {};
>> foreach my $vmid (keys %$vmlist) {
>> @@ -1889,15 +1890,16 @@ my $get_start_stop_list = sub {
>>
>> $resList->{$order}->{$vmid} = $startup;
>> $resList->{$order}->{$vmid}->{type} = $vmlist->{$vmid}->{type};
>> + $resList->{$order}->{$vmid}->{node} = $vmlist->{$vmid}->{node};
>> }
>>
>> return $resList;
>> -};
>> +}
>>
>> my $remove_locks_on_startup = sub {
>> my ($nodename) = @_;
>>
>> - my $vmlist = &$get_filtered_vmlist($nodename, undef, undef, 1);
>> + my $vmlist = get_filtered_vmlist($nodename, undef, undef, 1);
>>
>> foreach my $vmid (keys %$vmlist) {
>> my $conf = $vmlist->{$vmid}->{conf};
>> @@ -1983,7 +1985,7 @@ __PACKAGE__->register_method ({
>> warn $@ if $@;
>>
>> my $autostart = $force ? undef : 1;
>> - my $startList = $get_start_stop_list->($nodename, $autostart, $param->{vms});
>> + my $startList = get_start_stop_list($nodename, $autostart, $param->{vms});
>>
>> # Note: use numeric sorting with <=>
>> for my $order (sort {$a <=> $b} keys %$startList) {
>> @@ -2096,7 +2098,7 @@ __PACKAGE__->register_method ({
>> minimum => 0,
>> maximum => 2 * 3600, # mostly arbitrary, but we do not want to high timeouts
>> },
>> - },
>> + }
>> },
>> returns => {
>> type => 'string',
>> @@ -2123,7 +2125,7 @@ __PACKAGE__->register_method ({
>>
>> $rpcenv->{type} = 'priv'; # to start tasks in background
>>
>> - my $stopList = $get_start_stop_list->($nodename, undef, $param->{vms});
>> + my $stopList = get_start_stop_list($nodename, undef, $param->{vms});
>>
>> my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
>> my $datacenterconfig = cfs_read_file('datacenter.cfg');
>> @@ -2246,7 +2248,7 @@ __PACKAGE__->register_method ({
>>
>> $rpcenv->{type} = 'priv'; # to start tasks in background
>>
>> - my $toSuspendList = $get_start_stop_list->($nodename, undef, $param->{vms});
>> + my $toSuspendList = get_start_stop_list($nodename, undef, $param->{vms});
>>
>> my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
>> my $datacenterconfig = cfs_read_file('datacenter.cfg');
>> @@ -2434,7 +2436,7 @@ __PACKAGE__->register_method ({
>> my $code = sub {
>> $rpcenv->{type} = 'priv'; # to start tasks in background
>>
>> - my $vmlist = &$get_filtered_vmlist($nodename, $param->{vms}, 1, 1);
>> + my $vmlist = get_filtered_vmlist($nodename, $param->{vms}, 1, 1);
>> if (!scalar(keys %$vmlist)) {
>> warn "no virtual guests matched, nothing to do..\n";
>> return;
>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [relevance 1%]
* Re: [pve-devel] [RFC PATCH manager] WIP: api: implement node-independent bulk actions
2025-03-18 10:39 8% [pve-devel] [RFC PATCH manager] WIP: api: implement node-independent bulk actions Dominik Csapak
@ 2025-03-18 11:30 1% ` Stefan Hanreich
2025-03-19 9:04 1% ` Dominik Csapak
0 siblings, 1 reply; 23+ results
From: Stefan Hanreich @ 2025-03-18 11:30 UTC (permalink / raw)
To: Proxmox VE development discussion, Dominik Csapak
This would be really interesting for applying the SDN configuration as
well, where I'm currently calling the existing bulk-call. Really like
the design with the start / check callbacks, that should make this quite
flexible.
On 3/18/25 11:39, Dominik Csapak wrote:
> To achieve this, we start a worker task and use our generic api client
> to start the tasks on the relevant nodes. The client always points
> to 'localhost' so we let the pveproxy worry about the proxying etc.
>
> We reuse some logic from the startall/stopall/etc. calls, like getting
> the ordered guest info list.
>
> Not yet implemented are:
> * filters
> * failure mode resolution (we could implement this later too)
> * token handling (not sure if we need this at all if we check the
> permissions correctly upfront?)
> * suspend
> * some call specific parameters
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> this is a pre-requisite for having bulk actions on PDM.
> Since we normally don't do such things 'cluster-wide' I wanted to
> send the patch early to get feedback on my design decisons like:
> * using the api client this way
> * api naming/location
> * handling parallel requests
> * etc.
>
> There are alternative methods to achieve similar results:
> * use some kind of queuing system on the cluster (e.g. via pmxcfs)
> * using the 'startall'/'stopall' calls from pve in PDM
> * surely some other thing I didn't think about
>
> We can of course start with this, and change the underlying mechanism
> later too.
>
> If we go this route, I could also rewrite the code in rust if wanted,
> since there is nothing particularly dependent on perl here
> (besides getting the vmlist, but that could stay in perl).
> The bulk of the logic is how to start tasks + handle them finishing +
> handling filter + concurrency.
I'm actually reading the VM list in the firewall via this:
https://git.proxmox.com/?p=proxmox-ve-rs.git;a=blob;f=proxmox-ve-config/src/guest/mod.rs;h=74fd8abc000aec0fa61898840d44ab8a4cd9018b;hb=HEAD#l69
So we could build upon that if we want to implement it in Rust?
I have something similar, *very* basic, implemented for running multiple
tasks across clusters in my SDN patch series - so maybe we could
repurpose that for a possible implementation, even generalize it?
> PVE/API2/Cluster.pm | 7 +
> PVE/API2/Cluster/Bulk.pm | 475 ++++++++++++++++++++++++++++++++++++++
> PVE/API2/Cluster/Makefile | 1 +
> PVE/API2/Nodes.pm | 24 +-
> 4 files changed, 496 insertions(+), 11 deletions(-)
> create mode 100644 PVE/API2/Cluster/Bulk.pm
>
> diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
> index a0e5c11b..478610e6 100644
> --- a/PVE/API2/Cluster.pm
> +++ b/PVE/API2/Cluster.pm
> @@ -25,6 +25,7 @@ use PVE::API2::ACMEAccount;
> use PVE::API2::ACMEPlugin;
> use PVE::API2::Backup;
> use PVE::API2::Cluster::BackupInfo;
> +use PVE::API2::Cluster::Bulk;
> use PVE::API2::Cluster::Ceph;
> use PVE::API2::Cluster::Mapping;
> use PVE::API2::Cluster::Jobs;
> @@ -103,6 +104,11 @@ __PACKAGE__->register_method ({
> path => 'mapping',
> });
>
> +__PACKAGE__->register_method ({
> + subclass => "PVE::API2::Cluster::Bulk",
> + path => 'bulk-actions',
> +});
> +
> if ($have_sdn) {
> __PACKAGE__->register_method ({
> subclass => "PVE::API2::Network::SDN",
> @@ -162,6 +168,7 @@ __PACKAGE__->register_method ({
> { name => 'resources' },
> { name => 'status' },
> { name => 'tasks' },
> + { name => 'bulk-actions' },
> ];
>
> if ($have_sdn) {
> diff --git a/PVE/API2/Cluster/Bulk.pm b/PVE/API2/Cluster/Bulk.pm
> new file mode 100644
> index 00000000..05a79155
> --- /dev/null
> +++ b/PVE/API2/Cluster/Bulk.pm
> @@ -0,0 +1,475 @@
> +package PVE::API2::Cluster::Bulk;
We might wanna think about using sub-paths already, since I can see this
growing quite fast (at least a sub-path for SDN would be interesting). I
don't know how many other potential use-cases there are aside from that.
> +
> +use strict;
> +use warnings;
> +
> +use PVE::APIClient::LWP;
> +use PVE::AccessControl;
> +use PVE::Cluster;
> +use PVE::Exception qw(raise raise_perm_exc raise_param_exc);
> +use PVE::JSONSchema qw(get_standard_option);
> +use PVE::RESTHandler;
> +use PVE::RPCEnvironment;
> +use PVE::Tools qw();
> +
> +use PVE::API2::Nodes;
> +
> +use base qw(PVE::RESTHandler);
> +
> +
> +__PACKAGE__->register_method ({
> + name => 'index',
> + path => '',
> + method => 'GET',
> + description => "Bulk action index.",
> + permissions => { user => 'all' },
> + parameters => {
> + additionalProperties => 0,
> + properties => {},
> + },
> + returns => {
> + type => 'array',
> + items => {
> + type => "object",
> + properties => {},
> + },
> + links => [ { rel => 'child', href => "{name}" } ],
> + },
> + code => sub {
> + my ($param) = @_;
> +
> + return [
> + { name => 'start' },
> + { name => 'shutdown' },
> + { name => 'migrate' },
> + ];
> + }});
> +
> +sub create_client {
> + my ($authuser, $request_timeout) = @_;
> + my ($user, undef) = PVE::AccessControl::split_tokenid($authuser, 1);
> +
> + # TODO: How to handle Tokens?
> + my $ticket = PVE::AccessControl::assemble_ticket($user || $authuser);
> + my $csrf_token = PVE::AccessControl::assemble_csrf_prevention_token($user || $authuser);
> +
> + my $node = PVE::INotify::nodename();
> + my $fingerprint = PVE::Cluster::get_node_fingerprint($node);
> +
> + my $conn_args = {
> + protocol => 'https',
> + host => 'localhost', # always call the api locally, let pveproxy handle the proxying
> + port => 8006,
> + ticket => $ticket,
> + timeout => $request_timeout // 25, # default slightly shorter than the proxy->daemon timeout
> + cached_fingerprints => {
> + $fingerprint => 1,
> + }
> + };
> +
> + my $api_client = PVE::APIClient::LWP->new($conn_args->%*);
> + if (defined($csrf_token)) {
> + $api_client->update_csrftoken($csrf_token);
> + }
> +
> + return $api_client;
> +}
> +
> +# takes a vm list in the form of
> +# {
> +# 0 => {
> +# 100 => { .. guest info ..},
> +# 101 => { .. guest info ..},
> +# },
> +# 1 => {
> +# 102 => { .. guest info ..},
> +# 103 => { .. guest info ..},
> +# },
> +# }
> +#
> +# max_workers: how many parallel tasks should be started.
> +# start_task: a sub that returns eiter a upid or 1 (undef means failure)
> +# check_task: if start_task returned a upid, will wait for that to finish and
> +# call check_task with the resulting task status
> +sub foreach_guest {
> + my ($startlist, $max_workers, $start_task, $check_task) = @_;
> +
> + my $rpcenv = PVE::RPCEnvironment::get();
> + my $authuser = $rpcenv->get_user();
> + my $api_client = create_client($authuser);
> +
> + my $failed = [];
> + for my $order (sort {$a <=> $b} keys $startlist->%*) {
> + my $vmlist = $startlist->{$order};
> + my $workers = {};
> +
> + for my $vmid (sort {$a <=> $b} keys $vmlist->%*) {
> +
> + # wait until at least one slot is free
> + while (scalar(keys($workers->%*)) >= $max_workers) {
> + for my $upid (keys($workers->%*)) {
> + my $worker = $workers->{$upid};
> + my $node = $worker->{guest}->{node};
> +
> + my $task = $api_client->get("/nodes/$node/tasks/$upid/status");
what happens if this call fails for any reason (iow status code != 2xx)?
this is fallible afaict from a quick glance at the API client. should we
handle errors here and retry / abort? We should certainly not just die
here I'd say.
> + if ($task->{status} ne 'running') {
> + my $is_error = PVE::Tools::upid_status_is_error($task->{exitstatus});
> + push $failed->@*, $worker->{vmid} if $is_error;
> +
> + $check_task->($api_client, $worker->{vmid}, $worker->{guest}, $is_error, $task);
> +
> + delete $workers->{$upid};
> + }
> + }
> + sleep(1); # How much?
> + }
> +
> + my $guest = $vmlist->{$vmid};
> + my $upid = eval { $start_task->($api_client, $vmid, $guest) };
> + warn $@ if $@;
> +
> + # success but no task necessary
> + next if "$upid" eq "1";
> +
> + if (!defined($upid)) {
> + push $failed->@*, $vmid;
> + continue;
> + }
> +
> + $workers->{$upid} = {
> + vmid => $vmid,
> + guest => $guest,
> + };
> + }
> +
> + # wait until current order is finished
> + for my $upid (keys($workers->%*)) {
> + my $worker = $workers->{$upid};
> + my $node = $worker->{guest}->{node};
> +
> + my $task = wait_for_task_finished($api_client, $node, $upid);
> + my $is_error = PVE::Tools::upid_status_is_error($task->{exitstatus});
> + push $failed->@*, $worker->{vmid} if $is_error;
> +
> + $check_task->($api_client, $worker->{vmid}, $worker->{guest}, $is_error, $task);
> +
> + delete $workers->{$upid};
Maybe extract that into a function, since it seems to be the same code
as above?
Or maybe even a do while would simplify things here? Haven't thought it
through 100%, just an idea:
do {
// check for terminated workers and reap them
// fill empty worker slots with new workers
}
while (workers_exist)
Would maybe simplify things and not require the waiting part at the end?
> + }
> + }
> +
> + return $failed;
> +}
> +
> +sub get_type_text {
> + my ($type) = @_;
> +
> + if ($type eq 'lxc') {
> + return 'CT';
> + } elsif ($type eq 'qemu') {
> + return 'VM';
> + } else {
> + die "unknown guest type $type\n";
> + }
> +}
> +
> +sub wait_for_task_finished {
> + my ($client, $node, $upid) = @_;
> +
> + while (1) {
> + my $task = $client->get("/nodes/$node/tasks/$upid/status");
also some error handling / retry logic? maybe just at the call site though..
> + return $task if $task->{status} ne 'running';
> + sleep(1); # How much time?
> + }
> +}
> +
> +sub check_guest_permissions {
> + my ($rpcenv, $authuser, $vmlist, $priv_list) = @_;
> +
> + my @vms = PVE::Tools::split_list($vmlist);
> + if (scalar(@vms) > 0) {
> + $rpcenv->check($authuser, "/vms/$_", $priv_list) for @vms;
> + } elsif (!$rpcenv->check($authuser, "/", $priv_list, 1)) {
> + raise_perm_exc("/, VM.PowerMgmt");
> + }
> +}
> +
> +__PACKAGE__->register_method({
> + name => 'start',
> + path => 'start',
> + method => 'POST',
> + description => "Bulk start all guests on the cluster.",
> + permissions => { user => 'all' },
Since the permissions check happens inside the API call, it would be
nice to add a description here that states what checks are performed.
> + protected => 1,
> + parameters => {
> + additionalProperties => 0,
> + properties => {
> + vms => {
> + description => "Only consider guests from this comma separated list of VMIDs.",
> + type => 'string', format => 'pve-vmid-list',
> + optional => 1,
> + },
> + 'max-workers' => {
> + description => "How many parallel tasks at maximum should be started.",
> + optional => 1,
> + default => 1,
> + type => 'integer',
> + },
> + # TODO:
> + # Failure resolution mode (fail, warn, retry?)
Do you intend to pass this to foreach_guests or should this be handled
by check_task? Depending on this, you can ignore the comments above
w.r.t. fallibility. If check_task should handle it, we should be really
careful with how we handle the API call failures inside and return them
to check_task, so we can make informed decisions there.
> + # mode-limits (offline only, suspend only, ?)
> + # filter (tags, name, ?)
> + },
> + },
> + returns => {
> + type => 'string',
> + description => "UPID of the worker",
> + },
> + code => sub {
> + my ($param) = @_;
> +
> + my $rpcenv = PVE::RPCEnvironment::get();
> + my $authuser = $rpcenv->get_user();
> +
> + check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.PowerMgmt' ]);
> +
> + my $code = sub {
> + my $startlist = PVE::API2::Nodes::Nodeinfo::get_start_stop_list(undef, undef, $param->{vms});
> +
> + my $start_task = sub {
> + my ($api_client, $vmid, $guest) = @_;
> + my $node = $guest->{node};
> +
> + my $type = $guest->{type};
> + my $type_text = get_type_text($type);
> +
> + my $url = "/nodes/$node/$type/$vmid/status/start";
> + print STDERR "Starting $type_text $vmid\n";
> + return $api_client->post($url);
> + };
> +
> + my $check_task = sub {
> + my ($api_client, $vmid, $guest, $is_error, $task) = @_;
> + my $node = $guest->{node};
> +
> + my $default_delay = 0;
> +
> + if (!$is_error) {
> + my $delay = defined($guest->{up}) ? int($guest->{up}) : $default_delay;
> + if ($delay > 0) {
> + print STDERR "Waiting for $delay seconds (startup delay)\n" if $guest->{up};
> + for (my $i = 0; $i < $delay; $i++) {
> + sleep(1);
> + }
> + }
> + } else {
> + my $type_text = get_type_text($guest->{type});
> + print STDERR "Starting $type_text $vmid failed: $task->{exitstatus}\n";
> + }
> + };
> +
> + my $max_workers = $param->{'max-workers'} // 1;
> + my $failed = foreach_guest($startlist, $max_workers, $start_task, $check_task);
> +
> + if (scalar($failed->@*)) {
> + die "Some guests failed to start: " . join(', ', $failed->@*) . "\n";
> + }
> + };
> +
> + return $rpcenv->fork_worker('bulkstart', undef, $authuser, $code);
> + }});
> +
> +__PACKAGE__->register_method({
> + name => 'shutdown',
> + path => 'shutdown',
> + method => 'POST',
> + description => "Bulk shutdown all guests on the cluster.",
> + permissions => { user => 'all' },
description here as well
> + protected => 1,
> + parameters => {
> + additionalProperties => 0,
> + properties => {
> + vms => {
> + description => "Only consider guests from this comma separated list of VMIDs.",
> + type => 'string', format => 'pve-vmid-list',
> + optional => 1,
> + },
> + timeout => {
> + description => "Default shutdown timeout in seconds if none is configured for the guest.",
> + type => 'integer',
> + default => 180,
> + optional => 1,
> + },
> + 'max-workers' => {
> + description => "How many parallel tasks at maximum should be started.",
> + optional => 1,
> + default => 1,
> + type => 'integer',
> + },
> + # TODO:
> + # Failure resolution mode (fail, warn, retry?)
> + # mode-limits (offline only, suspend only, ?)
> + # filter (tags, name, ?)
> + },
> + },
> + returns => {
> + type => 'string',
> + description => "UPID of the worker",
> + },
> + code => sub {
> + my ($param) = @_;
> +
> + my $rpcenv = PVE::RPCEnvironment::get();
> + my $authuser = $rpcenv->get_user();
> +
> + check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.PowerMgmt' ]);
> +
> + my $code = sub {
> + my $startlist = PVE::API2::Nodes::Nodeinfo::get_start_stop_list(undef, undef, $param->{vms});
> +
> + # reverse order for shutdown
> + for my $order (keys $startlist->%*) {
> + my $list = delete $startlist->{$order};
> + $order = $order * -1;
> + $startlist->{$order} = $list;
> + }
> +
> + my $start_task = sub {
> + my ($api_client, $vmid, $guest) = @_;
> + my $node = $guest->{node};
> +
> + my $type = $guest->{type};
> + my $type_text = get_type_text($type);
> +
> + my $timeout = int($guest->{down} // $param->{timeout} // 180);
> +
> + my $params = {
> + forceStop => 1,
> + timeout => $timeout,
> + };
> +
> + my $url = "/nodes/$node/$type/$vmid/status/shutdown";
> + print STDERR "Shutting down $type_text $vmid (Timeout = $timeout seconds)\n";
> + return $api_client->post($url, $params);
> + };
> +
> + my $check_task = sub {
> + my ($api_client, $vmid, $guest, $is_error, $task) = @_;
> + my $node = $guest->{node};
> + if ($is_error) {
> + my $type_text = get_type_text($guest->{type});
> + print STDERR "Stopping $type_text $vmid failed: $task->{exitstatus}\n";
> + }
> + };
> +
> + my $max_workers = $param->{'max-workers'} // 1;
> + my $failed = foreach_guest($startlist, $max_workers, $start_task, $check_task);
> +
> + if (scalar($failed->@*)) {
> + die "Some guests failed to shutdown " . join(', ', $failed->@*) . "\n";
> + }
> + };
> +
> + return $rpcenv->fork_worker('bulkshutdown', undef, $authuser, $code);
> + }});
> +
> +__PACKAGE__->register_method({
> + name => 'migrate',
> + path => 'migrate',
> + method => 'POST',
> + description => "Bulk migrate all guests on the cluster.",
> + permissions => { user => 'all' },
description here as well
> + protected => 1,
> + parameters => {
> + additionalProperties => 0,
> + properties => {
> + vms => {
> + description => "Only consider guests from this comma separated list of VMIDs.",
> + type => 'string', format => 'pve-vmid-list',
> + optional => 1,
> + },
> + 'target-node' => get_standard_option('pve-node', { description => "Target node." }),
> + online => {
> + type => 'boolean',
> + description => "Enable live migration for VMs and restart migration for CTs.",
> + optional => 1,
> + },
> + "with-local-disks" => {
> + type => 'boolean',
> + description => "Enable live storage migration for local disk",
> + optional => 1,
> + },
> + 'max-workers' => {
> + description => "How many parallel tasks at maximum should be started.",
> + optional => 1,
> + default => 1,
> + type => 'integer',
> + },
> + # TODO:
> + # Failure resolution mode (fail, warn, retry?)
> + # mode-limits (offline only, suspend only, ?)
> + # filter (tags, name, ?)
> + },
> + },
> + returns => {
> + type => 'string',
> + description => "UPID of the worker",
> + },
> + code => sub {
> + my ($param) = @_;
> +
> + my $rpcenv = PVE::RPCEnvironment::get();
> + my $authuser = $rpcenv->get_user();
> +
> + check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.Migrate' ]);
> +
> + my $code = sub {
> + my $list = PVE::API2::Nodes::Nodeinfo::get_filtered_vmlist(undef, $param->{vms}, 1, 1);
> +
> + my $start_task = sub {
> + my ($api_client, $vmid, $guest) = @_;
> + my $node = $guest->{node};
> +
> + my $type = $guest->{type};
> + my $type_text = get_type_text($type);
> +
> + if ($node eq $param->{'target-node'}) {
> + print STDERR "$type_text $vmid already on $node, skipping.\n";
> + return 1;
> + }
> +
> + my $params = {
> + target => $param->{'target-node'},
> + };
> +
> + if ($type eq 'lxc') {
> + $params->{restart} = $param->{online} if defined($param->{online});
> + } elsif ($type eq 'qemu') {
> + $params->{online} = $param->{online} if defined($param->{online});
> + $params->{'with-local-disks'} = $param->{'with-local-disks'} if defined($param->{'with-local-disks'});
> + }
> +
> + my $url = "/nodes/$node/$type/$vmid/migrate";
> + print STDERR "Migrating $type_text $vmid\n";
> + return $api_client->post($url, $params);
> + };
> +
> + my $check_task = sub {
> + my ($api_client, $vmid, $guest, $is_error, $task) = @_;
> + if ($is_error) {
> + my $type_text = get_type_text($guest->{type});
> + print STDERR "Migrating $type_text $vmid failed: $task->{exitstatus}\n";
> + }
> + };
> +
> + my $max_workers = $param->{'max-workers'} // 1;
> + my $failed = foreach_guest({ '0' => $list }, $max_workers, $start_task, $check_task);
> +
> + if (scalar($failed->@*)) {
> + die "Some guests failed to migrate " . join(', ', $failed->@*) . "\n";
> + }
> + };
> +
> + return $rpcenv->fork_worker('bulkmigrate', undef, $authuser, $code);
> + }});
> +
> +1;
> diff --git a/PVE/API2/Cluster/Makefile b/PVE/API2/Cluster/Makefile
> index b109e5cb..ed02b4be 100644
> --- a/PVE/API2/Cluster/Makefile
> +++ b/PVE/API2/Cluster/Makefile
> @@ -6,6 +6,7 @@ SUBDIRS=Mapping
> # ensure we do not conflict with files shipped by pve-cluster!!
> PERLSOURCE= \
> BackupInfo.pm \
> + Bulk.pm \
> MetricServer.pm \
> Mapping.pm \
> Notifications.pm \
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index 9cdf19db..02bc7299 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -1829,7 +1829,7 @@ __PACKAGE__->register_method({
> # * vmid whitelist
> # * guest is a template (default: skip)
> # * guest is HA manged (default: skip)
> -my $get_filtered_vmlist = sub {
> +sub get_filtered_vmlist {
> my ($nodename, $vmfilter, $templates, $ha_managed) = @_;
>
> my $vmlist = PVE::Cluster::get_vmlist();
> @@ -1856,13 +1856,14 @@ my $get_filtered_vmlist = sub {
> die "unknown virtual guest type '$d->{type}'\n";
> }
>
> - my $conf = $class->load_config($vmid);
> + my $conf = $class->load_config($vmid, $d->{node});
> return if !$templates && $class->is_template($conf);
> return if !$ha_managed && PVE::HA::Config::vm_is_ha_managed($vmid);
>
> $res->{$vmid}->{conf} = $conf;
> $res->{$vmid}->{type} = $d->{type};
> $res->{$vmid}->{class} = $class;
> + $res->{$vmid}->{node} = $d->{node};
> };
> warn $@ if $@;
> }
> @@ -1871,13 +1872,13 @@ my $get_filtered_vmlist = sub {
> };
>
> # return all VMs which should get started/stopped on power up/down
> -my $get_start_stop_list = sub {
> +sub get_start_stop_list {
> my ($nodename, $autostart, $vmfilter) = @_;
>
> # do not skip HA vms on force or if a specific VMID set is wanted
> my $include_ha_managed = defined($vmfilter) ? 1 : 0;
>
> - my $vmlist = $get_filtered_vmlist->($nodename, $vmfilter, undef, $include_ha_managed);
> + my $vmlist = get_filtered_vmlist($nodename, $vmfilter, undef, $include_ha_managed);
>
> my $resList = {};
> foreach my $vmid (keys %$vmlist) {
> @@ -1889,15 +1890,16 @@ my $get_start_stop_list = sub {
>
> $resList->{$order}->{$vmid} = $startup;
> $resList->{$order}->{$vmid}->{type} = $vmlist->{$vmid}->{type};
> + $resList->{$order}->{$vmid}->{node} = $vmlist->{$vmid}->{node};
> }
>
> return $resList;
> -};
> +}
>
> my $remove_locks_on_startup = sub {
> my ($nodename) = @_;
>
> - my $vmlist = &$get_filtered_vmlist($nodename, undef, undef, 1);
> + my $vmlist = get_filtered_vmlist($nodename, undef, undef, 1);
>
> foreach my $vmid (keys %$vmlist) {
> my $conf = $vmlist->{$vmid}->{conf};
> @@ -1983,7 +1985,7 @@ __PACKAGE__->register_method ({
> warn $@ if $@;
>
> my $autostart = $force ? undef : 1;
> - my $startList = $get_start_stop_list->($nodename, $autostart, $param->{vms});
> + my $startList = get_start_stop_list($nodename, $autostart, $param->{vms});
>
> # Note: use numeric sorting with <=>
> for my $order (sort {$a <=> $b} keys %$startList) {
> @@ -2096,7 +2098,7 @@ __PACKAGE__->register_method ({
> minimum => 0,
> maximum => 2 * 3600, # mostly arbitrary, but we do not want to high timeouts
> },
> - },
> + }
> },
> returns => {
> type => 'string',
> @@ -2123,7 +2125,7 @@ __PACKAGE__->register_method ({
>
> $rpcenv->{type} = 'priv'; # to start tasks in background
>
> - my $stopList = $get_start_stop_list->($nodename, undef, $param->{vms});
> + my $stopList = get_start_stop_list($nodename, undef, $param->{vms});
>
> my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
> my $datacenterconfig = cfs_read_file('datacenter.cfg');
> @@ -2246,7 +2248,7 @@ __PACKAGE__->register_method ({
>
> $rpcenv->{type} = 'priv'; # to start tasks in background
>
> - my $toSuspendList = $get_start_stop_list->($nodename, undef, $param->{vms});
> + my $toSuspendList = get_start_stop_list($nodename, undef, $param->{vms});
>
> my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
> my $datacenterconfig = cfs_read_file('datacenter.cfg');
> @@ -2434,7 +2436,7 @@ __PACKAGE__->register_method ({
> my $code = sub {
> $rpcenv->{type} = 'priv'; # to start tasks in background
>
> - my $vmlist = &$get_filtered_vmlist($nodename, $param->{vms}, 1, 1);
> + my $vmlist = get_filtered_vmlist($nodename, $param->{vms}, 1, 1);
> if (!scalar(keys %$vmlist)) {
> warn "no virtual guests matched, nothing to do..\n";
> return;
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [relevance 1%]
* [pve-devel] [RFC PATCH manager] WIP: api: implement node-independent bulk actions
@ 2025-03-18 10:39 8% Dominik Csapak
2025-03-18 11:30 1% ` Stefan Hanreich
0 siblings, 1 reply; 23+ results
From: Dominik Csapak @ 2025-03-18 10:39 UTC (permalink / raw)
To: pve-devel
To achieve this, we start a worker task and use our generic api client
to start the tasks on the relevant nodes. The client always points
to 'localhost' so we let the pveproxy worry about the proxying etc.
We reuse some logic from the startall/stopall/etc. calls, like getting
the ordered guest info list.
Not yet implemented are:
* filters
* failure mode resolution (we could implement this later too)
* token handling (not sure if we need this at all if we check the
permissions correctly upfront?)
* suspend
* some call specific parameters
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
this is a pre-requisite for having bulk actions on PDM.
Since we normally don't do such things 'cluster-wide' I wanted to
send the patch early to get feedback on my design decisons like:
* using the api client this way
* api naming/location
* handling parallel requests
* etc.
There are alternative methods to achieve similar results:
* use some kind of queuing system on the cluster (e.g. via pmxcfs)
* using the 'startall'/'stopall' calls from pve in PDM
* surely some other thing I didn't think about
We can of course start with this, and change the underlying mechanism
later too.
If we go this route, I could also rewrite the code in rust if wanted,
since there is nothing particularly dependent on perl here
(besides getting the vmlist, but that could stay in perl).
The bulk of the logic is how to start tasks + handle them finishing +
handling filter + concurrency.
PVE/API2/Cluster.pm | 7 +
PVE/API2/Cluster/Bulk.pm | 475 ++++++++++++++++++++++++++++++++++++++
PVE/API2/Cluster/Makefile | 1 +
PVE/API2/Nodes.pm | 24 +-
4 files changed, 496 insertions(+), 11 deletions(-)
create mode 100644 PVE/API2/Cluster/Bulk.pm
diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index a0e5c11b..478610e6 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -25,6 +25,7 @@ use PVE::API2::ACMEAccount;
use PVE::API2::ACMEPlugin;
use PVE::API2::Backup;
use PVE::API2::Cluster::BackupInfo;
+use PVE::API2::Cluster::Bulk;
use PVE::API2::Cluster::Ceph;
use PVE::API2::Cluster::Mapping;
use PVE::API2::Cluster::Jobs;
@@ -103,6 +104,11 @@ __PACKAGE__->register_method ({
path => 'mapping',
});
+__PACKAGE__->register_method ({
+ subclass => "PVE::API2::Cluster::Bulk",
+ path => 'bulk-actions',
+});
+
if ($have_sdn) {
__PACKAGE__->register_method ({
subclass => "PVE::API2::Network::SDN",
@@ -162,6 +168,7 @@ __PACKAGE__->register_method ({
{ name => 'resources' },
{ name => 'status' },
{ name => 'tasks' },
+ { name => 'bulk-actions' },
];
if ($have_sdn) {
diff --git a/PVE/API2/Cluster/Bulk.pm b/PVE/API2/Cluster/Bulk.pm
new file mode 100644
index 00000000..05a79155
--- /dev/null
+++ b/PVE/API2/Cluster/Bulk.pm
@@ -0,0 +1,475 @@
+package PVE::API2::Cluster::Bulk;
+
+use strict;
+use warnings;
+
+use PVE::APIClient::LWP;
+use PVE::AccessControl;
+use PVE::Cluster;
+use PVE::Exception qw(raise raise_perm_exc raise_param_exc);
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::RESTHandler;
+use PVE::RPCEnvironment;
+use PVE::Tools qw();
+
+use PVE::API2::Nodes;
+
+use base qw(PVE::RESTHandler);
+
+
+__PACKAGE__->register_method ({
+ name => 'index',
+ path => '',
+ method => 'GET',
+ description => "Bulk action index.",
+ permissions => { user => 'all' },
+ parameters => {
+ additionalProperties => 0,
+ properties => {},
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {},
+ },
+ links => [ { rel => 'child', href => "{name}" } ],
+ },
+ code => sub {
+ my ($param) = @_;
+
+ return [
+ { name => 'start' },
+ { name => 'shutdown' },
+ { name => 'migrate' },
+ ];
+ }});
+
+sub create_client {
+ my ($authuser, $request_timeout) = @_;
+ my ($user, undef) = PVE::AccessControl::split_tokenid($authuser, 1);
+
+ # TODO: How to handle Tokens?
+ my $ticket = PVE::AccessControl::assemble_ticket($user || $authuser);
+ my $csrf_token = PVE::AccessControl::assemble_csrf_prevention_token($user || $authuser);
+
+ my $node = PVE::INotify::nodename();
+ my $fingerprint = PVE::Cluster::get_node_fingerprint($node);
+
+ my $conn_args = {
+ protocol => 'https',
+ host => 'localhost', # always call the api locally, let pveproxy handle the proxying
+ port => 8006,
+ ticket => $ticket,
+ timeout => $request_timeout // 25, # default slightly shorter than the proxy->daemon timeout
+ cached_fingerprints => {
+ $fingerprint => 1,
+ }
+ };
+
+ my $api_client = PVE::APIClient::LWP->new($conn_args->%*);
+ if (defined($csrf_token)) {
+ $api_client->update_csrftoken($csrf_token);
+ }
+
+ return $api_client;
+}
+
+# takes a vm list in the form of
+# {
+# 0 => {
+# 100 => { .. guest info ..},
+# 101 => { .. guest info ..},
+# },
+# 1 => {
+# 102 => { .. guest info ..},
+# 103 => { .. guest info ..},
+# },
+# }
+#
+# max_workers: how many parallel tasks should be started.
+# start_task: a sub that returns eiter a upid or 1 (undef means failure)
+# check_task: if start_task returned a upid, will wait for that to finish and
+# call check_task with the resulting task status
+sub foreach_guest {
+ my ($startlist, $max_workers, $start_task, $check_task) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+ my $api_client = create_client($authuser);
+
+ my $failed = [];
+ for my $order (sort {$a <=> $b} keys $startlist->%*) {
+ my $vmlist = $startlist->{$order};
+ my $workers = {};
+
+ for my $vmid (sort {$a <=> $b} keys $vmlist->%*) {
+
+ # wait until at least one slot is free
+ while (scalar(keys($workers->%*)) >= $max_workers) {
+ for my $upid (keys($workers->%*)) {
+ my $worker = $workers->{$upid};
+ my $node = $worker->{guest}->{node};
+
+ my $task = $api_client->get("/nodes/$node/tasks/$upid/status");
+ if ($task->{status} ne 'running') {
+ my $is_error = PVE::Tools::upid_status_is_error($task->{exitstatus});
+ push $failed->@*, $worker->{vmid} if $is_error;
+
+ $check_task->($api_client, $worker->{vmid}, $worker->{guest}, $is_error, $task);
+
+ delete $workers->{$upid};
+ }
+ }
+ sleep(1); # How much?
+ }
+
+ my $guest = $vmlist->{$vmid};
+ my $upid = eval { $start_task->($api_client, $vmid, $guest) };
+ warn $@ if $@;
+
+ # success but no task necessary
+ next if "$upid" eq "1";
+
+ if (!defined($upid)) {
+ push $failed->@*, $vmid;
+ continue;
+ }
+
+ $workers->{$upid} = {
+ vmid => $vmid,
+ guest => $guest,
+ };
+ }
+
+ # wait until current order is finished
+ for my $upid (keys($workers->%*)) {
+ my $worker = $workers->{$upid};
+ my $node = $worker->{guest}->{node};
+
+ my $task = wait_for_task_finished($api_client, $node, $upid);
+ my $is_error = PVE::Tools::upid_status_is_error($task->{exitstatus});
+ push $failed->@*, $worker->{vmid} if $is_error;
+
+ $check_task->($api_client, $worker->{vmid}, $worker->{guest}, $is_error, $task);
+
+ delete $workers->{$upid};
+ }
+ }
+
+ return $failed;
+}
+
+sub get_type_text {
+ my ($type) = @_;
+
+ if ($type eq 'lxc') {
+ return 'CT';
+ } elsif ($type eq 'qemu') {
+ return 'VM';
+ } else {
+ die "unknown guest type $type\n";
+ }
+}
+
+sub wait_for_task_finished {
+ my ($client, $node, $upid) = @_;
+
+ while (1) {
+ my $task = $client->get("/nodes/$node/tasks/$upid/status");
+ return $task if $task->{status} ne 'running';
+ sleep(1); # How much time?
+ }
+}
+
+sub check_guest_permissions {
+ my ($rpcenv, $authuser, $vmlist, $priv_list) = @_;
+
+ my @vms = PVE::Tools::split_list($vmlist);
+ if (scalar(@vms) > 0) {
+ $rpcenv->check($authuser, "/vms/$_", $priv_list) for @vms;
+ } elsif (!$rpcenv->check($authuser, "/", $priv_list, 1)) {
+ raise_perm_exc("/, VM.PowerMgmt");
+ }
+}
+
+__PACKAGE__->register_method({
+ name => 'start',
+ path => 'start',
+ method => 'POST',
+ description => "Bulk start all guests on the cluster.",
+ permissions => { user => 'all' },
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ vms => {
+ description => "Only consider guests from this comma separated list of VMIDs.",
+ type => 'string', format => 'pve-vmid-list',
+ optional => 1,
+ },
+ 'max-workers' => {
+ description => "How many parallel tasks at maximum should be started.",
+ optional => 1,
+ default => 1,
+ type => 'integer',
+ },
+ # TODO:
+ # Failure resolution mode (fail, warn, retry?)
+ # mode-limits (offline only, suspend only, ?)
+ # filter (tags, name, ?)
+ },
+ },
+ returns => {
+ type => 'string',
+ description => "UPID of the worker",
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
+ check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.PowerMgmt' ]);
+
+ my $code = sub {
+ my $startlist = PVE::API2::Nodes::Nodeinfo::get_start_stop_list(undef, undef, $param->{vms});
+
+ my $start_task = sub {
+ my ($api_client, $vmid, $guest) = @_;
+ my $node = $guest->{node};
+
+ my $type = $guest->{type};
+ my $type_text = get_type_text($type);
+
+ my $url = "/nodes/$node/$type/$vmid/status/start";
+ print STDERR "Starting $type_text $vmid\n";
+ return $api_client->post($url);
+ };
+
+ my $check_task = sub {
+ my ($api_client, $vmid, $guest, $is_error, $task) = @_;
+ my $node = $guest->{node};
+
+ my $default_delay = 0;
+
+ if (!$is_error) {
+ my $delay = defined($guest->{up}) ? int($guest->{up}) : $default_delay;
+ if ($delay > 0) {
+ print STDERR "Waiting for $delay seconds (startup delay)\n" if $guest->{up};
+ for (my $i = 0; $i < $delay; $i++) {
+ sleep(1);
+ }
+ }
+ } else {
+ my $type_text = get_type_text($guest->{type});
+ print STDERR "Starting $type_text $vmid failed: $task->{exitstatus}\n";
+ }
+ };
+
+ my $max_workers = $param->{'max-workers'} // 1;
+ my $failed = foreach_guest($startlist, $max_workers, $start_task, $check_task);
+
+ if (scalar($failed->@*)) {
+ die "Some guests failed to start: " . join(', ', $failed->@*) . "\n";
+ }
+ };
+
+ return $rpcenv->fork_worker('bulkstart', undef, $authuser, $code);
+ }});
+
+__PACKAGE__->register_method({
+ name => 'shutdown',
+ path => 'shutdown',
+ method => 'POST',
+ description => "Bulk shutdown all guests on the cluster.",
+ permissions => { user => 'all' },
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ vms => {
+ description => "Only consider guests from this comma separated list of VMIDs.",
+ type => 'string', format => 'pve-vmid-list',
+ optional => 1,
+ },
+ timeout => {
+ description => "Default shutdown timeout in seconds if none is configured for the guest.",
+ type => 'integer',
+ default => 180,
+ optional => 1,
+ },
+ 'max-workers' => {
+ description => "How many parallel tasks at maximum should be started.",
+ optional => 1,
+ default => 1,
+ type => 'integer',
+ },
+ # TODO:
+ # Failure resolution mode (fail, warn, retry?)
+ # mode-limits (offline only, suspend only, ?)
+ # filter (tags, name, ?)
+ },
+ },
+ returns => {
+ type => 'string',
+ description => "UPID of the worker",
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
+ check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.PowerMgmt' ]);
+
+ my $code = sub {
+ my $startlist = PVE::API2::Nodes::Nodeinfo::get_start_stop_list(undef, undef, $param->{vms});
+
+ # reverse order for shutdown
+ for my $order (keys $startlist->%*) {
+ my $list = delete $startlist->{$order};
+ $order = $order * -1;
+ $startlist->{$order} = $list;
+ }
+
+ my $start_task = sub {
+ my ($api_client, $vmid, $guest) = @_;
+ my $node = $guest->{node};
+
+ my $type = $guest->{type};
+ my $type_text = get_type_text($type);
+
+ my $timeout = int($guest->{down} // $param->{timeout} // 180);
+
+ my $params = {
+ forceStop => 1,
+ timeout => $timeout,
+ };
+
+ my $url = "/nodes/$node/$type/$vmid/status/shutdown";
+ print STDERR "Shutting down $type_text $vmid (Timeout = $timeout seconds)\n";
+ return $api_client->post($url, $params);
+ };
+
+ my $check_task = sub {
+ my ($api_client, $vmid, $guest, $is_error, $task) = @_;
+ my $node = $guest->{node};
+ if ($is_error) {
+ my $type_text = get_type_text($guest->{type});
+ print STDERR "Stopping $type_text $vmid failed: $task->{exitstatus}\n";
+ }
+ };
+
+ my $max_workers = $param->{'max-workers'} // 1;
+ my $failed = foreach_guest($startlist, $max_workers, $start_task, $check_task);
+
+ if (scalar($failed->@*)) {
+ die "Some guests failed to shutdown " . join(', ', $failed->@*) . "\n";
+ }
+ };
+
+ return $rpcenv->fork_worker('bulkshutdown', undef, $authuser, $code);
+ }});
+
+__PACKAGE__->register_method({
+ name => 'migrate',
+ path => 'migrate',
+ method => 'POST',
+ description => "Bulk migrate all guests on the cluster.",
+ permissions => { user => 'all' },
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ vms => {
+ description => "Only consider guests from this comma separated list of VMIDs.",
+ type => 'string', format => 'pve-vmid-list',
+ optional => 1,
+ },
+ 'target-node' => get_standard_option('pve-node', { description => "Target node." }),
+ online => {
+ type => 'boolean',
+ description => "Enable live migration for VMs and restart migration for CTs.",
+ optional => 1,
+ },
+ "with-local-disks" => {
+ type => 'boolean',
+ description => "Enable live storage migration for local disk",
+ optional => 1,
+ },
+ 'max-workers' => {
+ description => "How many parallel tasks at maximum should be started.",
+ optional => 1,
+ default => 1,
+ type => 'integer',
+ },
+ # TODO:
+ # Failure resolution mode (fail, warn, retry?)
+ # mode-limits (offline only, suspend only, ?)
+ # filter (tags, name, ?)
+ },
+ },
+ returns => {
+ type => 'string',
+ description => "UPID of the worker",
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
+ check_guest_permissions($rpcenv, $authuser, $param->{vms}, [ 'VM.Migrate' ]);
+
+ my $code = sub {
+ my $list = PVE::API2::Nodes::Nodeinfo::get_filtered_vmlist(undef, $param->{vms}, 1, 1);
+
+ my $start_task = sub {
+ my ($api_client, $vmid, $guest) = @_;
+ my $node = $guest->{node};
+
+ my $type = $guest->{type};
+ my $type_text = get_type_text($type);
+
+ if ($node eq $param->{'target-node'}) {
+ print STDERR "$type_text $vmid already on $node, skipping.\n";
+ return 1;
+ }
+
+ my $params = {
+ target => $param->{'target-node'},
+ };
+
+ if ($type eq 'lxc') {
+ $params->{restart} = $param->{online} if defined($param->{online});
+ } elsif ($type eq 'qemu') {
+ $params->{online} = $param->{online} if defined($param->{online});
+ $params->{'with-local-disks'} = $param->{'with-local-disks'} if defined($param->{'with-local-disks'});
+ }
+
+ my $url = "/nodes/$node/$type/$vmid/migrate";
+ print STDERR "Migrating $type_text $vmid\n";
+ return $api_client->post($url, $params);
+ };
+
+ my $check_task = sub {
+ my ($api_client, $vmid, $guest, $is_error, $task) = @_;
+ if ($is_error) {
+ my $type_text = get_type_text($guest->{type});
+ print STDERR "Migrating $type_text $vmid failed: $task->{exitstatus}\n";
+ }
+ };
+
+ my $max_workers = $param->{'max-workers'} // 1;
+ my $failed = foreach_guest({ '0' => $list }, $max_workers, $start_task, $check_task);
+
+ if (scalar($failed->@*)) {
+ die "Some guests failed to migrate " . join(', ', $failed->@*) . "\n";
+ }
+ };
+
+ return $rpcenv->fork_worker('bulkmigrate', undef, $authuser, $code);
+ }});
+
+1;
diff --git a/PVE/API2/Cluster/Makefile b/PVE/API2/Cluster/Makefile
index b109e5cb..ed02b4be 100644
--- a/PVE/API2/Cluster/Makefile
+++ b/PVE/API2/Cluster/Makefile
@@ -6,6 +6,7 @@ SUBDIRS=Mapping
# ensure we do not conflict with files shipped by pve-cluster!!
PERLSOURCE= \
BackupInfo.pm \
+ Bulk.pm \
MetricServer.pm \
Mapping.pm \
Notifications.pm \
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 9cdf19db..02bc7299 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1829,7 +1829,7 @@ __PACKAGE__->register_method({
# * vmid whitelist
# * guest is a template (default: skip)
# * guest is HA manged (default: skip)
-my $get_filtered_vmlist = sub {
+sub get_filtered_vmlist {
my ($nodename, $vmfilter, $templates, $ha_managed) = @_;
my $vmlist = PVE::Cluster::get_vmlist();
@@ -1856,13 +1856,14 @@ my $get_filtered_vmlist = sub {
die "unknown virtual guest type '$d->{type}'\n";
}
- my $conf = $class->load_config($vmid);
+ my $conf = $class->load_config($vmid, $d->{node});
return if !$templates && $class->is_template($conf);
return if !$ha_managed && PVE::HA::Config::vm_is_ha_managed($vmid);
$res->{$vmid}->{conf} = $conf;
$res->{$vmid}->{type} = $d->{type};
$res->{$vmid}->{class} = $class;
+ $res->{$vmid}->{node} = $d->{node};
};
warn $@ if $@;
}
@@ -1871,13 +1872,13 @@ my $get_filtered_vmlist = sub {
};
# return all VMs which should get started/stopped on power up/down
-my $get_start_stop_list = sub {
+sub get_start_stop_list {
my ($nodename, $autostart, $vmfilter) = @_;
# do not skip HA vms on force or if a specific VMID set is wanted
my $include_ha_managed = defined($vmfilter) ? 1 : 0;
- my $vmlist = $get_filtered_vmlist->($nodename, $vmfilter, undef, $include_ha_managed);
+ my $vmlist = get_filtered_vmlist($nodename, $vmfilter, undef, $include_ha_managed);
my $resList = {};
foreach my $vmid (keys %$vmlist) {
@@ -1889,15 +1890,16 @@ my $get_start_stop_list = sub {
$resList->{$order}->{$vmid} = $startup;
$resList->{$order}->{$vmid}->{type} = $vmlist->{$vmid}->{type};
+ $resList->{$order}->{$vmid}->{node} = $vmlist->{$vmid}->{node};
}
return $resList;
-};
+}
my $remove_locks_on_startup = sub {
my ($nodename) = @_;
- my $vmlist = &$get_filtered_vmlist($nodename, undef, undef, 1);
+ my $vmlist = get_filtered_vmlist($nodename, undef, undef, 1);
foreach my $vmid (keys %$vmlist) {
my $conf = $vmlist->{$vmid}->{conf};
@@ -1983,7 +1985,7 @@ __PACKAGE__->register_method ({
warn $@ if $@;
my $autostart = $force ? undef : 1;
- my $startList = $get_start_stop_list->($nodename, $autostart, $param->{vms});
+ my $startList = get_start_stop_list($nodename, $autostart, $param->{vms});
# Note: use numeric sorting with <=>
for my $order (sort {$a <=> $b} keys %$startList) {
@@ -2096,7 +2098,7 @@ __PACKAGE__->register_method ({
minimum => 0,
maximum => 2 * 3600, # mostly arbitrary, but we do not want to high timeouts
},
- },
+ }
},
returns => {
type => 'string',
@@ -2123,7 +2125,7 @@ __PACKAGE__->register_method ({
$rpcenv->{type} = 'priv'; # to start tasks in background
- my $stopList = $get_start_stop_list->($nodename, undef, $param->{vms});
+ my $stopList = get_start_stop_list($nodename, undef, $param->{vms});
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
my $datacenterconfig = cfs_read_file('datacenter.cfg');
@@ -2246,7 +2248,7 @@ __PACKAGE__->register_method ({
$rpcenv->{type} = 'priv'; # to start tasks in background
- my $toSuspendList = $get_start_stop_list->($nodename, undef, $param->{vms});
+ my $toSuspendList = get_start_stop_list($nodename, undef, $param->{vms});
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
my $datacenterconfig = cfs_read_file('datacenter.cfg');
@@ -2434,7 +2436,7 @@ __PACKAGE__->register_method ({
my $code = sub {
$rpcenv->{type} = 'priv'; # to start tasks in background
- my $vmlist = &$get_filtered_vmlist($nodename, $param->{vms}, 1, 1);
+ my $vmlist = get_filtered_vmlist($nodename, $param->{vms}, 1, 1);
if (!scalar(keys %$vmlist)) {
warn "no virtual guests matched, nothing to do..\n";
return;
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply related [relevance 8%]
* [pve-devel] [PATCH v2 qemu 1/4] update submodule and patches to 7.1.0
@ 2022-10-14 12:07 11% Fiona Ebner
0 siblings, 0 replies; 23+ results
From: Fiona Ebner @ 2022-10-14 12:07 UTC (permalink / raw)
To: pve-devel
Notable changes:
* The only big change is the switch to using a custom QIOChannel for
savevm-async, because the previously used QEMUFileOps was dropped.
Changes to the current implementation:
* Switch to vector based methods as required for an IO channel. For
short reads the passed-in IO vector is stuffed with zeroes at the
end, just to be sure.
* For reading: The documentation in include/io/channel.h states that
at least one byte should be read, so also error out when whe are
at the very end instead of returning 0.
* For reading: Fix off-by-one error when request goes beyond end.
The wrong code piece was:
if ((pos + size) > maxlen) {
size = maxlen - pos - 1;
}
Previously, the last byte would not be read. It's actually
possible to get a snapshot .raw file that has content all the way
up the final 512 byte (= BDRV_SECTOR_SIZE) boundary without any
trailing zero bytes (I wrote a script to do it).
Luckily, it didn't cause a real issue, because qemu_loadvm_state()
is not interested in the final (i.e. QEMU_VM_VMDESCRIPTION)
section. The buffer for reading it is simply freed up afterwards
and the function will assume that it read the whole section, even
if that's not the case.
* For writing: Make use of the generated blk_pwritev() wrapper
instead of manually wrapping the coroutine to simplify and save a
few lines.
* Adapt to changed interfaces for blk_{pread,pwrite}:
* a9262f551e ("block: Change blk_{pread,pwrite}() param order")
* 3b35d4542c ("block: Add a 'flags' param to blk_pread()")
* bf5b16fa40 ("block: Make blk_{pread,pwrite}() return 0 on success")
Those changes especially affected the qemu-img dd patches, because
the context also changed, but also some of our block drivers used
the functions.
* Drop qemu-common.h include: it got renamed after essentially
everything was moved to other headers. The only remaining user I
could find for things dropped from the header between 7.0 and 7.1
was qemu_get_vm_name() in the iscsi-initiatorname patch, but it
already includes the header to which the function was moved.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
Changes from v1 (thanks to Wolfgang for the suggestions!):
* Drop the memset for short reads. The caller is responsible for not
using more bytes then we reported.
* Use the generated blk_pwritev() wrapper instead of manually doing
so. Makes the code easier to read and avoids quite a bit of
boilerplate.
...d-support-for-sync-bitmap-mode-never.patch | 22 +-
...-support-for-conditional-and-always-.patch | 2 +-
...check-for-bitmap-mode-without-bitmap.patch | 2 +-
...-to-bdrv_dirty_bitmap_merge_internal.patch | 2 +-
.../0006-mirror-move-some-checks-to-qmp.patch | 4 +-
...race-with-clients-disconnecting-earl.patch | 8 +-
...k-gluster-correctly-set-max_pdiscard.patch | 47 ---
...003-block-vmdk-Fix-reopening-bs-file.patch | 129 --------
...balanced-plugged-counter-in-laio_io_.patch | 44 ---
...erflow-in-snprintf-string-formatting.patch | 100 -------
...Fix-disabling-MPX-on-cpu-host-with-M.patch | 48 ---
...ontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch | 121 --------
...outine-use-QEMU_DEFINE_STATIC_CO_TLS.patch | 123 --------
...ame-qemu_coroutine_inc-dec_pool_size.patch | 90 ------
...outine-Revert-to-constant-batch-size.patch | 121 --------
...-not-consult-nonexistent-host-leaves.patch | 117 --------
...ctrl-and-event-handler-functions-in-.patch | 108 -------
...t-waste-CPU-polling-the-event-virtqu.patch | 91 ------
...k-descriptor-chain-in-private-at-SVQ.patch | 102 -------
...Fix-device-s-used-descriptor-dequeue.patch | 62 ----
...ex-calculus-at-vhost_vdpa_get_vring_.patch | 39 ---
...ex-calculus-at-vhost_vdpa_svqs_start.patch | 35 ---
...virtio-Replace-g_memdup-by-g_memdup2.patch | 74 -----
...Fix-element-in-vhost_svq_add-failure.patch | 47 ---
...20-io_uring-fix-short-read-slow-path.patch | 49 ---
...criptor-status-in-a-separate-operati.patch | 82 -----
...k-file-change-locking-default-to-off.patch | 6 +-
...he-CPU-model-to-kvm64-32-instead-of-.patch | 4 +-
...erfs-no-default-logfile-if-daemonize.patch | 2 +-
...lock-rbd-disable-rbd_cache_writethro.patch | 2 +-
.../0007-PVE-Up-qmp-add-get_link_status.patch | 12 +-
...PVE-Up-glusterfs-allow-partial-reads.patch | 2 +-
...return-success-on-info-without-snaps.patch | 4 +-
...dd-add-osize-and-read-from-to-stdin-.patch | 70 +++--
...E-Up-qemu-img-dd-add-isize-parameter.patch | 23 +-
...PVE-Up-qemu-img-dd-add-n-skip_create.patch | 12 +-
...virtio-balloon-improve-query-balloon.patch | 13 +-
.../0014-PVE-qapi-modify-query-machines.patch | 6 +-
.../0015-PVE-qapi-modify-spice-query.patch | 4 +-
...nnel-implementation-for-savevm-async.patch | 280 ++++++++++++++++++
...sync-for-background-state-snapshots.patch} | 148 +++------
...dd-optional-buffer-size-to-QEMUFile.patch} | 132 +++++----
...dd-the-zeroinit-block-driver-filter.patch} | 2 +-
...Add-dummy-id-command-line-parameter.patch} | 12 +-
...-target-i386-disable-LINT0-after-re.patch} | 0
...e-posix-make-locking-optiono-on-cre.patch} | 18 +-
...-PVE-monitor-disable-oob-capability.patch} | 0
...ed-balloon-qemu-4-0-config-size-fal.patch} | 4 +-
...-Allow-version-code-in-machine-type.patch} | 16 +-
...-bcs-bitmap-initialization-to-job-c.patch} | 10 +-
...E-Backup-add-vma-backup-format-code.patch} | 26 +-
...Backup-add-backup-dump-block-driver.patch} | 15 +-
...kup-proxmox-backup-patches-for-qemu.patch} | 36 +--
...store-new-command-to-restore-from-p.patch} | 15 +-
...rty-bitmap-tracking-for-incremental.patch} | 14 +-
...patch => 0032-PVE-various-PBS-fixes.patch} | 6 +-
...-driver-to-map-backup-archives-into.patch} | 63 ++--
...d-query_proxmox_support-QMP-command.patch} | 4 +-
...-add-query-pbs-bitmap-info-QMP-call.patch} | 14 +-
...t-stderr-to-journal-when-daemonized.patch} | 14 +-
...-sequential-job-transaction-support.patch} | 0
...transaction-to-synchronize-job-stat.patch} | 0
...block-on-finishing-and-cleanup-crea.patch} | 4 +-
...grate-dirty-bitmap-state-via-savevm.patch} | 16 +-
...irty-bitmap-migrate-other-bitmaps-e.patch} | 0
...ll-back-to-open-iscsi-initiatorname.patch} | 2 +-
...outine-QMP-for-backup-cancel_backup.patch} | 12 +-
... => 0044-PBS-add-master-key-support.patch} | 10 +-
...t-path-reads-without-allocation-if-.patch} | 0
...VE-block-stream-increase-chunk-size.patch} | 0
...ccept-NULL-qiov-in-bdrv_pad_request.patch} | 4 +-
...> 0048-block-add-alloc-track-driver.patch} | 2 +-
...alid-QAPI-names-for-backwards-compa.patch} | 4 +-
...register-yank-before-migration_inco.patch} | 6 +-
...add-l-option-for-loading-a-snapshot.patch} | 16 +-
...h => 0052-vma-allow-partial-restore.patch} | 32 +-
...patch => 0053-pbs-namespace-support.patch} | 20 +-
...rbd-workaround-for-ceph-issue-53784.patch} | 8 +-
...fix-handling-of-holes-in-.bdrv_co_b.patch} | 4 +-
...-rbd-implement-bdrv_co_block_status.patch} | 6 +-
...-jobs-correctly-cancel-in-error-sce.patch} | 0
...sure-jobs-in-di_list-are-referenced.patch} | 0
...-segfault-issues-upon-backup-cancel.patch} | 0
...upport-64KiB-unaligned-input-images.patch} | 6 +-
...-triggering-assertion-in-error-case.patch} | 0
...k-alloc-track-avoid-premature-break.patch} | 0
...passing-max-workers-performance-set.patch} | 8 +-
debian/patches/series | 115 +++----
qemu | 2 +-
89 files changed, 768 insertions(+), 2167 deletions(-)
delete mode 100644 debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch
delete mode 100644 debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch
delete mode 100644 debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
delete mode 100644 debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
delete mode 100644 debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
delete mode 100644 debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
delete mode 100644 debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
delete mode 100644 debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
delete mode 100644 debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch
delete mode 100644 debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
delete mode 100644 debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
delete mode 100644 debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
delete mode 100644 debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
delete mode 100644 debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
delete mode 100644 debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
delete mode 100644 debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
delete mode 100644 debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
delete mode 100644 debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
delete mode 100644 debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch
delete mode 100644 debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
create mode 100644 debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
rename debian/patches/pve/{0016-PVE-add-savevm-async-for-background-state-snapshots.patch => 0017-PVE-add-savevm-async-for-background-state-snapshots.patch} (88%)
rename debian/patches/pve/{0017-PVE-add-optional-buffer-size-to-QEMUFile.patch => 0018-PVE-add-optional-buffer-size-to-QEMUFile.patch} (52%)
rename debian/patches/pve/{0018-PVE-block-add-the-zeroinit-block-driver-filter.patch => 0019-PVE-block-add-the-zeroinit-block-driver-filter.patch} (99%)
rename debian/patches/pve/{0019-PVE-Add-dummy-id-command-line-parameter.patch => 0020-PVE-Add-dummy-id-command-line-parameter.patch} (86%)
rename debian/patches/pve/{0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch => 0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch} (100%)
rename debian/patches/pve/{0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch => 0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch} (90%)
rename debian/patches/pve/{0022-PVE-monitor-disable-oob-capability.patch => 0023-PVE-monitor-disable-oob-capability.patch} (100%)
rename debian/patches/pve/{0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch => 0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch} (95%)
rename debian/patches/pve/{0024-PVE-Allow-version-code-in-machine-type.patch => 0025-PVE-Allow-version-code-in-machine-type.patch} (93%)
rename debian/patches/pve/{0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch => 0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch} (88%)
rename debian/patches/pve/{0026-PVE-Backup-add-vma-backup-format-code.patch => 0027-PVE-Backup-add-vma-backup-format-code.patch} (99%)
rename debian/patches/pve/{0027-PVE-Backup-add-backup-dump-block-driver.patch => 0028-PVE-Backup-add-backup-dump-block-driver.patch} (96%)
rename debian/patches/pve/{0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch => 0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch} (98%)
rename debian/patches/pve/{0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch => 0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch} (95%)
rename debian/patches/pve/{0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch => 0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch} (98%)
rename debian/patches/pve/{0031-PVE-various-PBS-fixes.patch => 0032-PVE-various-PBS-fixes.patch} (99%)
rename debian/patches/pve/{0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch => 0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch} (91%)
rename debian/patches/pve/{0033-PVE-add-query_proxmox_support-QMP-command.patch => 0034-PVE-add-query_proxmox_support-QMP-command.patch} (97%)
rename debian/patches/pve/{0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch => 0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch} (98%)
rename debian/patches/pve/{0035-PVE-redirect-stderr-to-journal-when-daemonized.patch => 0036-PVE-redirect-stderr-to-journal-when-daemonized.patch} (86%)
rename debian/patches/pve/{0036-PVE-Add-sequential-job-transaction-support.patch => 0037-PVE-Add-sequential-job-transaction-support.patch} (100%)
rename debian/patches/pve/{0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch => 0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch} (100%)
rename debian/patches/pve/{0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch => 0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch} (99%)
rename debian/patches/pve/{0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch => 0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch} (96%)
rename debian/patches/pve/{0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch => 0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch} (100%)
rename debian/patches/pve/{0041-PVE-fall-back-to-open-iscsi-initiatorname.patch => 0042-PVE-fall-back-to-open-iscsi-initiatorname.patch} (98%)
rename debian/patches/pve/{0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch => 0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch} (99%)
rename debian/patches/pve/{0043-PBS-add-master-key-support.patch => 0044-PBS-add-master-key-support.patch} (97%)
rename debian/patches/pve/{0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch => 0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch} (100%)
rename debian/patches/pve/{0045-PVE-block-stream-increase-chunk-size.patch => 0046-PVE-block-stream-increase-chunk-size.patch} (100%)
rename debian/patches/pve/{0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch => 0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch} (90%)
rename debian/patches/pve/{0047-block-add-alloc-track-driver.patch => 0048-block-add-alloc-track-driver.patch} (99%)
rename debian/patches/pve/{0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch => 0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch} (95%)
rename debian/patches/pve/{0049-PVE-savevm-async-register-yank-before-migration_inco.patch => 0050-PVE-savevm-async-register-yank-before-migration_inco.patch} (90%)
rename debian/patches/pve/{0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch => 0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch} (91%)
rename debian/patches/pve/{0051-vma-allow-partial-restore.patch => 0052-vma-allow-partial-restore.patch} (94%)
rename debian/patches/pve/{0052-pbs-namespace-support.patch => 0053-pbs-namespace-support.patch} (96%)
rename debian/patches/pve/{0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch => 0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch} (92%)
rename debian/patches/pve/{0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch => 0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch} (90%)
rename debian/patches/pve/{0055-Revert-block-rbd-implement-bdrv_co_block_status.patch => 0056-Revert-block-rbd-implement-bdrv_co_block_status.patch} (97%)
rename debian/patches/pve/{0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch => 0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch} (100%)
rename debian/patches/pve/{0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch => 0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch} (100%)
rename debian/patches/pve/{0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch => 0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch} (100%)
rename debian/patches/pve/{0059-vma-create-support-64KiB-unaligned-input-images.patch => 0060-vma-create-support-64KiB-unaligned-input-images.patch} (92%)
rename debian/patches/pve/{0060-vma-create-avoid-triggering-assertion-in-error-case.patch => 0061-vma-create-avoid-triggering-assertion-in-error-case.patch} (100%)
rename debian/patches/pve/{0061-block-alloc-track-avoid-premature-break.patch => 0062-block-alloc-track-avoid-premature-break.patch} (100%)
rename debian/patches/pve/{0062-PVE-Backup-allow-passing-max-workers-performance-set.patch => 0063-PVE-Backup-allow-passing-max-workers-performance-set.patch} (98%)
diff --git a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
index 5301cf0..8cdca68 100644
--- a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
+++ b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
@@ -36,7 +36,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 files changed, 145 insertions(+), 29 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index d8ecb9efa2..d95a7d7940 100644
+index 3c4ab1159d..f2eca983f1 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -51,7 +51,7 @@ typedef struct MirrorBlockJob {
@@ -252,7 +252,7 @@ index d8ecb9efa2..d95a7d7940 100644
errp);
if (!job) {
diff --git a/blockdev.c b/blockdev.c
-index e46e831212..fa601838a3 100644
+index 9230888e34..9a1a3118ed 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2951,6 +2951,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
@@ -344,10 +344,10 @@ index e46e831212..fa601838a3 100644
has_granularity, granularity,
has_buf_size, buf_size,
diff --git a/include/block/block_int-global-state.h b/include/block/block_int-global-state.h
-index 0f21b0570b..e7f901d048 100644
+index b49f4eb35b..9d744db618 100644
--- a/include/block/block_int-global-state.h
+++ b/include/block/block_int-global-state.h
-@@ -148,7 +148,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
+@@ -149,7 +149,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, const char *replaces,
int creation_flags, int64_t speed,
uint32_t granularity, int64_t buf_size,
@@ -359,10 +359,10 @@ index 0f21b0570b..e7f901d048 100644
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index beeb91952a..fb25c2b245 100644
+index 2173e7734a..e1857e7094 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -1993,10 +1993,19 @@
+@@ -2000,10 +2000,19 @@
# (all the disk, only the sectors allocated in the topmost image, or
# only new I/O).
#
@@ -383,7 +383,7 @@ index beeb91952a..fb25c2b245 100644
#
# @buf-size: maximum amount of data in flight from source to
# target (since 1.4).
-@@ -2034,7 +2043,9 @@
+@@ -2043,7 +2052,9 @@
{ 'struct': 'DriveMirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*format': 'str', '*node-name': 'str', '*replaces': 'str',
@@ -394,7 +394,7 @@ index beeb91952a..fb25c2b245 100644
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
-@@ -2306,10 +2317,19 @@
+@@ -2322,10 +2333,19 @@
# (all the disk, only the sectors allocated in the topmost image, or
# only new I/O).
#
@@ -415,7 +415,7 @@ index beeb91952a..fb25c2b245 100644
#
# @buf-size: maximum amount of data in flight from source to
# target
-@@ -2358,7 +2378,8 @@
+@@ -2375,7 +2395,8 @@
{ 'command': 'blockdev-mirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*replaces': 'str',
@@ -426,10 +426,10 @@ index beeb91952a..fb25c2b245 100644
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
-index 94718c9319..7977ac14f4 100644
+index 8b55eccc89..f4650be8e5 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
-@@ -626,8 +626,8 @@ static void test_propagate_mirror(void)
+@@ -753,8 +753,8 @@ static void test_propagate_mirror(void)
/* Start a mirror job */
mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0,
diff --git a/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch b/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
index d30b46d..8c01d80 100644
--- a/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
+++ b/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
@@ -24,7 +24,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index d95a7d7940..2c79ee41af 100644
+index f2eca983f1..b6475d50ad 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -673,8 +673,6 @@ static int mirror_exit_common(Job *job)
diff --git a/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch b/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
index ffd3efe..2fac2ca 100644
--- a/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
+++ b/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 3 insertions(+)
diff --git a/blockdev.c b/blockdev.c
-index fa601838a3..93fd0a61a4 100644
+index 9a1a3118ed..a57b0af2e7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3050,6 +3050,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
diff --git a/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch b/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
index c86ceca..4d5f62a 100644
--- a/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
+++ b/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index 2c79ee41af..e04a3ea6f4 100644
+index b6475d50ad..8b3342f9ec 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -779,8 +779,8 @@ static int mirror_exit_common(Job *job)
diff --git a/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch b/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
index 4d4747b..336efbe 100644
--- a/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
+++ b/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 70 insertions(+), 59 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index e04a3ea6f4..4feec2a002 100644
+index 8b3342f9ec..1d4ff0efad 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1634,31 +1634,13 @@ static BlockJob *mirror_start_job(
@@ -60,7 +60,7 @@ index e04a3ea6f4..4feec2a002 100644
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
diff --git a/blockdev.c b/blockdev.c
-index 93fd0a61a4..1af5a1fcb2 100644
+index a57b0af2e7..ce62a9b439 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3029,7 +3029,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
diff --git a/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch b/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
index 9d8322c..cd72a8e 100644
--- a/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
+++ b/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
@@ -48,7 +48,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
-index cc4cc6c6ad..82f649d9ab 100644
+index a4b40e8391..d64ae8f34e 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
@@ -78,7 +78,7 @@ index caa2e90ef2..e1596f79ab 100644
/**
diff --git a/monitor/monitor.c b/monitor/monitor.c
-index 21c7a68758..ad9813567a 100644
+index 86949024f6..c306cadcf4 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -135,6 +135,21 @@ bool monitor_cur_is_qmp(void)
@@ -189,10 +189,10 @@ index 0990873ec8..e605003771 100644
aio_bh_schedule_oneshot(qemu_get_aio_context(), do_qmp_dispatch_bh,
&data);
diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
-index d058a2a00d..3290b58120 100644
+index afa477aae6..d3ff124bf3 100644
--- a/stubs/monitor-core.c
+++ b/stubs/monitor-core.c
-@@ -13,6 +13,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
+@@ -12,6 +12,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
return NULL;
}
diff --git a/debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch b/debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch
deleted file mode 100644
index c0b8ee0..0000000
--- a/debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Fabian Ebner <f.ebner@proxmox.com>
-Date: Fri, 20 May 2022 09:59:22 +0200
-Subject: [PATCH] block/gluster: correctly set max_pdiscard
-
-On 64-bit platforms, assigning SIZE_MAX to the int64_t max_pdiscard
-results in a negative value, and the following assertion would trigger
-down the line (it's not the same max_pdiscard, but computed from the
-other one):
-qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
-`max_pdiscard >= bs->bl.request_alignment' failed.
-
-On 32-bit platforms, it's fine to keep using SIZE_MAX.
-
-The assertion in qemu_gluster_co_pdiscard() is checking that the value
-of 'bytes' can safely be passed to glfs_discard_async(), which takes a
-size_t for the argument in question, so it is kept as is. And since
-max_pdiscard is still <= SIZE_MAX, relying on max_pdiscard is still
-fine.
-
-Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
-Message-Id: <20220520075922.43972-1-f.ebner@proxmox.com>
-Reviewed-by: Eric Blake <eblake@redhat.com>
-Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
-Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 9b38fc56c054c7de65fa3bf7cdd82b32654f6b7d)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/gluster.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/block/gluster.c b/block/gluster.c
-index 80b75cb96c..1079b6186b 100644
---- a/block/gluster.c
-+++ b/block/gluster.c
-@@ -901,7 +901,7 @@ out:
- static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp)
- {
- bs->bl.max_transfer = GLUSTER_MAX_TRANSFER;
-- bs->bl.max_pdiscard = SIZE_MAX;
-+ bs->bl.max_pdiscard = MIN(SIZE_MAX, INT64_MAX);
- }
-
- static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
diff --git a/debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch b/debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch
deleted file mode 100644
index 65c43de..0000000
--- a/debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch
+++ /dev/null
@@ -1,129 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Hanna Reitz <hreitz@redhat.com>
-Date: Mon, 14 Mar 2022 17:27:18 +0100
-Subject: [PATCH] block/vmdk: Fix reopening bs->file
-
-VMDK disk data is stored in extents, which may or may not be separate
-from bs->file. VmdkExtent.file points to where they are stored. Each
-that is stored in bs->file will simply reuse the exact pointer value of
-bs->file.
-
-(That is why vmdk_free_extents() will unref VmdkExtent.file (e->file)
-only if e->file != bs->file.)
-
-Reopen operations can change bs->file (they will replace the whole
-BdrvChild object, not just the BDS stored in that BdrvChild), and then
-we will need to change all .file pointers of all such VmdkExtents to
-point to the new BdrvChild.
-
-In vmdk_reopen_prepare(), we have to check which VmdkExtents are
-affected, and in vmdk_reopen_commit(), we can modify them. We have to
-split this because:
-- The new BdrvChild is created only after prepare, so we can change
- VmdkExtent.file only in commit
-- In commit, there no longer is any (valid) reference to the old
- BdrvChild object, so there would be nothing to compare VmdkExtent.file
- against to see whether it was equal to bs->file before reopening
- (There is BDRVReopenState.old_file_bs, but the old bs->file
- BdrvChild's .bs pointer will be NULL-ed when the new BdrvChild is
- created, and so we cannot compare VmdkExtent.file->bs against
- BDRVReopenState.old_file_bs)
-
-Signed-off-by: Hanna Reitz <hreitz@redhat.com>
-Message-Id: <20220314162719.65384-2-hreitz@redhat.com>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 6d17e2879854d7d0e623c06a9286085e97bf3545)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/vmdk.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++-
- 1 file changed, 55 insertions(+), 1 deletion(-)
-
-diff --git a/block/vmdk.c b/block/vmdk.c
-index 37c0946066..38e5ab3806 100644
---- a/block/vmdk.c
-+++ b/block/vmdk.c
-@@ -178,6 +178,10 @@ typedef struct BDRVVmdkState {
- char *create_type;
- } BDRVVmdkState;
-
-+typedef struct BDRVVmdkReopenState {
-+ bool *extents_using_bs_file;
-+} BDRVVmdkReopenState;
-+
- typedef struct VmdkMetaData {
- unsigned int l1_index;
- unsigned int l2_index;
-@@ -400,15 +404,63 @@ static int vmdk_is_cid_valid(BlockDriverState *bs)
- return 1;
- }
-
--/* We have nothing to do for VMDK reopen, stubs just return success */
- static int vmdk_reopen_prepare(BDRVReopenState *state,
- BlockReopenQueue *queue, Error **errp)
- {
-+ BDRVVmdkState *s;
-+ BDRVVmdkReopenState *rs;
-+ int i;
-+
- assert(state != NULL);
- assert(state->bs != NULL);
-+ assert(state->opaque == NULL);
-+
-+ s = state->bs->opaque;
-+
-+ rs = g_new0(BDRVVmdkReopenState, 1);
-+ state->opaque = rs;
-+
-+ /*
-+ * Check whether there are any extents stored in bs->file; if bs->file
-+ * changes, we will need to update their .file pointers to follow suit
-+ */
-+ rs->extents_using_bs_file = g_new(bool, s->num_extents);
-+ for (i = 0; i < s->num_extents; i++) {
-+ rs->extents_using_bs_file[i] = s->extents[i].file == state->bs->file;
-+ }
-+
- return 0;
- }
-
-+static void vmdk_reopen_clean(BDRVReopenState *state)
-+{
-+ BDRVVmdkReopenState *rs = state->opaque;
-+
-+ g_free(rs->extents_using_bs_file);
-+ g_free(rs);
-+ state->opaque = NULL;
-+}
-+
-+static void vmdk_reopen_commit(BDRVReopenState *state)
-+{
-+ BDRVVmdkState *s = state->bs->opaque;
-+ BDRVVmdkReopenState *rs = state->opaque;
-+ int i;
-+
-+ for (i = 0; i < s->num_extents; i++) {
-+ if (rs->extents_using_bs_file[i]) {
-+ s->extents[i].file = state->bs->file;
-+ }
-+ }
-+
-+ vmdk_reopen_clean(state);
-+}
-+
-+static void vmdk_reopen_abort(BDRVReopenState *state)
-+{
-+ vmdk_reopen_clean(state);
-+}
-+
- static int vmdk_parent_open(BlockDriverState *bs)
- {
- char *p_name;
-@@ -3072,6 +3124,8 @@ static BlockDriver bdrv_vmdk = {
- .bdrv_open = vmdk_open,
- .bdrv_co_check = vmdk_co_check,
- .bdrv_reopen_prepare = vmdk_reopen_prepare,
-+ .bdrv_reopen_commit = vmdk_reopen_commit,
-+ .bdrv_reopen_abort = vmdk_reopen_abort,
- .bdrv_child_perm = bdrv_default_perms,
- .bdrv_co_preadv = vmdk_co_preadv,
- .bdrv_co_pwritev = vmdk_co_pwritev,
diff --git a/debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch b/debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
deleted file mode 100644
index cf130ac..0000000
--- a/debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Thu, 9 Jun 2022 17:47:11 +0100
-Subject: [PATCH] linux-aio: fix unbalanced plugged counter in laio_io_unplug()
-
-Every laio_io_plug() call has a matching laio_io_unplug() call. There is
-a plugged counter that tracks the number of levels of plugging and
-allows for nesting.
-
-The plugged counter must reflect the balance between laio_io_plug() and
-laio_io_unplug() calls accurately. Otherwise I/O stalls occur since
-io_submit(2) calls are skipped while plugged.
-
-Reported-by: Nikolay Tenev <nt@storpool.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
-Message-id: 20220609164712.1539045-2-stefanha@redhat.com
-Cc: Stefano Garzarella <sgarzare@redhat.com>
-Fixes: 68d7946648 ("linux-aio: add `dev_max_batch` parameter to laio_io_unplug()")
-[Stefano Garzarella suggested adding a Fixes tag.
---Stefan]
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit f387cac5af030a58ac5a0dacf64cab5e5a4fe5c7)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/linux-aio.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/block/linux-aio.c b/block/linux-aio.c
-index 4c423fcccf..6078da7e42 100644
---- a/block/linux-aio.c
-+++ b/block/linux-aio.c
-@@ -363,8 +363,10 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
- uint64_t dev_max_batch)
- {
- assert(s->io_q.plugged);
-+ s->io_q.plugged--;
-+
- if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
-- (--s->io_q.plugged == 0 &&
-+ (!s->io_q.plugged &&
- !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
- ioq_submit(s);
- }
diff --git a/debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch b/debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
deleted file mode 100644
index 3f2dfa9..0000000
--- a/debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Claudio Fontana <cfontana@suse.de>
-Date: Tue, 31 May 2022 13:47:07 +0200
-Subject: [PATCH] pci: fix overflow in snprintf string formatting
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-the code in pcibus_get_fw_dev_path contained the potential for a
-stack buffer overflow of 1 byte, potentially writing to the stack an
-extra NUL byte.
-
-This overflow could happen if the PCI slot is >= 0x10000000,
-and the PCI function is >= 0x10000000, due to the size parameter
-of snprintf being incorrectly calculated in the call:
-
- if (PCI_FUNC(d->devfn))
- snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
-
-since the off obtained from a previous call to snprintf is added
-instead of subtracted from the total available size of the buffer.
-
-Without the accurate size guard from snprintf, we end up writing in the
-worst case:
-
-name (32) + "@" (1) + SLOT (8) + "," (1) + FUNC (8) + term NUL (1) = 51 bytes
-
-In order to provide something more robust, replace all of the code in
-pcibus_get_fw_dev_path with a single call to g_strdup_printf,
-so there is no need to rely on manual calculations.
-
-Found by compiling QEMU with FORTIFY_SOURCE=3 as the error:
-
-*** buffer overflow detected ***: terminated
-
-Thread 1 "qemu-system-x86" received signal SIGABRT, Aborted.
-[Switching to Thread 0x7ffff642c380 (LWP 121307)]
-0x00007ffff71ff55c in __pthread_kill_implementation () from /lib64/libc.so.6
-(gdb) bt
- #0 0x00007ffff71ff55c in __pthread_kill_implementation () at /lib64/libc.so.6
- #1 0x00007ffff71ac6f6 in raise () at /lib64/libc.so.6
- #2 0x00007ffff7195814 in abort () at /lib64/libc.so.6
- #3 0x00007ffff71f279e in __libc_message () at /lib64/libc.so.6
- #4 0x00007ffff729767a in __fortify_fail () at /lib64/libc.so.6
- #5 0x00007ffff7295c36 in () at /lib64/libc.so.6
- #6 0x00007ffff72957f5 in __snprintf_chk () at /lib64/libc.so.6
- #7 0x0000555555b1c1fd in pcibus_get_fw_dev_path ()
- #8 0x0000555555f2bde4 in qdev_get_fw_dev_path_helper.constprop ()
- #9 0x0000555555f2bd86 in qdev_get_fw_dev_path_helper.constprop ()
- #10 0x00005555559a6e5d in get_boot_device_path ()
- #11 0x00005555559a712c in get_boot_devices_list ()
- #12 0x0000555555b1a3d0 in fw_cfg_machine_reset ()
- #13 0x0000555555bf4c2d in pc_machine_reset ()
- #14 0x0000555555c66988 in qemu_system_reset ()
- #15 0x0000555555a6dff6 in qdev_machine_creation_done ()
- #16 0x0000555555c79186 in qmp_x_exit_preconfig.part ()
- #17 0x0000555555c7b459 in qemu_init ()
- #18 0x0000555555960a29 in main ()
-
-Found-by: Dario Faggioli <Dario Faggioli <dfaggioli@suse.com>
-Found-by: Martin Liška <martin.liska@suse.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Claudio Fontana <cfontana@suse.de>
-Message-Id: <20220531114707.18830-1-cfontana@suse.de>
-Reviewed-by: Ani Sinha <ani@anisinha.ca>
-(cherry-picked from commit 36f18c6989a3d1ff1d7a0e50b0868ef3958299b4)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/pci/pci.c | 18 +++++++++---------
- 1 file changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/hw/pci/pci.c b/hw/pci/pci.c
-index dae9119bfe..c69b412434 100644
---- a/hw/pci/pci.c
-+++ b/hw/pci/pci.c
-@@ -2625,15 +2625,15 @@ static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
- static char *pcibus_get_fw_dev_path(DeviceState *dev)
- {
- PCIDevice *d = (PCIDevice *)dev;
-- char path[50], name[33];
-- int off;
--
-- off = snprintf(path, sizeof(path), "%s@%x",
-- pci_dev_fw_name(dev, name, sizeof name),
-- PCI_SLOT(d->devfn));
-- if (PCI_FUNC(d->devfn))
-- snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
-- return g_strdup(path);
-+ char name[33];
-+ int has_func = !!PCI_FUNC(d->devfn);
-+
-+ return g_strdup_printf("%s@%x%s%.*x",
-+ pci_dev_fw_name(dev, name, sizeof(name)),
-+ PCI_SLOT(d->devfn),
-+ has_func ? "," : "",
-+ has_func,
-+ PCI_FUNC(d->devfn));
- }
-
- static char *pcibus_get_dev_path(DeviceState *dev)
diff --git a/debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch b/debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
deleted file mode 100644
index d393ed1..0000000
--- a/debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
-Date: Mon, 23 May 2022 18:26:58 +0200
-Subject: [PATCH] target/i386/kvm: Fix disabling MPX on "-cpu host" with
- MPX-capable host
-
-Since KVM commit 5f76f6f5ff96 ("KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled")
-it is not possible to disable MPX on a "-cpu host" just by adding "-mpx"
-there if the host CPU does indeed support MPX.
-QEMU will fail to set MSR_IA32_VMX_TRUE_{EXIT,ENTRY}_CTLS MSRs in this case
-and so trigger an assertion failure.
-
-Instead, besides "-mpx" one has to explicitly add also
-"-vmx-exit-clear-bndcfgs" and "-vmx-entry-load-bndcfgs" to QEMU command
-line to make it work, which is a bit convoluted.
-
-Make the MPX-related bits in FEAT_VMX_{EXIT,ENTRY}_CTLS dependent on MPX
-being actually enabled so such workarounds are no longer necessary.
-
-Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
-Message-Id: <51aa2125c76363204cc23c27165e778097c33f0b.1653323077.git.maciej.szmigiero@oracle.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry-picked from commit 267b5e7e378afd260004cb37a66a6fcd641e3b53)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- target/i386/cpu.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/target/i386/cpu.c b/target/i386/cpu.c
-index cb6b5467d0..6e6945139b 100644
---- a/target/i386/cpu.c
-+++ b/target/i386/cpu.c
-@@ -1327,6 +1327,14 @@ static FeatureDep feature_dependencies[] = {
- .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_INVPCID },
- .to = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_ENABLE_INVPCID },
- },
-+ {
-+ .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_MPX },
-+ .to = { FEAT_VMX_EXIT_CTLS, VMX_VM_EXIT_CLEAR_BNDCFGS },
-+ },
-+ {
-+ .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_MPX },
-+ .to = { FEAT_VMX_ENTRY_CTLS, VMX_VM_ENTRY_LOAD_BNDCFGS },
-+ },
- {
- .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_RDSEED },
- .to = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_RDSEED_EXITING },
diff --git a/debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch b/debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
deleted file mode 100644
index 6c4d523..0000000
--- a/debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
+++ /dev/null
@@ -1,121 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Mon, 7 Mar 2022 15:38:51 +0000
-Subject: [PATCH] coroutine-ucontext: use QEMU_DEFINE_STATIC_CO_TLS()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Thread-Local Storage variables cannot be used directly from coroutine
-code because the compiler may optimize TLS variable accesses across
-qemu_coroutine_yield() calls. When the coroutine is re-entered from
-another thread the TLS variables from the old thread must no longer be
-used.
-
-Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
-
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Message-Id: <20220307153853.602859-2-stefanha@redhat.com>
-Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 34145a307d849d0b6734d0222a7aa0bb9eef7407)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- util/coroutine-ucontext.c | 38 ++++++++++++++++++++++++--------------
- 1 file changed, 24 insertions(+), 14 deletions(-)
-
-diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c
-index 904b375192..127d5a13c8 100644
---- a/util/coroutine-ucontext.c
-+++ b/util/coroutine-ucontext.c
-@@ -25,6 +25,7 @@
- #include "qemu/osdep.h"
- #include <ucontext.h>
- #include "qemu/coroutine_int.h"
-+#include "qemu/coroutine-tls.h"
-
- #ifdef CONFIG_VALGRIND_H
- #include <valgrind/valgrind.h>
-@@ -66,8 +67,8 @@ typedef struct {
- /**
- * Per-thread coroutine bookkeeping
- */
--static __thread CoroutineUContext leader;
--static __thread Coroutine *current;
-+QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
-+QEMU_DEFINE_STATIC_CO_TLS(CoroutineUContext, leader);
-
- /*
- * va_args to makecontext() must be type 'int', so passing
-@@ -97,14 +98,15 @@ static inline __attribute__((always_inline))
- void finish_switch_fiber(void *fake_stack_save)
- {
- #ifdef CONFIG_ASAN
-+ CoroutineUContext *leaderp = get_ptr_leader();
- const void *bottom_old;
- size_t size_old;
-
- __sanitizer_finish_switch_fiber(fake_stack_save, &bottom_old, &size_old);
-
-- if (!leader.stack) {
-- leader.stack = (void *)bottom_old;
-- leader.stack_size = size_old;
-+ if (!leaderp->stack) {
-+ leaderp->stack = (void *)bottom_old;
-+ leaderp->stack_size = size_old;
- }
- #endif
- #ifdef CONFIG_TSAN
-@@ -161,8 +163,10 @@ static void coroutine_trampoline(int i0, int i1)
-
- /* Initialize longjmp environment and switch back the caller */
- if (!sigsetjmp(self->env, 0)) {
-- start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save, leader.stack,
-- leader.stack_size);
-+ CoroutineUContext *leaderp = get_ptr_leader();
-+
-+ start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save,
-+ leaderp->stack, leaderp->stack_size);
- start_switch_fiber_tsan(&fake_stack_save, self, true); /* true=caller */
- siglongjmp(*(sigjmp_buf *)co->entry_arg, 1);
- }
-@@ -297,7 +301,7 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
- int ret;
- void *fake_stack_save = NULL;
-
-- current = to_;
-+ set_current(to_);
-
- ret = sigsetjmp(from->env, 0);
- if (ret == 0) {
-@@ -315,18 +319,24 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
-
- Coroutine *qemu_coroutine_self(void)
- {
-- if (!current) {
-- current = &leader.base;
-+ Coroutine *self = get_current();
-+ CoroutineUContext *leaderp = get_ptr_leader();
-+
-+ if (!self) {
-+ self = &leaderp->base;
-+ set_current(self);
- }
- #ifdef CONFIG_TSAN
-- if (!leader.tsan_co_fiber) {
-- leader.tsan_co_fiber = __tsan_get_current_fiber();
-+ if (!leaderp->tsan_co_fiber) {
-+ leaderp->tsan_co_fiber = __tsan_get_current_fiber();
- }
- #endif
-- return current;
-+ return self;
- }
-
- bool qemu_in_coroutine(void)
- {
-- return current && current->caller;
-+ Coroutine *self = get_current();
-+
-+ return self && self->caller;
- }
diff --git a/debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch b/debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
deleted file mode 100644
index b5c4d3b..0000000
--- a/debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
+++ /dev/null
@@ -1,123 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Mon, 7 Mar 2022 15:38:52 +0000
-Subject: [PATCH] coroutine: use QEMU_DEFINE_STATIC_CO_TLS()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Thread-Local Storage variables cannot be used directly from coroutine
-code because the compiler may optimize TLS variable accesses across
-qemu_coroutine_yield() calls. When the coroutine is re-entered from
-another thread the TLS variables from the old thread must no longer be
-used.
-
-Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
-The alloc_pool QSLIST needs a typedef so the return value of
-get_ptr_alloc_pool() can be stored in a local variable.
-
-One example of why this code is necessary: a coroutine that yields
-before calling qemu_coroutine_create() to create another coroutine is
-affected by the TLS issue.
-
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Message-Id: <20220307153853.602859-3-stefanha@redhat.com>
-Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit ac387a08a9c9f6b36757da912f0339c25f421f90)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- util/qemu-coroutine.c | 41 ++++++++++++++++++++++++-----------------
- 1 file changed, 24 insertions(+), 17 deletions(-)
-
-diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
-index c03b2422ff..f3e8300c8d 100644
---- a/util/qemu-coroutine.c
-+++ b/util/qemu-coroutine.c
-@@ -18,6 +18,7 @@
- #include "qemu/atomic.h"
- #include "qemu/coroutine.h"
- #include "qemu/coroutine_int.h"
-+#include "qemu/coroutine-tls.h"
- #include "block/aio.h"
-
- /** Initial batch size is 64, and is increased on demand */
-@@ -29,17 +30,20 @@ enum {
- static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
- static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE;
- static unsigned int release_pool_size;
--static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
--static __thread unsigned int alloc_pool_size;
--static __thread Notifier coroutine_pool_cleanup_notifier;
-+
-+typedef QSLIST_HEAD(, Coroutine) CoroutineQSList;
-+QEMU_DEFINE_STATIC_CO_TLS(CoroutineQSList, alloc_pool);
-+QEMU_DEFINE_STATIC_CO_TLS(unsigned int, alloc_pool_size);
-+QEMU_DEFINE_STATIC_CO_TLS(Notifier, coroutine_pool_cleanup_notifier);
-
- static void coroutine_pool_cleanup(Notifier *n, void *value)
- {
- Coroutine *co;
- Coroutine *tmp;
-+ CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
-
-- QSLIST_FOREACH_SAFE(co, &alloc_pool, pool_next, tmp) {
-- QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
-+ QSLIST_FOREACH_SAFE(co, alloc_pool, pool_next, tmp) {
-+ QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
- qemu_coroutine_delete(co);
- }
- }
-@@ -49,27 +53,30 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
- Coroutine *co = NULL;
-
- if (CONFIG_COROUTINE_POOL) {
-- co = QSLIST_FIRST(&alloc_pool);
-+ CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
-+
-+ co = QSLIST_FIRST(alloc_pool);
- if (!co) {
- if (release_pool_size > qatomic_read(&pool_batch_size)) {
- /* Slow path; a good place to register the destructor, too. */
-- if (!coroutine_pool_cleanup_notifier.notify) {
-- coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
-- qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
-+ Notifier *notifier = get_ptr_coroutine_pool_cleanup_notifier();
-+ if (!notifier->notify) {
-+ notifier->notify = coroutine_pool_cleanup;
-+ qemu_thread_atexit_add(notifier);
- }
-
- /* This is not exact; there could be a little skew between
- * release_pool_size and the actual size of release_pool. But
- * it is just a heuristic, it does not need to be perfect.
- */
-- alloc_pool_size = qatomic_xchg(&release_pool_size, 0);
-- QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool);
-- co = QSLIST_FIRST(&alloc_pool);
-+ set_alloc_pool_size(qatomic_xchg(&release_pool_size, 0));
-+ QSLIST_MOVE_ATOMIC(alloc_pool, &release_pool);
-+ co = QSLIST_FIRST(alloc_pool);
- }
- }
- if (co) {
-- QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
-- alloc_pool_size--;
-+ QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
-+ set_alloc_pool_size(get_alloc_pool_size() - 1);
- }
- }
-
-@@ -93,9 +100,9 @@ static void coroutine_delete(Coroutine *co)
- qatomic_inc(&release_pool_size);
- return;
- }
-- if (alloc_pool_size < qatomic_read(&pool_batch_size)) {
-- QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
-- alloc_pool_size++;
-+ if (get_alloc_pool_size() < qatomic_read(&pool_batch_size)) {
-+ QSLIST_INSERT_HEAD(get_ptr_alloc_pool(), co, pool_next);
-+ set_alloc_pool_size(get_alloc_pool_size() + 1);
- return;
- }
- }
diff --git a/debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch b/debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
deleted file mode 100644
index 9459471..0000000
--- a/debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Kevin Wolf <kwolf@redhat.com>
-Date: Tue, 10 May 2022 17:10:19 +0200
-Subject: [PATCH] coroutine: Rename qemu_coroutine_inc/dec_pool_size()
-
-It's true that these functions currently affect the batch size in which
-coroutines are reused (i.e. moved from the global release pool to the
-allocation pool of a specific thread), but this is a bug and will be
-fixed in a separate patch.
-
-In fact, the comment in the header file already just promises that it
-influences the pool size, so reflect this in the name of the functions.
-As a nice side effect, the shorter function name makes some line
-wrapping unnecessary.
-
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-Message-Id: <20220510151020.105528-2-kwolf@redhat.com>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 98e3ab35054b946f7c2aba5408822532b0920b53)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/block/virtio-blk.c | 6 ++----
- include/qemu/coroutine.h | 6 +++---
- util/qemu-coroutine.c | 4 ++--
- 3 files changed, 7 insertions(+), 9 deletions(-)
-
-diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
-index 540c38f829..6a1cc41877 100644
---- a/hw/block/virtio-blk.c
-+++ b/hw/block/virtio-blk.c
-@@ -1215,8 +1215,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
- for (i = 0; i < conf->num_queues; i++) {
- virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
- }
-- qemu_coroutine_increase_pool_batch_size(conf->num_queues * conf->queue_size
-- / 2);
-+ qemu_coroutine_inc_pool_size(conf->num_queues * conf->queue_size / 2);
- virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
- if (err != NULL) {
- error_propagate(errp, err);
-@@ -1253,8 +1252,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev)
- for (i = 0; i < conf->num_queues; i++) {
- virtio_del_queue(vdev, i);
- }
-- qemu_coroutine_decrease_pool_batch_size(conf->num_queues * conf->queue_size
-- / 2);
-+ qemu_coroutine_dec_pool_size(conf->num_queues * conf->queue_size / 2);
- qemu_del_vm_change_state_handler(s->change);
- blockdev_mark_auto_del(s->blk);
- virtio_cleanup(vdev);
-diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
-index c828a95ee0..5b621d1295 100644
---- a/include/qemu/coroutine.h
-+++ b/include/qemu/coroutine.h
-@@ -334,12 +334,12 @@ void coroutine_fn yield_until_fd_readable(int fd);
- /**
- * Increase coroutine pool size
- */
--void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size);
-+void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size);
-
- /**
-- * Devcrease coroutine pool size
-+ * Decrease coroutine pool size
- */
--void qemu_coroutine_decrease_pool_batch_size(unsigned int additional_pool_size);
-+void qemu_coroutine_dec_pool_size(unsigned int additional_pool_size);
-
- #include "qemu/lockable.h"
-
-diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
-index f3e8300c8d..ea23929a74 100644
---- a/util/qemu-coroutine.c
-+++ b/util/qemu-coroutine.c
-@@ -212,12 +212,12 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
- return co->ctx;
- }
-
--void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size)
-+void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size)
- {
- qatomic_add(&pool_batch_size, additional_pool_size);
- }
-
--void qemu_coroutine_decrease_pool_batch_size(unsigned int removing_pool_size)
-+void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size)
- {
- qatomic_sub(&pool_batch_size, removing_pool_size);
- }
diff --git a/debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch b/debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch
deleted file mode 100644
index 711ffe0..0000000
--- a/debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch
+++ /dev/null
@@ -1,121 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Kevin Wolf <kwolf@redhat.com>
-Date: Tue, 10 May 2022 17:10:20 +0200
-Subject: [PATCH] coroutine: Revert to constant batch size
-
-Commit 4c41c69e changed the way the coroutine pool is sized because for
-virtio-blk devices with a large queue size and heavy I/O, it was just
-too small and caused coroutines to be deleted and reallocated soon
-afterwards. The change made the size dynamic based on the number of
-queues and the queue size of virtio-blk devices.
-
-There are two important numbers here: Slightly simplified, when a
-coroutine terminates, it is generally stored in the global release pool
-up to a certain pool size, and if the pool is full, it is freed.
-Conversely, when allocating a new coroutine, the coroutines in the
-release pool are reused if the pool already has reached a certain
-minimum size (the batch size), otherwise we allocate new coroutines.
-
-The problem after commit 4c41c69e is that it not only increases the
-maximum pool size (which is the intended effect), but also the batch
-size for reusing coroutines (which is a bug). It means that in cases
-with many devices and/or a large queue size (which defaults to the
-number of vcpus for virtio-blk-pci), many thousand coroutines could be
-sitting in the release pool without being reused.
-
-This is not only a waste of memory and allocations, but it actually
-makes the QEMU process likely to hit the vm.max_map_count limit on Linux
-because each coroutine requires two mappings (its stack and the guard
-page for the stack), causing it to abort() in qemu_alloc_stack() because
-when the limit is hit, mprotect() starts to fail with ENOMEM.
-
-In order to fix the problem, change the batch size back to 64 to avoid
-uselessly accumulating coroutines in the release pool, but keep the
-dynamic maximum pool size so that coroutines aren't freed too early
-in heavy I/O scenarios.
-
-Note that this fix doesn't strictly make it impossible to hit the limit,
-but this would only happen if most of the coroutines are actually in use
-at the same time, not just sitting in a pool. This is the same behaviour
-as we already had before commit 4c41c69e. Fully preventing this would
-require allowing qemu_coroutine_create() to return an error, but it
-doesn't seem to be a scenario that people hit in practice.
-
-Cc: qemu-stable@nongnu.org
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2079938
-Fixes: 4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-Message-Id: <20220510151020.105528-3-kwolf@redhat.com>
-Tested-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 9ec7a59b5aad4b736871c378d30f5ef5ec51cb52)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- util/qemu-coroutine.c | 22 ++++++++++++++--------
- 1 file changed, 14 insertions(+), 8 deletions(-)
-
-diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
-index ea23929a74..4a8bd63ef0 100644
---- a/util/qemu-coroutine.c
-+++ b/util/qemu-coroutine.c
-@@ -21,14 +21,20 @@
- #include "qemu/coroutine-tls.h"
- #include "block/aio.h"
-
--/** Initial batch size is 64, and is increased on demand */
-+/**
-+ * The minimal batch size is always 64, coroutines from the release_pool are
-+ * reused as soon as there are 64 coroutines in it. The maximum pool size starts
-+ * with 64 and is increased on demand so that coroutines are not deleted even if
-+ * they are not immediately reused.
-+ */
- enum {
-- POOL_INITIAL_BATCH_SIZE = 64,
-+ POOL_MIN_BATCH_SIZE = 64,
-+ POOL_INITIAL_MAX_SIZE = 64,
- };
-
- /** Free list to speed up creation */
- static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
--static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE;
-+static unsigned int pool_max_size = POOL_INITIAL_MAX_SIZE;
- static unsigned int release_pool_size;
-
- typedef QSLIST_HEAD(, Coroutine) CoroutineQSList;
-@@ -57,7 +63,7 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
-
- co = QSLIST_FIRST(alloc_pool);
- if (!co) {
-- if (release_pool_size > qatomic_read(&pool_batch_size)) {
-+ if (release_pool_size > POOL_MIN_BATCH_SIZE) {
- /* Slow path; a good place to register the destructor, too. */
- Notifier *notifier = get_ptr_coroutine_pool_cleanup_notifier();
- if (!notifier->notify) {
-@@ -95,12 +101,12 @@ static void coroutine_delete(Coroutine *co)
- co->caller = NULL;
-
- if (CONFIG_COROUTINE_POOL) {
-- if (release_pool_size < qatomic_read(&pool_batch_size) * 2) {
-+ if (release_pool_size < qatomic_read(&pool_max_size) * 2) {
- QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next);
- qatomic_inc(&release_pool_size);
- return;
- }
-- if (get_alloc_pool_size() < qatomic_read(&pool_batch_size)) {
-+ if (get_alloc_pool_size() < qatomic_read(&pool_max_size)) {
- QSLIST_INSERT_HEAD(get_ptr_alloc_pool(), co, pool_next);
- set_alloc_pool_size(get_alloc_pool_size() + 1);
- return;
-@@ -214,10 +220,10 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
-
- void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size)
- {
-- qatomic_add(&pool_batch_size, additional_pool_size);
-+ qatomic_add(&pool_max_size, additional_pool_size);
- }
-
- void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size)
- {
-- qatomic_sub(&pool_batch_size, removing_pool_size);
-+ qatomic_sub(&pool_max_size, removing_pool_size);
- }
diff --git a/debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch b/debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
deleted file mode 100644
index cf535bb..0000000
--- a/debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
+++ /dev/null
@@ -1,117 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Fri, 29 Apr 2022 21:16:28 +0200
-Subject: [PATCH] target/i386: do not consult nonexistent host leaves
-
-When cache_info_passthrough is requested, QEMU passes the host values
-of the cache information CPUID leaves down to the guest. However,
-it blindly assumes that the CPUID leaf exists on the host, and this
-cannot be guaranteed: for example, KVM has recently started to
-synthesize AMD leaves up to 0x80000021 in order to provide accurate
-CPU bug information to guests.
-
-Querying a nonexistent host leaf fills the output arguments of
-host_cpuid with data that (albeit deterministic) is nonsensical
-as cache information, namely the data in the highest Intel CPUID
-leaf. If said highest leaf is not ECX-dependent, this can even
-cause an infinite loop when kvm_arch_init_vcpu prepares the input
-to KVM_SET_CPUID2. The infinite loop is only terminated by an
-abort() when the array gets full.
-
-Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
-Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry-picked from commit 798d8ec0dacd4cc0034298d94f430c14f23e2919)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- target/i386/cpu.c | 41 ++++++++++++++++++++++++++++++++++++-----
- 1 file changed, 36 insertions(+), 5 deletions(-)
-
-diff --git a/target/i386/cpu.c b/target/i386/cpu.c
-index 6e6945139b..c79e151887 100644
---- a/target/i386/cpu.c
-+++ b/target/i386/cpu.c
-@@ -5030,6 +5030,37 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
- return r;
- }
-
-+static void x86_cpu_get_cache_cpuid(uint32_t func, uint32_t index,
-+ uint32_t *eax, uint32_t *ebx,
-+ uint32_t *ecx, uint32_t *edx)
-+{
-+ uint32_t level, unused;
-+
-+ /* Only return valid host leaves. */
-+ switch (func) {
-+ case 2:
-+ case 4:
-+ host_cpuid(0, 0, &level, &unused, &unused, &unused);
-+ break;
-+ case 0x80000005:
-+ case 0x80000006:
-+ case 0x8000001d:
-+ host_cpuid(0x80000000, 0, &level, &unused, &unused, &unused);
-+ break;
-+ default:
-+ return;
-+ }
-+
-+ if (func > level) {
-+ *eax = 0;
-+ *ebx = 0;
-+ *ecx = 0;
-+ *edx = 0;
-+ } else {
-+ host_cpuid(func, index, eax, ebx, ecx, edx);
-+ }
-+}
-+
- /*
- * Only for builtin_x86_defs models initialized with x86_register_cpudef_types.
- */
-@@ -5288,7 +5319,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 2:
- /* cache info: needed for Pentium Pro compatibility */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, 0, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, 0, eax, ebx, ecx, edx);
- break;
- } else if (cpu->vendor_cpuid_only && IS_AMD_CPU(env)) {
- *eax = *ebx = *ecx = *edx = 0;
-@@ -5308,7 +5339,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 4:
- /* cache info: needed for Core compatibility */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, count, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, count, eax, ebx, ecx, edx);
- /* QEMU gives out its own APIC IDs, never pass down bits 31..26. */
- *eax &= ~0xFC000000;
- if ((*eax & 31) && cs->nr_cores > 1) {
-@@ -5710,7 +5741,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 0x80000005:
- /* cache info (L1 cache) */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, 0, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, 0, eax, ebx, ecx, edx);
- break;
- }
- *eax = (L1_DTLB_2M_ASSOC << 24) | (L1_DTLB_2M_ENTRIES << 16) |
-@@ -5723,7 +5754,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 0x80000006:
- /* cache info (L2 cache) */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, 0, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, 0, eax, ebx, ecx, edx);
- break;
- }
- *eax = (AMD_ENC_ASSOC(L2_DTLB_2M_ASSOC) << 28) |
-@@ -5783,7 +5814,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 0x8000001D:
- *eax = 0;
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, count, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, count, eax, ebx, ecx, edx);
- break;
- }
- switch (count) {
diff --git a/debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch b/debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
deleted file mode 100644
index 92a57cf..0000000
--- a/debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Wed, 27 Apr 2022 15:35:36 +0100
-Subject: [PATCH] virtio-scsi: fix ctrl and event handler functions in
- dataplane mode
-
-Commit f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare
-virtio_scsi_handle_cmd for dataplane") prepared the virtio-scsi cmd
-virtqueue handler function to be used in both the dataplane and
-non-datpalane code paths.
-
-It failed to convert the ctrl and event virtqueue handler functions,
-which are not designed to be called from the dataplane code path but
-will be since the ioeventfd is set up for those virtqueues when
-dataplane starts.
-
-Convert the ctrl and event virtqueue handler functions now so they
-operate correctly when called from the dataplane code path. Avoid code
-duplication by extracting this code into a helper function.
-
-Fixes: f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane")
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
-Message-id: 20220427143541.119567-2-stefanha@redhat.com
-[Fixed s/by used/be used/ typo pointed out by Michael Tokarev
-<mjt@tls.msk.ru>.
---Stefan]
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit 2f743ef6366c2df4ef51ef3ae318138cdc0125ab)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/scsi/virtio-scsi.c | 42 +++++++++++++++++++++++++++---------------
- 1 file changed, 27 insertions(+), 15 deletions(-)
-
-diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
-index 34a968ecfb..417fbc71d6 100644
---- a/hw/scsi/virtio-scsi.c
-+++ b/hw/scsi/virtio-scsi.c
-@@ -472,16 +472,32 @@ bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
- return progress;
- }
-
-+/*
-+ * If dataplane is configured but not yet started, do so now and return true on
-+ * success.
-+ *
-+ * Dataplane is started by the core virtio code but virtqueue handler functions
-+ * can also be invoked when a guest kicks before DRIVER_OK, so this helper
-+ * function helps us deal with manually starting ioeventfd in that case.
-+ */
-+static bool virtio_scsi_defer_to_dataplane(VirtIOSCSI *s)
-+{
-+ if (!s->ctx || s->dataplane_started) {
-+ return false;
-+ }
-+
-+ virtio_device_start_ioeventfd(&s->parent_obj.parent_obj);
-+ return !s->dataplane_fenced;
-+}
-+
- static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
- {
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
-
-- if (s->ctx) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_ctrl_vq(s, vq);
- virtio_scsi_release(s);
-@@ -720,12 +736,10 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
- /* use non-QOM casts in the data path */
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
-
-- if (s->ctx && !s->dataplane_started) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_cmd_vq(s, vq);
- virtio_scsi_release(s);
-@@ -855,12 +869,10 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
- {
- VirtIOSCSI *s = VIRTIO_SCSI(vdev);
-
-- if (s->ctx) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_event_vq(s, vq);
- virtio_scsi_release(s);
diff --git a/debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch b/debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
deleted file mode 100644
index 238d456..0000000
--- a/debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Wed, 27 Apr 2022 15:35:37 +0100
-Subject: [PATCH] virtio-scsi: don't waste CPU polling the event virtqueue
-
-The virtio-scsi event virtqueue is not emptied by its handler function.
-This is typical for rx virtqueues where the device uses buffers when
-some event occurs (e.g. a packet is received, an error condition
-happens, etc).
-
-Polling non-empty virtqueues wastes CPU cycles. We are not waiting for
-new buffers to become available, we are waiting for an event to occur,
-so it's a misuse of CPU resources to poll for buffers.
-
-Introduce the new virtio_queue_aio_attach_host_notifier_no_poll() API,
-which is identical to virtio_queue_aio_attach_host_notifier() except
-that it does not poll the virtqueue.
-
-Before this patch the following command-line consumed 100% CPU in the
-IOThread polling and calling virtio_scsi_handle_event():
-
- $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
- --object iothread,id=iothread0 \
- --device virtio-scsi-pci,iothread=iothread0 \
- --blockdev file,filename=test.img,aio=native,cache.direct=on,node-name=drive0 \
- --device scsi-hd,drive=drive0
-
-After this patch CPU is no longer wasted.
-
-Reported-by: Nir Soffer <nsoffer@redhat.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Tested-by: Nir Soffer <nsoffer@redhat.com>
-Message-id: 20220427143541.119567-3-stefanha@redhat.com
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit 38738f7dbbda90fbc161757b7f4be35b52205552)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/scsi/virtio-scsi-dataplane.c | 2 +-
- hw/virtio/virtio.c | 13 +++++++++++++
- include/hw/virtio/virtio.h | 1 +
- 3 files changed, 15 insertions(+), 1 deletion(-)
-
-diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
-index 29575cbaf6..8bb6e6acfc 100644
---- a/hw/scsi/virtio-scsi-dataplane.c
-+++ b/hw/scsi/virtio-scsi-dataplane.c
-@@ -138,7 +138,7 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
-
- aio_context_acquire(s->ctx);
- virtio_queue_aio_attach_host_notifier(vs->ctrl_vq, s->ctx);
-- virtio_queue_aio_attach_host_notifier(vs->event_vq, s->ctx);
-+ virtio_queue_aio_attach_host_notifier_no_poll(vs->event_vq, s->ctx);
-
- for (i = 0; i < vs->conf.num_queues; i++) {
- virtio_queue_aio_attach_host_notifier(vs->cmd_vqs[i], s->ctx);
-diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
-index 9d637e043e..67a873f54a 100644
---- a/hw/virtio/virtio.c
-+++ b/hw/virtio/virtio.c
-@@ -3534,6 +3534,19 @@ void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx)
- virtio_queue_host_notifier_aio_poll_end);
- }
-
-+/*
-+ * Same as virtio_queue_aio_attach_host_notifier() but without polling. Use
-+ * this for rx virtqueues and similar cases where the virtqueue handler
-+ * function does not pop all elements. When the virtqueue is left non-empty
-+ * polling consumes CPU cycles and should not be used.
-+ */
-+void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx)
-+{
-+ aio_set_event_notifier(ctx, &vq->host_notifier, true,
-+ virtio_queue_host_notifier_read,
-+ NULL, NULL);
-+}
-+
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx)
- {
- aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL, NULL);
-diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
-index b31c4507f5..b62a35fdca 100644
---- a/include/hw/virtio/virtio.h
-+++ b/include/hw/virtio/virtio.h
-@@ -317,6 +317,7 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
- void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
- void virtio_queue_host_notifier_read(EventNotifier *n);
- void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx);
-+void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx);
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
- VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
- VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
diff --git a/debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch b/debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
deleted file mode 100644
index 2f52fd3..0000000
--- a/debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
+++ /dev/null
@@ -1,102 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:42 +0200
-Subject: [PATCH] vhost: Track descriptor chain in private at SVQ
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The device could have access to modify them, and it definitely have
-access when we implement packed vq. Harden SVQ maintaining a private
-copy of the descriptor chain. Other fields like buffer addresses are
-already maintained sepparatedly.
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-2-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 495fe3a78749c39c0e772c4e1a55d6cb8a7e5292)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-shadow-virtqueue.c | 12 +++++++-----
- hw/virtio/vhost-shadow-virtqueue.h | 6 ++++++
- 2 files changed, 13 insertions(+), 5 deletions(-)
-
-diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
-index b232803d1b..3155801f50 100644
---- a/hw/virtio/vhost-shadow-virtqueue.c
-+++ b/hw/virtio/vhost-shadow-virtqueue.c
-@@ -138,6 +138,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
- for (n = 0; n < num; n++) {
- if (more_descs || (n + 1 < num)) {
- descs[i].flags = flags | cpu_to_le16(VRING_DESC_F_NEXT);
-+ descs[i].next = cpu_to_le16(svq->desc_next[i]);
- } else {
- descs[i].flags = flags;
- }
-@@ -145,10 +146,10 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
- descs[i].len = cpu_to_le32(iovec[n].iov_len);
-
- last = i;
-- i = cpu_to_le16(descs[i].next);
-+ i = cpu_to_le16(svq->desc_next[i]);
- }
-
-- svq->free_head = le16_to_cpu(descs[last].next);
-+ svq->free_head = le16_to_cpu(svq->desc_next[last]);
- }
-
- static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
-@@ -336,7 +337,6 @@ static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
- static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- uint32_t *len)
- {
-- vring_desc_t *descs = svq->vring.desc;
- const vring_used_t *used = svq->vring.used;
- vring_used_elem_t used_elem;
- uint16_t last_used;
-@@ -365,7 +365,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- return NULL;
- }
-
-- descs[used_elem.id].next = svq->free_head;
-+ svq->desc_next[used_elem.id] = svq->free_head;
- svq->free_head = used_elem.id;
-
- *len = used_elem.len;
-@@ -540,8 +540,9 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
- svq->vring.used = qemu_memalign(qemu_real_host_page_size, device_size);
- memset(svq->vring.used, 0, device_size);
- svq->ring_id_maps = g_new0(VirtQueueElement *, svq->vring.num);
-+ svq->desc_next = g_new0(uint16_t, svq->vring.num);
- for (unsigned i = 0; i < svq->vring.num - 1; i++) {
-- svq->vring.desc[i].next = cpu_to_le16(i + 1);
-+ svq->desc_next[i] = cpu_to_le16(i + 1);
- }
- }
-
-@@ -574,6 +575,7 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
- virtqueue_detach_element(svq->vq, next_avail_elem, 0);
- }
- svq->vq = NULL;
-+ g_free(svq->desc_next);
- g_free(svq->ring_id_maps);
- qemu_vfree(svq->vring.desc);
- qemu_vfree(svq->vring.used);
-diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
-index e5e24c536d..c132c994e9 100644
---- a/hw/virtio/vhost-shadow-virtqueue.h
-+++ b/hw/virtio/vhost-shadow-virtqueue.h
-@@ -53,6 +53,12 @@ typedef struct VhostShadowVirtqueue {
- /* Next VirtQueue element that guest made available */
- VirtQueueElement *next_guest_avail_elem;
-
-+ /*
-+ * Backup next field for each descriptor so we can recover securely, not
-+ * needing to trust the device access.
-+ */
-+ uint16_t *desc_next;
-+
- /* Next head to expose to the device */
- uint16_t shadow_avail_idx;
-
diff --git a/debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch b/debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
deleted file mode 100644
index 497bcec..0000000
--- a/debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:43 +0200
-Subject: [PATCH] vhost: Fix device's used descriptor dequeue
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Only the first one of them were properly enqueued back.
-
-Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-3-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 81abfa5724c9a6502d7a1d3a67c55f2a303a1170)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-shadow-virtqueue.c | 17 +++++++++++++++--
- 1 file changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
-index 3155801f50..31fc50907d 100644
---- a/hw/virtio/vhost-shadow-virtqueue.c
-+++ b/hw/virtio/vhost-shadow-virtqueue.c
-@@ -334,12 +334,22 @@ static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
- svq->vring.avail->flags |= cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
- }
-
-+static uint16_t vhost_svq_last_desc_of_chain(const VhostShadowVirtqueue *svq,
-+ uint16_t num, uint16_t i)
-+{
-+ for (uint16_t j = 0; j < (num - 1); ++j) {
-+ i = le16_to_cpu(svq->desc_next[i]);
-+ }
-+
-+ return i;
-+}
-+
- static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- uint32_t *len)
- {
- const vring_used_t *used = svq->vring.used;
- vring_used_elem_t used_elem;
-- uint16_t last_used;
-+ uint16_t last_used, last_used_chain, num;
-
- if (!vhost_svq_more_used(svq)) {
- return NULL;
-@@ -365,7 +375,10 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- return NULL;
- }
-
-- svq->desc_next[used_elem.id] = svq->free_head;
-+ num = svq->ring_id_maps[used_elem.id]->in_num +
-+ svq->ring_id_maps[used_elem.id]->out_num;
-+ last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
-+ svq->desc_next[last_used_chain] = svq->free_head;
- svq->free_head = used_elem.id;
-
- *len = used_elem.len;
diff --git a/debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch b/debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
deleted file mode 100644
index 6f33164..0000000
--- a/debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:44 +0200
-Subject: [PATCH] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Fixes: 6d0b222666 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ")
-
-Acked-by: Jason Wang <jasowang@redhat.com>
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-4-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 639036477ef890958415967e753ca2cbb348c16c)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-vdpa.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
-index 8adf7c0b92..8555a84f87 100644
---- a/hw/virtio/vhost-vdpa.c
-+++ b/hw/virtio/vhost-vdpa.c
-@@ -1170,11 +1170,11 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
- struct vhost_vring_state *ring)
- {
- struct vhost_vdpa *v = dev->opaque;
-+ int vdpa_idx = ring->index - dev->vq_index;
- int ret;
-
- if (v->shadow_vqs_enabled) {
-- VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs,
-- ring->index);
-+ VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, vdpa_idx);
-
- /*
- * Setting base as last used idx, so destination will see as available
diff --git a/debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch b/debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
deleted file mode 100644
index 8c74f0c..0000000
--- a/debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:45 +0200
-Subject: [PATCH] vdpa: Fix index calculus at vhost_vdpa_svqs_start
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-With the introduction of MQ the index of the vq needs to be calculated
-with the device model vq_index.
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Acked-by: Jason Wang <jasowang@redhat.com>
-Message-Id: <20220512175747.142058-5-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 1c82fdfef8a227518ffecae9d419bcada995c202)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-vdpa.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
-index 8555a84f87..aa43cfa7d9 100644
---- a/hw/virtio/vhost-vdpa.c
-+++ b/hw/virtio/vhost-vdpa.c
-@@ -1016,7 +1016,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
- VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
- VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
- struct vhost_vring_addr addr = {
-- .index = i,
-+ .index = dev->vq_index + i,
- };
- int r;
- bool ok = vhost_vdpa_svq_setup(dev, svq, i, &err);
diff --git a/debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch b/debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
deleted file mode 100644
index 12ea0ad..0000000
--- a/debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
-Date: Thu, 12 May 2022 19:57:46 +0200
-Subject: [PATCH] hw/virtio: Replace g_memdup() by g_memdup2()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Per https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538
-
- The old API took the size of the memory to duplicate as a guint,
- whereas most memory functions take memory sizes as a gsize. This
- made it easy to accidentally pass a gsize to g_memdup(). For large
- values, that would lead to a silent truncation of the size from 64
- to 32 bits, and result in a heap area being returned which is
- significantly smaller than what the caller expects. This can likely
- be exploited in various modules to cause a heap buffer overflow.
-
-Replace g_memdup() by the safer g_memdup2() wrapper.
-
-Acked-by: Jason Wang <jasowang@redhat.com>
-Acked-by: Eugenio Pérez <eperezma@redhat.com>
-Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
-Message-Id: <20220512175747.142058-6-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit d792199de55ca5cb5334016884039c740290b5c7)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/net/virtio-net.c | 3 ++-
- hw/virtio/virtio-crypto.c | 6 +++---
- 2 files changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
-index 1067e72b39..e4748a7e6c 100644
---- a/hw/net/virtio-net.c
-+++ b/hw/net/virtio-net.c
-@@ -1443,7 +1443,8 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
- }
-
- iov_cnt = elem->out_num;
-- iov2 = iov = g_memdup(elem->out_sg, sizeof(struct iovec) * elem->out_num);
-+ iov2 = iov = g_memdup2(elem->out_sg,
-+ sizeof(struct iovec) * elem->out_num);
- s = iov_to_buf(iov, iov_cnt, 0, &ctrl, sizeof(ctrl));
- iov_discard_front(&iov, &iov_cnt, sizeof(ctrl));
- if (s != sizeof(ctrl)) {
-diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
-index dcd80b904d..0e31e3cc04 100644
---- a/hw/virtio/virtio-crypto.c
-+++ b/hw/virtio/virtio-crypto.c
-@@ -242,7 +242,7 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
- }
-
- out_num = elem->out_num;
-- out_iov_copy = g_memdup(elem->out_sg, sizeof(out_iov[0]) * out_num);
-+ out_iov_copy = g_memdup2(elem->out_sg, sizeof(out_iov[0]) * out_num);
- out_iov = out_iov_copy;
-
- in_num = elem->in_num;
-@@ -605,11 +605,11 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)
- }
-
- out_num = elem->out_num;
-- out_iov_copy = g_memdup(elem->out_sg, sizeof(out_iov[0]) * out_num);
-+ out_iov_copy = g_memdup2(elem->out_sg, sizeof(out_iov[0]) * out_num);
- out_iov = out_iov_copy;
-
- in_num = elem->in_num;
-- in_iov_copy = g_memdup(elem->in_sg, sizeof(in_iov[0]) * in_num);
-+ in_iov_copy = g_memdup2(elem->in_sg, sizeof(in_iov[0]) * in_num);
- in_iov = in_iov_copy;
-
- if (unlikely(iov_to_buf(out_iov, out_num, 0, &req, sizeof(req))
diff --git a/debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch b/debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
deleted file mode 100644
index daa5bca..0000000
--- a/debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:47 +0200
-Subject: [PATCH] vhost: Fix element in vhost_svq_add failure
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Coverity rightly reports that is not free in that case.
-
-Fixes: Coverity CID 1487559
-Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-7-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 5181db132b587754dda3a520eec923b87a65bbb7)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-shadow-virtqueue.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
-index 31fc50907d..06d0bb39d9 100644
---- a/hw/virtio/vhost-shadow-virtqueue.c
-+++ b/hw/virtio/vhost-shadow-virtqueue.c
-@@ -199,11 +199,19 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
- return true;
- }
-
-+/**
-+ * Add an element to a SVQ.
-+ *
-+ * The caller must check that there is enough slots for the new element. It
-+ * takes ownership of the element: In case of failure, it is free and the SVQ
-+ * is considered broken.
-+ */
- static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
- {
- unsigned qemu_head;
- bool ok = vhost_svq_add_split(svq, elem, &qemu_head);
- if (unlikely(!ok)) {
-+ g_free(elem);
- return false;
- }
-
diff --git a/debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch b/debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch
deleted file mode 100644
index 88cf137..0000000
--- a/debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Dominique Martinet <dominique.martinet@atmark-techno.com>
-Date: Thu, 30 Jun 2022 10:01:37 +0900
-Subject: [PATCH] io_uring: fix short read slow path
-
-sqeq.off here is the offset to read within the disk image, so obviously
-not 'nread' (the amount we just read), but as the author meant to write
-its current value incremented by the amount we just read.
-
-Normally recent versions of linux will not issue short reads,
-but it can happen so we should fix this.
-
-This lead to weird image corruptions when short read happened
-
-Fixes: 6663a0a33764 ("block/io_uring: implements interfaces for io_uring")
-Link: https://lkml.kernel.org/r/YrrFGO4A1jS0GI0G@atmark-techno.com
-Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
-Message-Id: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com>
-Reviewed-by: Hanna Reitz <hreitz@redhat.com>
-Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit c06fc7ce147e57ab493bad9263f1601b8298484b)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/io_uring.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/block/io_uring.c b/block/io_uring.c
-index 782afdb433..e451e55de0 100644
---- a/block/io_uring.c
-+++ b/block/io_uring.c
-@@ -89,7 +89,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
- trace_luring_resubmit_short_read(s, luringcb, nread);
-
- /* Update read position */
-- luringcb->total_read = nread;
-+ luringcb->total_read += nread;
- remaining = luringcb->qiov->size - luringcb->total_read;
-
- /* Shorten qiov */
-@@ -103,7 +103,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
- remaining);
-
- /* Update sqe */
-- luringcb->sqeq.off = nread;
-+ luringcb->sqeq.off += nread;
- luringcb->sqeq.addr = (__u64)(uintptr_t)luringcb->resubmit_qiov.iov;
- luringcb->sqeq.len = luringcb->resubmit_qiov.niov;
-
diff --git a/debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch b/debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
deleted file mode 100644
index ee66fba..0000000
--- a/debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Ding Hui <dinghui@sangfor.com.cn>
-Date: Wed, 29 Jun 2022 17:40:26 +0800
-Subject: [PATCH] e1000: set RX descriptor status in a separate operation
-
-The code of setting RX descriptor status field maybe work fine in
-previously, however with the update of glibc version, it shows two
-issues when guest using dpdk receive packets:
-
- 1. The dpdk has a certain probability getting wrong buffer_addr
-
- this impact may be not obvious, such as lost a packet once in
- a while
-
- 2. The dpdk may consume a packet twice when scan the RX desc queue
- over again
-
- this impact will lead a infinite wait in Qemu, since the RDT
- (tail pointer) be inscreased to equal to RDH by unexpected,
- which regard as the RX desc queue is full
-
-Write a whole of RX desc with DD flag on is not quite correct, because
-when the underlying implementation of memcpy using XMM registers to
-copy e1000_rx_desc (when AVX or something else CPU feature is usable),
-the bytes order of desc writing to memory is indeterminacy
-
-We can use full-scale test case to reproduce the issue-2 by
-https://github.com/BASM/qemu_dpdk_e1000_test (thanks to Leonid Myravjev)
-
-I also write a POC test case at https://github.com/cdkey/e1000_poc
-which can reproduce both of them, and easy to verify the patch effect.
-
-The hw watchpoint also shows that, when Qemu using XMM related instructions
-writing 16 bytes e1000_rx_desc, concurrent with DPDK using movb
-writing 1 byte status, the final result of writing to memory will be one
-of them, if it made by Qemu which DD flag is on, DPDK will consume it
-again.
-
-Setting DD status in a separate operation, can prevent the impact of
-disorder memory writing by memcpy, also avoid unexpected data when
-concurrent writing status by qemu and guest dpdk.
-
-Links: https://lore.kernel.org/qemu-devel/20200102110504.GG121208@stefanha-x1.localdomain/T/
-
-Reported-by: Leonid Myravjev <asm@asm.pp.ru>
-Cc: Stefan Hajnoczi <stefanha@gmail.com>
-Cc: Paolo Bonzini <pbonzini@redhat.com>
-Cc: Michael S. Tsirkin <mst@redhat.com>
-Cc: qemu-stable@nongnu.org
-Tested-by: Jing Zhang <zhangjing@sangfor.com.cn>
-Reviewed-by: Frank Lee <lifan38153@sangfor.com.cn>
-Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
-Signed-off-by: Jason Wang <jasowang@redhat.com>
-(cherry-picked from commit 034d00d4858161e1d4cff82d8d230bce874a04d3)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/net/e1000.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/hw/net/e1000.c b/hw/net/e1000.c
-index f5bc81296d..e26e0a64c1 100644
---- a/hw/net/e1000.c
-+++ b/hw/net/e1000.c
-@@ -979,7 +979,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
- base = rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH];
- pci_dma_read(d, base, &desc, sizeof(desc));
- desc.special = vlan_special;
-- desc.status |= (vlan_status | E1000_RXD_STAT_DD);
-+ desc.status &= ~E1000_RXD_STAT_DD;
- if (desc.buffer_addr) {
- if (desc_offset < size) {
- size_t iov_copy;
-@@ -1013,6 +1013,9 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
- DBGOUT(RX, "Null RX descriptor!!\n");
- }
- pci_dma_write(d, base, &desc, sizeof(desc));
-+ desc.status |= (vlan_status | E1000_RXD_STAT_DD);
-+ pci_dma_write(d, base + offsetof(struct e1000_rx_desc, status),
-+ &desc.status, sizeof(desc.status));
-
- if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
- s->mac_reg[RDH] = 0;
diff --git a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
index 700afed..b21d8a7 100644
--- a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
+++ b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index 39a3d6dbe6..e5bf5d59bf 100644
+index 48cd096624..3d60b80286 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -554,7 +554,7 @@ static QemuOptsList raw_runtime_opts = {
+@@ -553,7 +553,7 @@ static QemuOptsList raw_runtime_opts = {
{
.name = "locking",
.type = QEMU_OPT_STRING,
@@ -26,7 +26,7 @@ index 39a3d6dbe6..e5bf5d59bf 100644
},
{
.name = "pr-manager",
-@@ -654,7 +654,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
+@@ -653,7 +653,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
s->use_lock = false;
break;
case ON_OFF_AUTO_AUTO:
diff --git a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
index 6a19ef0..0184097 100644
--- a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
+++ b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
@@ -10,10 +10,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
-index 982c532353..5395e7e471 100644
+index 82004b65b9..4868db8f94 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
-@@ -2087,9 +2087,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
+@@ -2133,9 +2133,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
#ifdef TARGET_X86_64
diff --git a/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch b/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch
index f8775dc..0890369 100644
--- a/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch
+++ b/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch
@@ -9,7 +9,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
-index 592e71b22a..aebfece6eb 100644
+index b60213ab80..93da76bc31 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -42,7 +42,7 @@
diff --git a/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch b/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
index ce4366d..a87a46a 100644
--- a/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
+++ b/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
@@ -18,7 +18,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+)
diff --git a/block/rbd.c b/block/rbd.c
-index 6caf35cbba..0cec24c86d 100644
+index f826410f40..64a8d7d48b 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -820,6 +820,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
diff --git a/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch b/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
index d6b5440..cd90b46 100644
--- a/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
+++ b/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 43 insertions(+)
diff --git a/net/net.c b/net/net.c
-index f0d14dbfc1..6d476c47ef 100644
+index 2db160e063..8329347891 100644
--- a/net/net.c
+++ b/net/net.c
-@@ -1334,6 +1334,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
+@@ -1343,6 +1343,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
}
}
@@ -49,7 +49,7 @@ index f0d14dbfc1..6d476c47ef 100644
{
NetClientState *nc;
diff --git a/qapi/net.json b/qapi/net.json
-index b92f3f5fb4..52c7e1f82b 100644
+index 75ba2cb989..a3c93ab88f 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -35,6 +35,21 @@
@@ -75,12 +75,12 @@ index b92f3f5fb4..52c7e1f82b 100644
# @netdev_add:
#
diff --git a/qapi/pragma.json b/qapi/pragma.json
-index e6a021c19c..41139d8645 100644
+index 7f810b0e97..a2358e303a 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
-@@ -25,6 +25,7 @@
- 'system_reset',
+@@ -26,6 +26,7 @@
'system_wakeup' ],
+ # Commands allowed to return a non-dictionary
'command-returns-exceptions': [
+ 'get_link_status',
'human-monitor-command',
diff --git a/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch b/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch
index 1c16ff7..88becc5 100644
--- a/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch
+++ b/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/gluster.c b/block/gluster.c
-index aebfece6eb..3b7ee2f649 100644
+index 93da76bc31..1079b6186b 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
diff --git a/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch b/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
index 0d67cd2..b2a27d8 100644
--- a/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
+++ b/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 1caddfb23a..2782e181c0 100644
+index 7d4b33b3da..bb36f42dd2 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -3005,7 +3005,8 @@ static int img_info(int argc, char **argv)
+@@ -3010,7 +3010,8 @@ static int img_info(int argc, char **argv)
list = collect_image_info_list(image_opts, filename, fmt, chain,
force_share);
if (!list) {
diff --git a/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch b/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
index 7163f0f..bed5c25 100644
--- a/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
+++ b/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
@@ -31,10 +31,11 @@ override the output file's size.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
qemu-img-cmds.hx | 4 +-
- qemu-img.c | 187 +++++++++++++++++++++++++++++------------------
- 2 files changed, 119 insertions(+), 72 deletions(-)
+ qemu-img.c | 202 ++++++++++++++++++++++++++++++-----------------
+ 2 files changed, 133 insertions(+), 73 deletions(-)
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index 1b1dab5b17..d1616c045a 100644
@@ -53,10 +54,10 @@ index 1b1dab5b17..d1616c045a 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 2782e181c0..8cd43b3601 100644
+index bb36f42dd2..74afcb79ef 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4821,10 +4821,12 @@ static int img_bitmap(int argc, char **argv)
+@@ -4826,10 +4826,12 @@ static int img_bitmap(int argc, char **argv)
#define C_IF 04
#define C_OF 010
#define C_SKIP 020
@@ -69,7 +70,7 @@ index 2782e181c0..8cd43b3601 100644
};
struct DdIo {
-@@ -4900,6 +4902,19 @@ static int img_dd_skip(const char *arg,
+@@ -4905,6 +4907,19 @@ static int img_dd_skip(const char *arg,
return 0;
}
@@ -89,7 +90,7 @@ index 2782e181c0..8cd43b3601 100644
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4940,6 +4955,7 @@ static int img_dd(int argc, char **argv)
+@@ -4945,6 +4960,7 @@ static int img_dd(int argc, char **argv)
{ "if", img_dd_if, C_IF },
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
@@ -97,7 +98,7 @@ index 2782e181c0..8cd43b3601 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5015,91 +5031,112 @@ static int img_dd(int argc, char **argv)
+@@ -5020,91 +5036,112 @@ static int img_dd(int argc, char **argv)
arg = NULL;
}
@@ -153,9 +154,9 @@ index 2782e181c0..8cd43b3601 100644
}
- create_opts = qemu_opts_append(create_opts, drv->create_opts);
- create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
-
-- opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
-
+- opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
+
- size = blk_getlength(blk1);
- if (size < 0) {
- error_report("Failed to get size for '%s'", in.filename);
@@ -274,41 +275,54 @@ index 2782e181c0..8cd43b3601 100644
}
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
-@@ -5117,11 +5154,17 @@ static int img_dd(int argc, char **argv)
+@@ -5121,20 +5158,43 @@ static int img_dd(int argc, char **argv)
+ in.buf = g_new(uint8_t, in.bsz);
for (out_pos = 0; in_pos < size; block_count++) {
- int in_ret, out_ret;
++ int in_ret, out_ret;
+ int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
-
-- if (in_pos + in.bsz > size) {
-- in_ret = blk_pread(blk1, in_pos, in.buf, size - in_pos);
-+ size_t in_bsz = in_pos + in.bsz > size ? size - in_pos : in.bsz;
+- ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
+- if (ret < 0) {
+ if (blk1) {
-+ in_ret = blk_pread(blk1, in_pos, in.buf, in_bsz);
- } else {
-- in_ret = blk_pread(blk1, in_pos, in.buf, in.bsz);
-+ in_ret = read(STDIN_FILENO, in.buf, in_bsz);
++ in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
++ if (in_ret == 0) {
++ in_ret = bytes;
++ }
++ } else {
++ in_ret = read(STDIN_FILENO, in.buf, bytes);
+ if (in_ret == 0) {
+ /* early EOF is considered an error */
+ error_report("Input ended unexpectedly");
+ ret = -1;
+ goto out;
+ }
- }
- if (in_ret < 0) {
++ }
++ if (in_ret < 0) {
error_report("error while reading from input image file: %s",
-@@ -5131,9 +5174,13 @@ static int img_dd(int argc, char **argv)
+- strerror(-ret));
++ strerror(-in_ret));
++ ret = -1;
+ goto out;
}
- in_pos += in_ret;
+ in_pos += bytes;
-- out_ret = blk_pwrite(blk2, out_pos, in.buf, in_ret, 0);
+- ret = blk_pwrite(blk2, out_pos, bytes, in.buf, 0);
+- if (ret < 0) {
+ if (blk2) {
-+ out_ret = blk_pwrite(blk2, out_pos, in.buf, in_ret, 0);
++ out_ret = blk_pwrite(blk2, out_pos, in_ret, in.buf, 0);
++ if (out_ret == 0) {
++ out_ret = in_ret;
++ }
+ } else {
+ out_ret = write(STDOUT_FILENO, in.buf, in_ret);
+ }
-
-- if (out_ret < 0) {
++
+ if (out_ret != in_ret) {
error_report("error while writing to output image file: %s",
- strerror(-out_ret));
- ret = -1;
+- strerror(-ret));
++ strerror(-out_ret));
++ ret = -1;
+ goto out;
+ }
+ out_pos += bytes;
diff --git a/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch b/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
index 29df3de..f367a53 100644
--- a/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
+++ b/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
@@ -10,15 +10,16 @@ an expected end of input.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
qemu-img.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 8cd43b3601..67033b2d2c 100644
+index 74afcb79ef..14594d44b6 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4822,11 +4822,13 @@ static int img_bitmap(int argc, char **argv)
+@@ -4827,11 +4827,13 @@ static int img_bitmap(int argc, char **argv)
#define C_OF 010
#define C_SKIP 020
#define C_OSIZE 040
@@ -32,7 +33,7 @@ index 8cd43b3601..67033b2d2c 100644
};
struct DdIo {
-@@ -4915,6 +4917,19 @@ static int img_dd_osize(const char *arg,
+@@ -4920,6 +4922,19 @@ static int img_dd_osize(const char *arg,
return 0;
}
@@ -52,7 +53,7 @@ index 8cd43b3601..67033b2d2c 100644
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4929,12 +4944,14 @@ static int img_dd(int argc, char **argv)
+@@ -4934,12 +4949,14 @@ static int img_dd(int argc, char **argv)
int c, i;
const char *out_fmt = "raw";
const char *fmt = NULL;
@@ -68,7 +69,7 @@ index 8cd43b3601..67033b2d2c 100644
};
struct DdIo in = {
.bsz = 512, /* Block size is by default 512 bytes */
-@@ -4956,6 +4973,7 @@ static int img_dd(int argc, char **argv)
+@@ -4961,6 +4978,7 @@ static int img_dd(int argc, char **argv)
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
{ "osize", img_dd_osize, C_OSIZE },
@@ -76,7 +77,7 @@ index 8cd43b3601..67033b2d2c 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5152,14 +5170,18 @@ static int img_dd(int argc, char **argv)
+@@ -5157,9 +5175,10 @@ static int img_dd(int argc, char **argv)
in.buf = g_new(uint8_t, in.bsz);
@@ -84,12 +85,14 @@ index 8cd43b3601..67033b2d2c 100644
+ readsize = (dd.isize > 0) ? dd.isize : size;
+ for (out_pos = 0; in_pos < readsize; block_count++) {
int in_ret, out_ret;
-- size_t in_bsz = in_pos + in.bsz > size ? size - in_pos : in.bsz;
-+ size_t in_bsz = in_pos + in.bsz > readsize ? readsize - in_pos : in.bsz;
+- int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
++ int bytes = (in_pos + in.bsz > readsize) ? readsize - in_pos : in.bsz;
if (blk1) {
- in_ret = blk_pread(blk1, in_pos, in.buf, in_bsz);
+ in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
+ if (in_ret == 0) {
+@@ -5168,6 +5187,9 @@ static int img_dd(int argc, char **argv)
} else {
- in_ret = read(STDIN_FILENO, in.buf, in_bsz);
+ in_ret = read(STDIN_FILENO, in.buf, bytes);
if (in_ret == 0) {
+ if (dd.isize == 0) {
+ goto out;
diff --git a/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch b/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
index 39991dd..f24932d 100644
--- a/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
+++ b/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
@@ -13,7 +13,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index 8885ea11cf..33979b7430 100644
+index 85a6e05b35..699229eef6 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -208,6 +208,10 @@ Parameters to convert subcommand:
@@ -65,10 +65,10 @@ index d1616c045a..b5b0bb4467 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 67033b2d2c..35c2bdc95c 100644
+index 14594d44b6..c6b4a5567d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4946,7 +4946,7 @@ static int img_dd(int argc, char **argv)
+@@ -4951,7 +4951,7 @@ static int img_dd(int argc, char **argv)
const char *fmt = NULL;
int64_t size = 0, readsize = 0;
int64_t block_count = 0, out_pos, in_pos;
@@ -77,7 +77,7 @@ index 67033b2d2c..35c2bdc95c 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4984,7 +4984,7 @@ static int img_dd(int argc, char **argv)
+@@ -4989,7 +4989,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -86,7 +86,7 @@ index 67033b2d2c..35c2bdc95c 100644
if (c == EOF) {
break;
}
-@@ -5004,6 +5004,9 @@ static int img_dd(int argc, char **argv)
+@@ -5009,6 +5009,9 @@ static int img_dd(int argc, char **argv)
case 'h':
help();
break;
@@ -96,7 +96,7 @@ index 67033b2d2c..35c2bdc95c 100644
case 'U':
force_share = true;
break;
-@@ -5134,13 +5137,15 @@ static int img_dd(int argc, char **argv)
+@@ -5139,13 +5142,15 @@ static int img_dd(int argc, char **argv)
size - in.bsz * in.offset, &error_abort);
}
diff --git a/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch b/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
index a52235f..12beef5 100644
--- a/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
+++ b/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
-index 163d244eb4..389907f1f8 100644
+index 73ac5eb675..bbfe7eca62 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
-@@ -813,8 +813,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+@@ -806,8 +806,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
@@ -58,10 +58,10 @@ index 163d244eb4..389907f1f8 100644
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 634968498b..5482dd0569 100644
+index c6cd6f91dd..15572befb1 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -708,7 +708,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
+@@ -715,7 +715,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
return;
}
@@ -99,10 +99,10 @@ index 634968498b..5482dd0569 100644
qapi_free_BalloonInfo(info);
}
diff --git a/qapi/machine.json b/qapi/machine.json
-index d25a481ce4..3627172aed 100644
+index 6afd1936b0..8b4be9b718 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -1018,10 +1018,30 @@
+@@ -1054,9 +1054,29 @@
# @actual: the logical size of the VM in bytes
# Formula used: logical_vm_size = vm_ram_size - balloon_size
#
@@ -123,7 +123,6 @@ index d25a481ce4..3627172aed 100644
+# @max_mem: amount of memory (in bytes) assigned to the guest
+#
# Since: 0.14
- #
##
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
+{ 'struct': 'BalloonInfo',
diff --git a/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch b/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
index 8c7d776..cc3c92e 100644
--- a/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
+++ b/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
@@ -30,10 +30,10 @@ index 4f4ab30f8c..76fff60a6b 100644
info->default_cpu_type = g_strdup(mc->default_cpu_type);
info->has_default_cpu_type = true;
diff --git a/qapi/machine.json b/qapi/machine.json
-index 3627172aed..ca133e68ce 100644
+index 8b4be9b718..555458f785 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -139,6 +139,8 @@
+@@ -138,6 +138,8 @@
#
# @is-default: whether the machine is default
#
@@ -42,7 +42,7 @@ index 3627172aed..ca133e68ce 100644
# @cpu-max: maximum number of CPUs supported by the machine type
# (since 1.5)
#
-@@ -160,7 +162,7 @@
+@@ -159,7 +161,7 @@
##
{ 'struct': 'MachineInfo',
'data': { 'name': 'str', '*alias': 'str',
diff --git a/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch b/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
index 3f7fd62..c3f3fc3 100644
--- a/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
+++ b/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
@@ -12,10 +12,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 8 insertions(+)
diff --git a/qapi/ui.json b/qapi/ui.json
-index 13a8bb82aa..4c34436ba7 100644
+index cf58ab4283..0be2388941 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
-@@ -300,11 +300,14 @@
+@@ -310,11 +310,14 @@
#
# @channels: a list of @SpiceChannel for each active spice channel
#
diff --git a/debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch b/debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
new file mode 100644
index 0000000..e48eb9d
--- /dev/null
+++ b/debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
@@ -0,0 +1,280 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Fiona Ebner <f.ebner@proxmox.com>
+Date: Thu, 13 Oct 2022 11:33:50 +0200
+Subject: [PATCH] PVE: add IOChannel implementation for savevm-async
+
+based on migration/channel-block.c and the implementation that was
+present in migration/savevm-async.c before QEMU 7.1.
+
+Passes along read/write requests to the given BlockBackend, while
+ensuring that a read request going beyond the end results in a
+graceful short read.
+
+Additionally, allows tracking the current position from the outside
+(intended to be used for progress tracking).
+
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
+---
+ migration/channel-savevm-async.c | 181 +++++++++++++++++++++++++++++++
+ migration/channel-savevm-async.h | 51 +++++++++
+ migration/meson.build | 1 +
+ 3 files changed, 233 insertions(+)
+ create mode 100644 migration/channel-savevm-async.c
+ create mode 100644 migration/channel-savevm-async.h
+
+diff --git a/migration/channel-savevm-async.c b/migration/channel-savevm-async.c
+new file mode 100644
+index 0000000000..efea3842cf
+--- /dev/null
++++ b/migration/channel-savevm-async.c
+@@ -0,0 +1,181 @@
++/*
++ * QIO Channel implementation to be used by savevm-async QMP calls
++ */
++#include "qemu/osdep.h"
++#include "migration/channel-savevm-async.h"
++#include "qapi/error.h"
++#include "sysemu/block-backend.h"
++#include "trace.h"
++
++QIOChannelSavevmAsync *
++qio_channel_savevm_async_new(BlockBackend *be, size_t *bs_pos)
++{
++ QIOChannelSavevmAsync *ioc;
++
++ ioc = QIO_CHANNEL_SAVEVM_ASYNC(object_new(TYPE_QIO_CHANNEL_SAVEVM_ASYNC));
++
++ bdrv_ref(blk_bs(be));
++ ioc->be = be;
++ ioc->bs_pos = bs_pos;
++
++ return ioc;
++}
++
++
++static void
++qio_channel_savevm_async_finalize(Object *obj)
++{
++ QIOChannelSavevmAsync *ioc = QIO_CHANNEL_SAVEVM_ASYNC(obj);
++
++ if (ioc->be) {
++ bdrv_unref(blk_bs(ioc->be));
++ ioc->be = NULL;
++ }
++ ioc->bs_pos = NULL;
++}
++
++
++static ssize_t
++qio_channel_savevm_async_readv(QIOChannel *ioc,
++ const struct iovec *iov,
++ size_t niov,
++ int **fds,
++ size_t *nfds,
++ Error **errp)
++{
++ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
++ BlockBackend *be = saioc->be;
++ int64_t maxlen = blk_getlength(be);
++ QEMUIOVector qiov;
++ size_t size;
++ int ret;
++
++ qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
++
++ if (*saioc->bs_pos >= maxlen) {
++ error_setg(errp, "cannot read beyond maxlen");
++ return -1;
++ }
++
++ if (maxlen - *saioc->bs_pos < qiov.size) {
++ size = maxlen - *saioc->bs_pos;
++ } else {
++ size = qiov.size;
++ }
++
++ // returns 0 on success
++ ret = blk_preadv(be, *saioc->bs_pos, size, &qiov, 0);
++ if (ret < 0) {
++ error_setg(errp, "blk_preadv returned %d", ret);
++ return -1;
++ }
++
++ *saioc->bs_pos += size;
++ return size;
++}
++
++
++static ssize_t
++qio_channel_savevm_async_writev(QIOChannel *ioc,
++ const struct iovec *iov,
++ size_t niov,
++ int *fds,
++ size_t nfds,
++ int flags,
++ Error **errp)
++{
++ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
++ BlockBackend *be = saioc->be;
++ QEMUIOVector qiov;
++ int ret;
++
++ qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
++
++ if (qemu_in_coroutine()) {
++ ret = blk_co_pwritev(be, *saioc->bs_pos, qiov.size, &qiov, 0);
++ aio_wait_kick();
++ } else {
++ ret = blk_pwritev(be, *saioc->bs_pos, qiov.size, &qiov, 0);
++ }
++
++ if (ret < 0) {
++ return ret;
++ }
++
++ *saioc->bs_pos += qiov.size;
++ return qiov.size;
++}
++
++
++static int
++qio_channel_savevm_async_set_blocking(QIOChannel *ioc,
++ bool enabled,
++ Error **errp)
++{
++ if (!enabled) {
++ error_setg(errp, "Non-blocking mode not supported for savevm-async");
++ return -1;
++ }
++ return 0;
++}
++
++
++static int
++qio_channel_savevm_async_close(QIOChannel *ioc,
++ Error **errp)
++{
++ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
++ int rv = bdrv_flush(blk_bs(saioc->be));
++
++ if (rv < 0) {
++ error_setg_errno(errp, -rv, "Unable to flush VMState");
++ return -1;
++ }
++
++ bdrv_unref(blk_bs(saioc->be));
++ saioc->be = NULL;
++ saioc->bs_pos = NULL;
++
++ return 0;
++}
++
++
++static void
++qio_channel_savevm_async_set_aio_fd_handler(QIOChannel *ioc,
++ AioContext *ctx,
++ IOHandler *io_read,
++ IOHandler *io_write,
++ void *opaque)
++{
++ // if channel-block starts doing something, check if this needs adaptation
++}
++
++
++static void
++qio_channel_savevm_async_class_init(ObjectClass *klass,
++ void *class_data G_GNUC_UNUSED)
++{
++ QIOChannelClass *ioc_klass = QIO_CHANNEL_CLASS(klass);
++
++ ioc_klass->io_writev = qio_channel_savevm_async_writev;
++ ioc_klass->io_readv = qio_channel_savevm_async_readv;
++ ioc_klass->io_set_blocking = qio_channel_savevm_async_set_blocking;
++ ioc_klass->io_close = qio_channel_savevm_async_close;
++ ioc_klass->io_set_aio_fd_handler = qio_channel_savevm_async_set_aio_fd_handler;
++}
++
++static const TypeInfo qio_channel_savevm_async_info = {
++ .parent = TYPE_QIO_CHANNEL,
++ .name = TYPE_QIO_CHANNEL_SAVEVM_ASYNC,
++ .instance_size = sizeof(QIOChannelSavevmAsync),
++ .instance_finalize = qio_channel_savevm_async_finalize,
++ .class_init = qio_channel_savevm_async_class_init,
++};
++
++static void
++qio_channel_savevm_async_register_types(void)
++{
++ type_register_static(&qio_channel_savevm_async_info);
++}
++
++type_init(qio_channel_savevm_async_register_types);
+diff --git a/migration/channel-savevm-async.h b/migration/channel-savevm-async.h
+new file mode 100644
+index 0000000000..17ae2cb261
+--- /dev/null
++++ b/migration/channel-savevm-async.h
+@@ -0,0 +1,51 @@
++/*
++ * QEMU I/O channels driver for savevm-async.c
++ *
++ * Copyright (c) 2022 Proxmox Server Solutions
++ *
++ * Authors:
++ * Fiona Ebner (f.ebner@proxmox.com)
++ *
++ * This work is licensed under the terms of the GNU GPL, version 2 or later.
++ * See the COPYING file in the top-level directory.
++ */
++
++#ifndef QIO_CHANNEL_SAVEVM_ASYNC_H
++#define QIO_CHANNEL_SAVEVM_ASYNC_H
++
++#include "io/channel.h"
++#include "qom/object.h"
++
++#define TYPE_QIO_CHANNEL_SAVEVM_ASYNC "qio-channel-savevm-async"
++OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelSavevmAsync, QIO_CHANNEL_SAVEVM_ASYNC)
++
++
++/**
++ * QIOChannelSavevmAsync:
++ *
++ * The QIOChannelBlock object provides a channel implementation that is able to
++ * perform I/O on any BlockBackend whose BlockDriverState directly contains a
++ * VMState (as opposed to indirectly, like qcow2). It allows tracking the
++ * current position from the outside.
++ */
++struct QIOChannelSavevmAsync {
++ QIOChannel parent;
++ BlockBackend *be;
++ size_t *bs_pos;
++};
++
++
++/**
++ * qio_channel_savevm_async_new:
++ * @be: the block backend
++ * @bs_pos: used to keep track of the IOChannels current position
++ *
++ * Create a new IO channel object that can perform I/O on a BlockBackend object
++ * whose BlockDriverState directly contains a VMState.
++ *
++ * Returns: the new channel object
++ */
++QIOChannelSavevmAsync *
++qio_channel_savevm_async_new(BlockBackend *be, size_t *bs_pos);
++
++#endif /* QIO_CHANNEL_SAVEVM_ASYNC_H */
+diff --git a/migration/meson.build b/migration/meson.build
+index 690487cf1a..8cac83c06c 100644
+--- a/migration/meson.build
++++ b/migration/meson.build
+@@ -13,6 +13,7 @@ softmmu_ss.add(files(
+ 'block-dirty-bitmap.c',
+ 'channel.c',
+ 'channel-block.c',
++ 'channel-savevm-async.c',
+ 'colo-failover.c',
+ 'colo.c',
+ 'exec.c',
diff --git a/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch b/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
similarity index 88%
rename from debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
rename to debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
index 6bb06ec..7058cb2 100644
--- a/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
+++ b/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
@@ -23,25 +23,26 @@ Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
[improve aborting]
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
-[FE: further improve aborting]
+[FE: further improve aborting
+ adapt to removal of QEMUFileOps]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
hmp-commands-info.hx | 13 +
- hmp-commands.hx | 33 ++
+ hmp-commands.hx | 33 +++
include/migration/snapshot.h | 2 +
include/monitor/hmp.h | 5 +
migration/meson.build | 1 +
- migration/savevm-async.c | 604 +++++++++++++++++++++++++++++++++++
+ migration/savevm-async.c | 531 +++++++++++++++++++++++++++++++++++
monitor/hmp-cmds.c | 57 ++++
- qapi/migration.json | 34 ++
- qapi/misc.json | 32 ++
+ qapi/migration.json | 34 +++
+ qapi/misc.json | 32 +++
qemu-options.hx | 12 +
softmmu/vl.c | 10 +
- 11 files changed, 803 insertions(+)
+ 11 files changed, 730 insertions(+)
create mode 100644 migration/savevm-async.c
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index adfa085a9b..925e680e5a 100644
+index 188d9ece3b..97b88eaaad 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -538,6 +538,19 @@ SRST
@@ -65,12 +66,12 @@ index adfa085a9b..925e680e5a 100644
.name = "balloon",
.args_type = "",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 8476277aa9..7f0ac498c4 100644
+index 182e639d14..bbcc73e942 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
-@@ -1746,3 +1746,36 @@ ERST
- "\n\t\t\t -b to specify dirty bitmap as method of calculation)",
- .cmd = hmp_calc_dirty_rate,
+@@ -1800,3 +1800,36 @@ ERST
+ "\n\t\t\t\t\t limit on a specified virtual cpu",
+ .cmd = hmp_cancel_vcpu_dirty_limit,
},
+
+ {
@@ -117,7 +118,7 @@ index e72083b117..c846d37806 100644
+
#endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
-index 96d014826a..3a39ba41b5 100644
+index a618eb1e4e..55067beff1 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -26,6 +26,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
@@ -140,10 +141,10 @@ index 96d014826a..3a39ba41b5 100644
void hmp_screendump(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
diff --git a/migration/meson.build b/migration/meson.build
-index 8b5ca5c047..1e2aec8486 100644
+index 8cac83c06c..0842d00cd2 100644
--- a/migration/meson.build
+++ b/migration/meson.build
-@@ -23,6 +23,7 @@ softmmu_ss.add(files(
+@@ -24,6 +24,7 @@ softmmu_ss.add(files(
'multifd-zlib.c',
'postcopy-ram.c',
'savevm.c',
@@ -153,11 +154,12 @@ index 8b5ca5c047..1e2aec8486 100644
), gnutls)
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
new file mode 100644
-index 0000000000..b9a43c56bc
+index 0000000000..b3692739a0
--- /dev/null
+++ b/migration/savevm-async.c
-@@ -0,0 +1,604 @@
+@@ -0,0 +1,531 @@
+#include "qemu/osdep.h"
++#include "migration/channel-savevm-async.h"
+#include "migration/migration.h"
+#include "migration/savevm.h"
+#include "migration/snapshot.h"
@@ -181,9 +183,6 @@ index 0000000000..b9a43c56bc
+
+/* #define DEBUG_SAVEVM_STATE */
+
-+/* used while emulated sync operation in progress */
-+#define NOT_DONE -EINPROGRESS
-+
+#ifdef DEBUG_SAVEVM_STATE
+#define DPRINTF(fmt, ...) \
+ do { printf("savevm-async: " fmt, ## __VA_ARGS__); } while (0)
@@ -270,6 +269,7 @@ index 0000000000..b9a43c56bc
+
+ if (snap_state.file) {
+ ret = qemu_fclose(snap_state.file);
++ snap_state.file = NULL;
+ }
+
+ if (snap_state.target) {
@@ -313,60 +313,6 @@ index 0000000000..b9a43c56bc
+ snap_state.state = SAVE_STATE_ERROR;
+}
+
-+static int block_state_close(void *opaque, Error **errp)
-+{
-+ snap_state.file = NULL;
-+ return blk_flush(snap_state.target);
-+}
-+
-+typedef struct BlkRwCo {
-+ int64_t offset;
-+ QEMUIOVector *qiov;
-+ ssize_t ret;
-+} BlkRwCo;
-+
-+static void coroutine_fn block_state_write_entry(void *opaque) {
-+ BlkRwCo *rwco = opaque;
-+ rwco->ret = blk_co_pwritev(snap_state.target, rwco->offset, rwco->qiov->size,
-+ rwco->qiov, 0);
-+ aio_wait_kick();
-+}
-+
-+static ssize_t block_state_writev_buffer(void *opaque, struct iovec *iov,
-+ int iovcnt, int64_t pos, Error **errp)
-+{
-+ QEMUIOVector qiov;
-+ BlkRwCo rwco;
-+
-+ assert(pos == snap_state.bs_pos);
-+ rwco = (BlkRwCo) {
-+ .offset = pos,
-+ .qiov = &qiov,
-+ .ret = NOT_DONE,
-+ };
-+
-+ qemu_iovec_init_external(&qiov, iov, iovcnt);
-+
-+ if (qemu_in_coroutine()) {
-+ block_state_write_entry(&rwco);
-+ } else {
-+ Coroutine *co = qemu_coroutine_create(&block_state_write_entry, &rwco);
-+ bdrv_coroutine_enter(blk_bs(snap_state.target), co);
-+ BDRV_POLL_WHILE(blk_bs(snap_state.target), rwco.ret == NOT_DONE);
-+ }
-+ if (rwco.ret < 0) {
-+ return rwco.ret;
-+ }
-+
-+ snap_state.bs_pos += qiov.size;
-+ return qiov.size;
-+}
-+
-+static const QEMUFileOps block_file_ops = {
-+ .writev_buffer = block_state_writev_buffer,
-+ .close = block_state_close,
-+};
-+
+static void process_savevm_finalize(void *opaque)
+{
+ int ret;
@@ -579,7 +525,9 @@ index 0000000000..b9a43c56bc
+ goto restart;
+ }
+
-+ snap_state.file = qemu_fopen_ops(&snap_state, &block_file_ops);
++ QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target,
++ &snap_state.bs_pos));
++ snap_state.file = qemu_file_new_output(ioc);
+
+ if (!snap_state.file) {
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
@@ -691,27 +639,6 @@ index 0000000000..b9a43c56bc
+ true, name, errp);
+}
+
-+static ssize_t loadstate_get_buffer(void *opaque, uint8_t *buf, int64_t pos,
-+ size_t size, Error **errp)
-+{
-+ BlockBackend *be = opaque;
-+ int64_t maxlen = blk_getlength(be);
-+ if (pos > maxlen) {
-+ return -EIO;
-+ }
-+ if ((pos + size) > maxlen) {
-+ size = maxlen - pos - 1;
-+ }
-+ if (size == 0) {
-+ return 0;
-+ }
-+ return blk_pread(be, pos, buf, size);
-+}
-+
-+static const QEMUFileOps loadstate_file_ops = {
-+ .get_buffer = loadstate_get_buffer,
-+};
-+
+int load_snapshot_from_blockdev(const char *filename, Error **errp)
+{
+ BlockBackend *be;
@@ -719,6 +646,7 @@ index 0000000000..b9a43c56bc
+ Error *blocker = NULL;
+
+ QEMUFile *f;
++ size_t bs_pos = 0;
+ int ret = -EINVAL;
+
+ be = blk_new_open(filename, NULL, NULL, 0, &local_err);
@@ -732,7 +660,7 @@ index 0000000000..b9a43c56bc
+ blk_op_block_all(be, blocker);
+
+ /* restore the VM state */
-+ f = qemu_fopen_ops(be, &loadstate_file_ops);
++ f = qemu_file_new_input(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)));
+ if (!f) {
+ error_setg(errp, "Could not open VM state file");
+ goto the_end;
@@ -762,10 +690,10 @@ index 0000000000..b9a43c56bc
+ return ret;
+}
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 5482dd0569..c64b959738 100644
+index 15572befb1..1507180990 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -1906,6 +1906,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
+@@ -1925,6 +1925,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, err);
}
@@ -830,10 +758,10 @@ index 5482dd0569..c64b959738 100644
{
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
diff --git a/qapi/migration.json b/qapi/migration.json
-index 27d7b28158..31d6cc902e 100644
+index 81185d4311..3129f71fa8 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
-@@ -258,6 +258,40 @@
+@@ -261,6 +261,40 @@
'*compression': 'CompressionStats',
'*socket-address': ['SocketAddress'] } }
@@ -875,7 +803,7 @@ index 27d7b28158..31d6cc902e 100644
# @query-migrate:
#
diff --git a/qapi/misc.json b/qapi/misc.json
-index b83cc39029..1e5dd7db29 100644
+index 27ef5a2b20..b3ce75dcae 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -435,6 +435,38 @@
@@ -918,10 +846,10 @@ index b83cc39029..1e5dd7db29 100644
# @CommandLineParameterType:
#
diff --git a/qemu-options.hx b/qemu-options.hx
-index 34e9b32a5c..aeade4ef80 100644
+index 31c04f7eea..c2ca6e91b5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -4254,6 +4254,18 @@ SRST
+@@ -4341,6 +4341,18 @@ SRST
Start right away with a saved state (``loadvm`` in monitor)
ERST
@@ -941,18 +869,18 @@ index 34e9b32a5c..aeade4ef80 100644
DEF("daemonize", 0, QEMU_OPTION_daemonize, \
"-daemonize daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 6f646531a0..a3f2a3818c 100644
+index 706bd7cff7..b8637c4262 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -157,6 +157,7 @@ static const char *incoming;
- static const char *loadvm;
- static const char *accelerators;
+@@ -165,6 +165,7 @@ static const char *accelerators;
+ static bool have_custom_ram_size;
+ static const char *ram_memdev_id;
static QDict *machine_opts_dict;
+static const char *loadstate;
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
- static ram_addr_t maxram_size;
-@@ -2749,6 +2750,12 @@ void qmp_x_exit_preconfig(Error **errp)
+ static int display_remote;
+@@ -2584,6 +2585,12 @@ void qmp_x_exit_preconfig(Error **errp)
if (loadvm) {
load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
@@ -965,7 +893,7 @@ index 6f646531a0..a3f2a3818c 100644
}
if (replay_mode != REPLAY_MODE_NONE) {
replay_vmstate_init();
-@@ -3289,6 +3296,9 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3133,6 +3140,9 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_loadvm:
loadvm = optarg;
break;
diff --git a/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
similarity index 52%
rename from debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
rename to debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
index c5cca9d..71ee72d 100644
--- a/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
+++ b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
@@ -10,14 +10,16 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
[increase max IOV count in QEMUFile to actually write more data]
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+[FE: adapt to removal of QEMUFileOps]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
- migration/qemu-file.c | 38 +++++++++++++++++++++++++-------------
- migration/qemu-file.h | 1 +
- migration/savevm-async.c | 4 ++--
- 3 files changed, 28 insertions(+), 15 deletions(-)
+ migration/qemu-file.c | 49 +++++++++++++++++++++++++++-------------
+ migration/qemu-file.h | 2 ++
+ migration/savevm-async.c | 5 ++--
+ 3 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
-index 1479cddad9..21a3355ae2 100644
+index 4f400c2e52..21e8998867 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -31,8 +31,8 @@
@@ -30,9 +32,9 @@ index 1479cddad9..21a3355ae2 100644
+#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 256)
struct QEMUFile {
- const QEMUFileOps *ops;
-@@ -46,7 +46,8 @@ struct QEMUFile {
- when reading */
+ const QEMUFileHooks *hooks;
+@@ -55,7 +55,8 @@ struct QEMUFile {
+
int buf_index;
int buf_size; /* 0 when writing */
- uint8_t buf[IO_BUF_SIZE];
@@ -41,53 +43,76 @@ index 1479cddad9..21a3355ae2 100644
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
struct iovec iov[MAX_IOV_SIZE];
-@@ -104,7 +105,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
+@@ -106,7 +107,9 @@ bool qemu_file_mode_is_not_valid(const char *mode)
return false;
}
--QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
-+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size)
+-static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
++static QEMUFile *qemu_file_new_impl(QIOChannel *ioc,
++ bool is_writable,
++ size_t buffer_size)
{
QEMUFile *f;
-@@ -113,9 +114,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
- f->opaque = opaque;
- f->ops = ops;
- f->has_ioc = has_ioc;
+@@ -115,6 +118,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
+ object_ref(ioc);
+ f->ioc = ioc;
+ f->is_writable = is_writable;
+ f->buf_allocated_size = buffer_size;
+ f->buf = malloc(buffer_size);
-+
+
return f;
}
+@@ -125,17 +130,27 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
+ */
+ QEMUFile *qemu_file_get_return_path(QEMUFile *f)
+ {
+- return qemu_file_new_impl(f->ioc, !f->is_writable);
++ return qemu_file_new_impl(f->ioc, !f->is_writable, DEFAULT_IO_BUF_SIZE);
+ }
-+QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
+ QEMUFile *qemu_file_new_output(QIOChannel *ioc)
+ {
+- return qemu_file_new_impl(ioc, true);
++ return qemu_file_new_impl(ioc, true, DEFAULT_IO_BUF_SIZE);
++}
++
++QEMUFile *qemu_file_new_output_sized(QIOChannel *ioc, size_t buffer_size)
+{
-+ return qemu_fopen_ops_sized(opaque, ops, has_ioc, DEFAULT_IO_BUF_SIZE);
++ return qemu_file_new_impl(ioc, true, buffer_size);
+ }
+
+ QEMUFile *qemu_file_new_input(QIOChannel *ioc)
+ {
+- return qemu_file_new_impl(ioc, false);
++ return qemu_file_new_impl(ioc, false, DEFAULT_IO_BUF_SIZE);
+}
+
++QEMUFile *qemu_file_new_input_sized(QIOChannel *ioc, size_t buffer_size)
++{
++ return qemu_file_new_impl(ioc, false, buffer_size);
+ }
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
- {
-@@ -350,7 +359,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
+@@ -393,7 +408,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
+ do {
+ len = qio_channel_read(f->ioc,
+ (char *)f->buf + pending,
+- IO_BUF_SIZE - pending,
++ f->buf_allocated_size - pending,
+ &local_error);
+ if (len == QIO_CHANNEL_ERR_BLOCK) {
+ if (qemu_in_coroutine()) {
+@@ -443,6 +458,8 @@ int qemu_fclose(QEMUFile *f)
}
+ g_clear_pointer(&f->ioc, object_unref);
- len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
-- IO_BUF_SIZE - pending, &local_error);
-+ f->buf_allocated_size - pending, &local_error);
- if (len > 0) {
- f->buf_size += len;
- f->pos += len;
-@@ -390,6 +399,9 @@ int qemu_fclose(QEMUFile *f)
- ret = ret2;
- }
- }
-+
+ free(f->buf);
+
/* If any error was spotted before closing, we should report it
* instead of the close() return value.
*/
-@@ -444,7 +456,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
+@@ -497,7 +514,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
{
if (!add_to_iovec(f, f->buf + f->buf_index, len, false)) {
f->buf_index += len;
@@ -96,7 +121,7 @@ index 1479cddad9..21a3355ae2 100644
qemu_fflush(f);
}
}
-@@ -470,7 +482,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
+@@ -523,7 +540,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
}
while (size > 0) {
@@ -105,7 +130,7 @@ index 1479cddad9..21a3355ae2 100644
if (l > size) {
l = size;
}
-@@ -517,8 +529,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
+@@ -570,8 +587,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
size_t index;
assert(!qemu_file_is_writable(f));
@@ -116,7 +141,7 @@ index 1479cddad9..21a3355ae2 100644
/* The 1st byte to read from */
index = f->buf_index + offset;
-@@ -568,7 +580,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -621,7 +638,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
size_t res;
uint8_t *src;
@@ -125,7 +150,7 @@ index 1479cddad9..21a3355ae2 100644
if (res == 0) {
return done;
}
-@@ -602,7 +614,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -655,7 +672,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
*/
size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size)
{
@@ -134,7 +159,7 @@ index 1479cddad9..21a3355ae2 100644
size_t res;
uint8_t *src = NULL;
-@@ -627,7 +639,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
+@@ -680,7 +697,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
int index = f->buf_index + offset;
assert(!qemu_file_is_writable(f));
@@ -143,7 +168,7 @@ index 1479cddad9..21a3355ae2 100644
if (index >= f->buf_size) {
qemu_fill_buffer(f);
-@@ -779,7 +791,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
+@@ -832,7 +849,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
const uint8_t *p, size_t size)
{
@@ -153,36 +178,39 @@ index 1479cddad9..21a3355ae2 100644
if (blen < compressBound(size)) {
return -1;
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
-index 3f36d4dc8c..67501fd9cf 100644
+index fa13d04d78..914f1a63a8 100644
--- a/migration/qemu-file.h
+++ b/migration/qemu-file.h
-@@ -121,6 +121,7 @@ typedef struct QEMUFileHooks {
+@@ -63,7 +63,9 @@ typedef struct QEMUFileHooks {
} QEMUFileHooks;
- QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc);
-+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size);
+ QEMUFile *qemu_file_new_input(QIOChannel *ioc);
++QEMUFile *qemu_file_new_input_sized(QIOChannel *ioc, size_t buffer_size);
+ QEMUFile *qemu_file_new_output(QIOChannel *ioc);
++QEMUFile *qemu_file_new_output_sized(QIOChannel *ioc, size_t buffer_size);
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
- int qemu_get_fd(QEMUFile *f);
int qemu_fclose(QEMUFile *f);
+
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
-index b9a43c56bc..0bc5799cf8 100644
+index b3692739a0..e65a5e3482 100644
--- a/migration/savevm-async.c
+++ b/migration/savevm-async.c
-@@ -420,7 +420,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
- goto restart;
- }
+@@ -367,7 +367,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
-- snap_state.file = qemu_fopen_ops(&snap_state, &block_file_ops);
-+ snap_state.file = qemu_fopen_ops_sized(&snap_state, &block_file_ops, false, 4 * 1024 * 1024);
+ QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target,
+ &snap_state.bs_pos));
+- snap_state.file = qemu_file_new_output(ioc);
++ snap_state.file = qemu_file_new_output_sized(ioc, 4 * 1024 * 1024);
if (!snap_state.file) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
-@@ -573,7 +573,7 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
+@@ -500,7 +500,8 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
blk_op_block_all(be, blocker);
/* restore the VM state */
-- f = qemu_fopen_ops(be, &loadstate_file_ops);
-+ f = qemu_fopen_ops_sized(be, &loadstate_file_ops, false, 4 * 1024 * 1024);
+- f = qemu_file_new_input(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)));
++ f = qemu_file_new_input_sized(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)),
++ 4 * 1024 * 1024);
if (!f) {
error_setg(errp, "Could not open VM state file");
goto the_end;
diff --git a/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch b/debian/patches/pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
similarity index 99%
rename from debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
rename to debian/patches/pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
index a0cc957..8f53db4 100644
--- a/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
+++ b/debian/patches/pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
@@ -13,7 +13,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
create mode 100644 block/zeroinit.c
diff --git a/block/meson.build b/block/meson.build
-index 0b2a60c99b..9451fc3ccd 100644
+index 60bc305597..ad40c10b6a 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -43,6 +43,7 @@ block_ss.add(files(
diff --git a/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch b/debian/patches/pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
similarity index 86%
rename from debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
rename to debian/patches/pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
index 488a70c..f0b18f5 100644
--- a/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
+++ b/debian/patches/pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
@@ -14,12 +14,12 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 11 insertions(+)
diff --git a/qemu-options.hx b/qemu-options.hx
-index aeade4ef80..a26f0b0400 100644
+index c2ca6e91b5..ab4734ef32 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -1075,6 +1075,9 @@ DEFHEADING()
+@@ -1118,6 +1118,9 @@ backend describes how QEMU handles the data.
- DEFHEADING(Block device options:)
+ ERST
+DEF("id", HAS_ARG, QEMU_OPTION_id,
+ "-id n set the VMID", QEMU_ARCH_ALL)
@@ -28,10 +28,10 @@ index aeade4ef80..a26f0b0400 100644
"-fda/-fdb file use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL)
DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL)
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index a3f2a3818c..4208142685 100644
+index b8637c4262..39f149924e 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -2785,6 +2785,7 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -2620,6 +2620,7 @@ void qemu_init(int argc, char **argv, char **envp)
MachineClass *machine_class;
bool userconfig = true;
FILE *vmstate_dump_file = NULL;
@@ -39,7 +39,7 @@ index a3f2a3818c..4208142685 100644
qemu_add_opts(&qemu_drive_opts);
qemu_add_drive_opts(&qemu_legacy_drive_opts);
-@@ -3420,6 +3421,13 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3245,6 +3246,13 @@ void qemu_init(int argc, char **argv, char **envp)
machine_parse_property_opt(qemu_find_opts("smp-opts"),
"smp", optarg);
break;
diff --git a/debian/patches/pve/0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch b/debian/patches/pve/0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
similarity index 100%
rename from debian/patches/pve/0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
rename to debian/patches/pve/0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
diff --git a/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch b/debian/patches/pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
similarity index 90%
rename from debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
rename to debian/patches/pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
index 99299d3..96b0193 100644
--- a/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+++ b/debian/patches/pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
@@ -13,10 +13,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index e5bf5d59bf..b013668dce 100644
+index 3d60b80286..49ee1db5f9 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -2461,6 +2461,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2475,6 +2475,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
int fd;
uint64_t perm, shared;
int result = 0;
@@ -24,7 +24,7 @@ index e5bf5d59bf..b013668dce 100644
/* Validate options and set default values */
assert(options->driver == BLOCKDEV_DRIVER_FILE);
-@@ -2501,19 +2502,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2515,19 +2516,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
perm = BLK_PERM_WRITE | BLK_PERM_RESIZE;
shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
@@ -59,7 +59,7 @@ index e5bf5d59bf..b013668dce 100644
}
/* Clear the file by truncating it to 0 */
-@@ -2567,13 +2571,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2581,13 +2585,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
}
out_unlock:
@@ -82,7 +82,7 @@ index e5bf5d59bf..b013668dce 100644
}
out_close:
-@@ -2598,6 +2604,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2612,6 +2618,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
PreallocMode prealloc;
char *buf = NULL;
Error *local_err = NULL;
@@ -90,7 +90,7 @@ index e5bf5d59bf..b013668dce 100644
/* Skip file: protocol prefix */
strstart(filename, "file:", &filename);
-@@ -2620,6 +2627,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2634,6 +2641,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
return -EINVAL;
}
@@ -109,7 +109,7 @@ index e5bf5d59bf..b013668dce 100644
options = (BlockdevCreateOptions) {
.driver = BLOCKDEV_DRIVER_FILE,
.u.file = {
-@@ -2631,6 +2650,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2645,6 +2664,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
.nocow = nocow,
.has_extent_size_hint = has_extent_size_hint,
.extent_size_hint = extent_size_hint,
@@ -119,10 +119,10 @@ index e5bf5d59bf..b013668dce 100644
};
return raw_co_create(&options, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index fb25c2b245..564b6b43f7 100644
+index e1857e7094..ddac91e8f6 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -4484,7 +4484,8 @@
+@@ -4537,7 +4537,8 @@
'size': 'size',
'*preallocation': 'PreallocMode',
'*nocow': 'bool',
diff --git a/debian/patches/pve/0022-PVE-monitor-disable-oob-capability.patch b/debian/patches/pve/0023-PVE-monitor-disable-oob-capability.patch
similarity index 100%
rename from debian/patches/pve/0022-PVE-monitor-disable-oob-capability.patch
rename to debian/patches/pve/0023-PVE-monitor-disable-oob-capability.patch
diff --git a/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch b/debian/patches/pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
similarity index 95%
rename from debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
rename to debian/patches/pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
index 61528fd..72f29ff 100644
--- a/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
+++ b/debian/patches/pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
@@ -26,10 +26,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
-index 1e23fdc14b..8a50445ee8 100644
+index a673302cce..fa424440bd 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
-@@ -118,7 +118,8 @@ GlobalProperty hw_compat_4_0[] = {
+@@ -127,7 +127,8 @@ GlobalProperty hw_compat_4_0[] = {
{ "virtio-vga", "edid", "false" },
{ "virtio-gpu-device", "edid", "false" },
{ "virtio-device", "use-started", "false" },
diff --git a/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch b/debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
similarity index 93%
rename from debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
rename to debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
index a0ca907..67fd0f6 100644
--- a/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
+++ b/debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
@@ -36,7 +36,7 @@ index 76fff60a6b..ec9201fb9a 100644
if (mc->default_cpu_type) {
diff --git a/include/hw/boards.h b/include/hw/boards.h
-index c92ac8815c..572d911ed4 100644
+index 7b416c9787..8ae15c51aa 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -230,6 +230,8 @@ struct MachineClass {
@@ -49,10 +49,10 @@ index c92ac8815c..572d911ed4 100644
void (*reset)(MachineState *state);
void (*wakeup)(MachineState *state);
diff --git a/qapi/machine.json b/qapi/machine.json
-index ca133e68ce..39ba204b52 100644
+index 555458f785..d868e4d31d 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -158,6 +158,8 @@
+@@ -157,6 +157,8 @@
#
# @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
#
@@ -61,7 +61,7 @@ index ca133e68ce..39ba204b52 100644
# Since: 1.2
##
{ 'struct': 'MachineInfo',
-@@ -165,7 +167,7 @@
+@@ -164,7 +166,7 @@
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
'deprecated': 'bool', '*default-cpu-type': 'str',
@@ -71,10 +71,10 @@ index ca133e68ce..39ba204b52 100644
##
# @query-machines:
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 4208142685..37d85f1b96 100644
+index 39f149924e..0d233d55f3 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -1659,6 +1659,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
+@@ -1580,6 +1580,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
static MachineClass *select_machine(QDict *qdict, Error **errp)
{
const char *optarg = qdict_get_try_str(qdict, "type");
@@ -82,7 +82,7 @@ index 4208142685..37d85f1b96 100644
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
MachineClass *machine_class;
Error *local_err = NULL;
-@@ -1676,6 +1677,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
+@@ -1597,6 +1598,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
}
}
@@ -94,7 +94,7 @@ index 4208142685..37d85f1b96 100644
g_slist_free(machines);
if (local_err) {
error_append_hint(&local_err, "Use -machine help to list supported machines\n");
-@@ -3362,12 +3368,31 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3187,12 +3193,31 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_machine:
{
bool help;
diff --git a/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch b/debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
similarity index 88%
rename from debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
rename to debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
index 8621cdf..a1ce276 100644
--- a/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
+++ b/debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
@@ -25,11 +25,11 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/backup.c b/block/backup.c
-index 5cfd0b999c..07b899035c 100644
+index b2b649e305..b6fa9e8a69 100644
--- a/block/backup.c
+++ b/block/backup.c
-@@ -239,8 +239,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
- assert(ret);
+@@ -237,8 +237,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
+ true);
} else if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
/*
- * We can't hog the coroutine to initialize this thoroughly.
@@ -39,7 +39,7 @@ index 5cfd0b999c..07b899035c 100644
*/
block_copy_set_skip_unallocated(job->bcs, true);
}
-@@ -254,8 +254,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
+@@ -252,8 +252,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
int ret;
@@ -48,7 +48,7 @@ index 5cfd0b999c..07b899035c 100644
if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
int64_t offset = 0;
int64_t count;
-@@ -494,6 +492,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
+@@ -492,6 +490,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
&error_abort);
diff --git a/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
similarity index 99%
rename from debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch
rename to debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
index ced8e74..cf67937 100644
--- a/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch
+++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
@@ -9,18 +9,18 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
block/meson.build | 2 +
meson.build | 5 +
- vma-reader.c | 860 ++++++++++++++++++++++++++++++++++++++++++++++
+ vma-reader.c | 859 ++++++++++++++++++++++++++++++++++++++++++++++
vma-writer.c | 791 ++++++++++++++++++++++++++++++++++++++++++
- vma.c | 850 +++++++++++++++++++++++++++++++++++++++++++++
+ vma.c | 849 +++++++++++++++++++++++++++++++++++++++++++++
vma.h | 150 ++++++++
- 6 files changed, 2658 insertions(+)
+ 6 files changed, 2656 insertions(+)
create mode 100644 vma-reader.c
create mode 100644 vma-writer.c
create mode 100644 vma.c
create mode 100644 vma.h
diff --git a/block/meson.build b/block/meson.build
-index 9451fc3ccd..819eb80951 100644
+index ad40c10b6a..3a0b84bc11 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -46,6 +46,8 @@ block_ss.add(files(
@@ -33,10 +33,10 @@ index 9451fc3ccd..819eb80951 100644
if get_option('qcow1').allowed()
diff --git a/meson.build b/meson.build
-index 861de93c4f..96a91b95e4 100644
+index d5230eadd6..ffff66c0cc 100644
--- a/meson.build
+++ b/meson.build
-@@ -1267,6 +1267,8 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1462,6 +1462,8 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
@@ -45,7 +45,7 @@ index 861de93c4f..96a91b95e4 100644
# libselinux
selinux = dependency('libselinux',
required: get_option('selinux'),
-@@ -3359,6 +3361,9 @@ if have_tools
+@@ -3607,6 +3609,9 @@ if have_tools
dependencies: [blockdev, qemuutil, gnutls, selinux],
install: true)
@@ -57,10 +57,10 @@ index 861de93c4f..96a91b95e4 100644
subdir('contrib/elf2dmp')
diff --git a/vma-reader.c b/vma-reader.c
new file mode 100644
-index 0000000000..4f4ee2b47b
+index 0000000000..e65f1e8415
--- /dev/null
+++ b/vma-reader.c
-@@ -0,0 +1,860 @@
+@@ -0,0 +1,859 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -78,7 +78,6 @@ index 0000000000..4f4ee2b47b
+#include <glib.h>
+#include <uuid/uuid.h>
+
-+#include "qemu-common.h"
+#include "qemu/timer.h"
+#include "qemu/ratelimit.h"
+#include "vma.h"
@@ -589,7 +588,7 @@ index 0000000000..4f4ee2b47b
+ }
+ }
+ } else {
-+ int res = blk_pwrite(target, sector_num * BDRV_SECTOR_SIZE, buf, nb_sectors * BDRV_SECTOR_SIZE, 0);
++ int res = blk_pwrite(target, sector_num * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE, buf, 0);
+ if (res < 0) {
+ error_setg(errp, "blk_pwrite to %s failed (%d)",
+ bdrv_get_device_name(blk_bs(target)), res);
@@ -1720,10 +1719,10 @@ index 0000000000..df4b20793d
+}
diff --git a/vma.c b/vma.c
new file mode 100644
-index 0000000000..91612d50a2
+index 0000000000..e8dffb43e0
--- /dev/null
+++ b/vma.c
-@@ -0,0 +1,850 @@
+@@ -0,0 +1,849 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -1741,7 +1740,6 @@ index 0000000000..91612d50a2
+#include <glib.h>
+
+#include "vma.h"
-+#include "qemu-common.h"
+#include "qemu/module.h"
+#include "qemu/error-report.h"
+#include "qemu/main-loop.h"
diff --git a/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch b/debian/patches/pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
similarity index 96%
rename from debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
rename to debian/patches/pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
index ea3bb84..548ce20 100644
--- a/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
+++ b/debian/patches/pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
@@ -10,20 +10,20 @@ Subject: [PATCH] PVE-Backup: add backup-dump block driver
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
- block/backup-dump.c | 168 +++++++++++++++++++++++++++++++
+ block/backup-dump.c | 167 +++++++++++++++++++++++++++++++
block/backup.c | 30 ++----
block/meson.build | 1 +
include/block/block_int-common.h | 35 +++++++
job.c | 3 +-
- 5 files changed, 214 insertions(+), 23 deletions(-)
+ 5 files changed, 213 insertions(+), 23 deletions(-)
create mode 100644 block/backup-dump.c
diff --git a/block/backup-dump.c b/block/backup-dump.c
new file mode 100644
-index 0000000000..93d7f46950
+index 0000000000..04718a94e2
--- /dev/null
+++ b/block/backup-dump.c
-@@ -0,0 +1,168 @@
+@@ -0,0 +1,167 @@
+/*
+ * BlockDriver to send backup data stream to a callback function
+ *
@@ -35,7 +35,6 @@ index 0000000000..93d7f46950
+ */
+
+#include "qemu/osdep.h"
-+#include "qemu-common.h"
+#include "qom/object_interfaces.h"
+#include "block/block_int.h"
+
@@ -193,7 +192,7 @@ index 0000000000..93d7f46950
+ return bs;
+}
diff --git a/block/backup.c b/block/backup.c
-index 07b899035c..7b5d02f580 100644
+index b6fa9e8a69..789f8b7799 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -29,28 +29,6 @@
@@ -225,7 +224,7 @@ index 07b899035c..7b5d02f580 100644
static const BlockJobDriver backup_job_driver;
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
-@@ -456,6 +434,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
+@@ -454,6 +432,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
}
cluster_size = block_copy_cluster_size(bcs);
@@ -241,7 +240,7 @@ index 07b899035c..7b5d02f580 100644
if (perf->max_chunk && perf->max_chunk < cluster_size) {
error_setg(errp, "Required max-chunk (%" PRIi64 ") is less than backup "
diff --git a/block/meson.build b/block/meson.build
-index 819eb80951..067708b7c0 100644
+index 3a0b84bc11..7f22e7f177 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -4,6 +4,7 @@ block_ss.add(files(
diff --git a/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch b/debian/patches/pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
similarity index 98%
rename from debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
rename to debian/patches/pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
index faa9483..58bc045 100644
--- a/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
+++ b/debian/patches/pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
@@ -30,7 +30,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
create mode 100644 pve-backup.c
diff --git a/block/meson.build b/block/meson.build
-index 067708b7c0..42aac96dbb 100644
+index 7f22e7f177..2783b77e9c 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -48,6 +48,11 @@ block_ss.add(files(
@@ -87,7 +87,7 @@ index bfb3c043a0..89ca64444d 100644
+ hmp_handle_error(mon, error);
+}
diff --git a/blockdev.c b/blockdev.c
-index 1af5a1fcb2..9916a72334 100644
+index ce62a9b439..1600b24eab 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -36,6 +36,7 @@
@@ -99,7 +99,7 @@ index 1af5a1fcb2..9916a72334 100644
#include "monitor/monitor.h"
#include "qemu/error-report.h"
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index 925e680e5a..d9b787d2c6 100644
+index 97b88eaaad..92a8867afb 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -484,6 +484,20 @@ SRST
@@ -124,10 +124,10 @@ index 925e680e5a..d9b787d2c6 100644
{
.name = "usernet",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 7f0ac498c4..994445f301 100644
+index bbcc73e942..97f24942b3 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
-@@ -99,6 +99,35 @@ ERST
+@@ -101,6 +101,35 @@ ERST
SRST
``block_stream``
Copy data from a backing file into a block device.
@@ -164,7 +164,7 @@ index 7f0ac498c4..994445f301 100644
{
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
-index 3a39ba41b5..d269b4c99c 100644
+index 55067beff1..5a98d2d927 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -30,6 +30,7 @@ void hmp_info_savevm(Monitor *mon, const QDict *qdict);
@@ -185,10 +185,10 @@ index 3a39ba41b5..d269b4c99c 100644
void hmp_device_add(Monitor *mon, const QDict *qdict);
void hmp_device_del(Monitor *mon, const QDict *qdict);
diff --git a/meson.build b/meson.build
-index 96a91b95e4..76fcb23299 100644
+index ffff66c0cc..0bc2fb5b10 100644
--- a/meson.build
+++ b/meson.build
-@@ -1268,6 +1268,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1463,6 +1463,7 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
libuuid = cc.find_library('uuid', required: true)
@@ -197,10 +197,10 @@ index 96a91b95e4..76fcb23299 100644
# libselinux
selinux = dependency('libselinux',
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index c64b959738..ef654221c4 100644
+index 1507180990..1168773da7 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -195,6 +195,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
+@@ -197,6 +197,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
qapi_free_MouseInfoList(mice_list);
}
@@ -1464,12 +1464,12 @@ index 0000000000..88f5ee133f
+ return info;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 564b6b43f7..ffcc25367b 100644
+index ddac91e8f6..90ad07b7ee 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -744,6 +744,115 @@
- { 'command': 'query-block', 'returns': ['BlockInfo'] }
-
+@@ -740,6 +740,115 @@
+ { 'command': 'query-block', 'returns': ['BlockInfo'],
+ 'allow-preconfig': true }
+##
+# @BackupStatus:
@@ -1584,10 +1584,10 @@ index 564b6b43f7..ffcc25367b 100644
# @BlockDeviceTimedStats:
#
diff --git a/qapi/common.json b/qapi/common.json
-index 412cc4f5ae..3e7a77ea66 100644
+index 356db3f670..aae8a3b682 100644
--- a/qapi/common.json
+++ b/qapi/common.json
-@@ -208,3 +208,16 @@
+@@ -206,3 +206,16 @@
##
{ 'struct': 'HumanReadableText',
'data': { 'human-readable-text': 'str' } }
@@ -1605,7 +1605,7 @@ index 412cc4f5ae..3e7a77ea66 100644
+##
+{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
diff --git a/qapi/machine.json b/qapi/machine.json
-index 39ba204b52..091aafeff7 100644
+index d868e4d31d..a63d9a078d 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -4,6 +4,8 @@
@@ -1617,7 +1617,7 @@ index 39ba204b52..091aafeff7 100644
##
# = Machines
##
-@@ -227,19 +229,6 @@
+@@ -226,19 +228,6 @@
##
{ 'command': 'query-target', 'returns': 'TargetInfo' }
diff --git a/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch b/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
similarity index 95%
rename from debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
rename to debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
index f1c77cb..6c61992 100644
--- a/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
+++ b/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
@@ -7,15 +7,15 @@ Subject: [PATCH] PVE-Backup: pbs-restore - new command to restore from proxmox
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
meson.build | 4 +
- pbs-restore.c | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 228 insertions(+)
+ pbs-restore.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 227 insertions(+)
create mode 100644 pbs-restore.c
diff --git a/meson.build b/meson.build
-index 76fcb23299..9476ccbe07 100644
+index 0bc2fb5b10..f48d2e0457 100644
--- a/meson.build
+++ b/meson.build
-@@ -3365,6 +3365,10 @@ if have_tools
+@@ -3613,6 +3613,10 @@ if have_tools
vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
dependencies: [authz, block, crypto, io, qom], install: true)
@@ -28,10 +28,10 @@ index 76fcb23299..9476ccbe07 100644
subdir('contrib/elf2dmp')
diff --git a/pbs-restore.c b/pbs-restore.c
new file mode 100644
-index 0000000000..4d3f925a1b
+index 0000000000..2f834cf42e
--- /dev/null
+++ b/pbs-restore.c
-@@ -0,0 +1,224 @@
+@@ -0,0 +1,223 @@
+/*
+ * Qemu image restore helper for Proxmox Backup
+ *
@@ -50,7 +50,6 @@ index 0000000000..4d3f925a1b
+#include <getopt.h>
+#include <string.h>
+
-+#include "qemu-common.h"
+#include "qemu/module.h"
+#include "qemu/error-report.h"
+#include "qemu/main-loop.h"
@@ -96,7 +95,7 @@ index 0000000000..4d3f925a1b
+ }
+ res = blk_pwrite_zeroes(callback_data->target, offset, data_len, 0);
+ } else {
-+ res = blk_pwrite(callback_data->target, offset, data, data_len, 0);
++ res = blk_pwrite(callback_data->target, offset, data_len, data, 0);
+ }
+
+ if (res < 0) {
diff --git a/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch b/debian/patches/pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
similarity index 98%
rename from debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
rename to debian/patches/pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
index 012c0b3..8d37565 100644
--- a/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
+++ b/debian/patches/pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
@@ -41,10 +41,10 @@ index 89ca64444d..45da74d7a0 100644
false, NULL, false, NULL, !!devlist,
devlist, qdict_haskey(qdict, "speed"), speed, &error);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index ef654221c4..c5c74ac1dc 100644
+index 1168773da7..4c1671e289 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -221,19 +221,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
+@@ -223,19 +223,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "End time: %s", ctime(&info->end_time));
}
@@ -405,10 +405,10 @@ index 88f5ee133f..1c49cd178d 100644
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index ffcc25367b..b332d8a8da 100644
+index 90ad07b7ee..3ad9eb5d1a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -757,8 +757,13 @@
+@@ -753,8 +753,13 @@
#
# @total: total amount of bytes involved in the backup process
#
@@ -422,7 +422,7 @@ index ffcc25367b..b332d8a8da 100644
# @zero-bytes: amount of 'zero' bytes detected.
#
# @start-time: time (epoch) when backup job started.
-@@ -771,8 +776,8 @@
+@@ -767,8 +772,8 @@
#
##
{ 'struct': 'BackupStatus',
@@ -433,7 +433,7 @@ index ffcc25367b..b332d8a8da 100644
'*start-time': 'int', '*end-time': 'int',
'*backup-file': 'str', '*uuid': 'str' } }
-@@ -815,6 +820,8 @@
+@@ -811,6 +816,8 @@
#
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
#
@@ -442,7 +442,7 @@ index ffcc25367b..b332d8a8da 100644
# Returns: the uuid of the backup job
#
##
-@@ -825,6 +832,7 @@
+@@ -821,6 +828,7 @@
'*fingerprint': 'str',
'*backup-id': 'str',
'*backup-time': 'int',
diff --git a/debian/patches/pve/0031-PVE-various-PBS-fixes.patch b/debian/patches/pve/0032-PVE-various-PBS-fixes.patch
similarity index 99%
rename from debian/patches/pve/0031-PVE-various-PBS-fixes.patch
rename to debian/patches/pve/0032-PVE-various-PBS-fixes.patch
index e5ebc18..3bd8426 100644
--- a/debian/patches/pve/0031-PVE-various-PBS-fixes.patch
+++ b/debian/patches/pve/0032-PVE-various-PBS-fixes.patch
@@ -194,10 +194,10 @@ index 1c49cd178d..c15abefdda 100644
.format = format,
.has_config_file = has_config_file,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index b332d8a8da..abef91062a 100644
+index 3ad9eb5d1a..4120052690 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -822,6 +822,10 @@
+@@ -818,6 +818,10 @@
#
# @use-dirty-bitmap: use dirty bitmap to detect incremental changes since last job (optional for format 'pbs')
#
@@ -208,7 +208,7 @@ index b332d8a8da..abef91062a 100644
# Returns: the uuid of the backup job
#
##
-@@ -833,6 +837,8 @@
+@@ -829,6 +833,8 @@
'*backup-id': 'str',
'*backup-time': 'int',
'*use-dirty-bitmap': 'bool',
diff --git a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch b/debian/patches/pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
similarity index 91%
rename from debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
rename to debian/patches/pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
index 3b08ed1..9a850c0 100644
--- a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+++ b/debian/patches/pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
@@ -13,13 +13,13 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
block/meson.build | 3 +
block/pbs.c | 276 +++++++++++++++++++++++++++++++++++++++++++
configure | 9 ++
- meson.build | 1 +
+ meson.build | 2 +-
qapi/block-core.json | 13 ++
- 5 files changed, 302 insertions(+)
+ 5 files changed, 302 insertions(+), 1 deletion(-)
create mode 100644 block/pbs.c
diff --git a/block/meson.build b/block/meson.build
-index 42aac96dbb..f94cc0cd25 100644
+index 2783b77e9c..a26a69434e 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -53,6 +53,9 @@ block_ss.add(files(
@@ -315,63 +315,64 @@ index 0000000000..0b05ea9080
+
+block_init(bdrv_pbs_init);
diff --git a/configure b/configure
-index 7c08c18358..08d164b4f5 100755
+index 72ab03f11a..7203c270ec 100755
--- a/configure
+++ b/configure
-@@ -325,6 +325,7 @@ trace_file="trace"
- opengl="$default_feature"
+@@ -309,6 +309,7 @@ linux_user=""
+ bsd_user=""
+ pie=""
coroutine=""
- tls_priority="NORMAL"
+pbs_bdrv="yes"
plugins="$default_feature"
- secret_keyring="$default_feature"
meson=""
-@@ -991,6 +992,10 @@ for opt do
- ;;
- --disable-pvrdma) pvrdma="no"
+ meson_args=""
+@@ -902,6 +903,10 @@ for opt do
+ --enable-uuid|--disable-uuid)
+ echo "$0: $opt is obsolete, UUID support is always built" >&2
;;
+ --disable-pbs-bdrv) pbs_bdrv="no"
+ ;;
+ --enable-pbs-bdrv) pbs_bdrv="yes"
+ ;;
- --disable-vhost-user) vhost_user="no"
+ --with-git=*) git="$optarg"
;;
- --enable-vhost-user) vhost_user="yes"
-@@ -1265,6 +1270,7 @@ cat << EOF
- vhost-user vhost-user backend support
- vhost-vdpa vhost-vdpa kernel backend support
- opengl opengl support
+ --with-git-submodules=*)
+@@ -1087,6 +1092,7 @@ cat << EOF
+ debug-info debugging information
+ safe-stack SafeStack Stack Smash Protection. Depends on
+ clang/llvm >= 3.7 and requires coroutine backend ucontext.
+ pbs-bdrv Proxmox backup server read-only block driver support
- gio libgio support
NOTE: The object files are built at the place where configure is launched
-@@ -2848,6 +2854,9 @@ if test "$xen" = "enabled" ; then
- echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
- echo "XEN_LIBS=$xen_libs" >> $config_host_mak
+ EOF
+@@ -2463,6 +2469,9 @@ echo "TARGET_DIRS=$target_list" >> $config_host_mak
+ if test "$modules" = "yes"; then
+ echo "CONFIG_MODULES=y" >> $config_host_mak
fi
+if test "$pbs_bdrv" = "yes" ; then
+ echo "CONFIG_PBS_BDRV=y" >> $config_host_mak
+fi
- if test "$vhost_scsi" = "yes" ; then
- echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
- fi
+
+ # XXX: suppress that
+ if [ "$bsd" = "yes" ] ; then
diff --git a/meson.build b/meson.build
-index 9476ccbe07..d3783a83e4 100644
+index f48d2e0457..be4785e2f6 100644
--- a/meson.build
+++ b/meson.build
-@@ -3743,6 +3743,7 @@ summary_info += {'bzip2 support': libbzip2}
+@@ -3986,7 +3986,7 @@ summary_info += {'bzip2 support': libbzip2}
summary_info += {'lzfse support': liblzfse}
summary_info += {'zstd support': zstd}
summary_info += {'NUMA host support': numa}
+-summary_info += {'capstone': capstone}
+summary_info += {'PBS bdrv support': config_host.has_key('CONFIG_PBS_BDRV')}
- summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
summary_info += {'libpmem support': libpmem}
summary_info += {'libdaxctl support': libdaxctl}
+ summary_info += {'libudev': libudev}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index abef91062a..68591cb343 100644
+index 4120052690..96bc696aaa 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3073,6 +3073,7 @@
+@@ -3099,6 +3099,7 @@
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
@@ -379,7 +380,7 @@ index abef91062a..68591cb343 100644
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
##
-@@ -3145,6 +3146,17 @@
+@@ -3171,6 +3172,17 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -397,7 +398,7 @@ index abef91062a..68591cb343 100644
##
# @BlockdevOptionsNVMe:
#
-@@ -4405,6 +4417,7 @@
+@@ -4455,6 +4467,7 @@
'nfs': 'BlockdevOptionsNfs',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
diff --git a/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch b/debian/patches/pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
similarity index 97%
rename from debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
rename to debian/patches/pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
index 0f1f0c6..dbcef29 100644
--- a/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
+++ b/debian/patches/pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
@@ -33,10 +33,10 @@ index c15abefdda..4684789813 100644
+ return ret;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 68591cb343..7d25aa4fa1 100644
+index 96bc696aaa..0b453c61d4 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -867,6 +867,35 @@
+@@ -863,6 +863,35 @@
##
{ 'command': 'backup-cancel' }
diff --git a/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch b/debian/patches/pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
similarity index 98%
rename from debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
rename to debian/patches/pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
index d3ba75c..29a96d1 100644
--- a/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
+++ b/debian/patches/pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
@@ -15,10 +15,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 159 insertions(+), 42 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index c5c74ac1dc..df273f41fb 100644
+index 4c1671e289..c1152f55a7 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -198,6 +198,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
+@@ -200,6 +200,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
void hmp_info_backup(Monitor *mon, const QDict *qdict)
{
BackupStatus *info;
@@ -26,7 +26,7 @@ index c5c74ac1dc..df273f41fb 100644
info = qmp_query_backup(NULL);
-@@ -228,26 +229,29 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
+@@ -230,26 +231,29 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
// this should not happen normally
monitor_printf(mon, "Total size: %d\n", 0);
} else {
@@ -359,10 +359,10 @@ index 4684789813..f90abaa50a 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 7d25aa4fa1..69571d86eb 100644
+index 0b453c61d4..16e184dd28 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -875,6 +875,8 @@
+@@ -871,6 +871,8 @@
# @pbs-dirty-bitmap: True if dirty-bitmap-incremental backups to PBS are
# supported.
#
@@ -371,7 +371,7 @@ index 7d25aa4fa1..69571d86eb 100644
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
# safely be set for savevm-async.
#
-@@ -883,6 +885,7 @@
+@@ -879,6 +881,7 @@
##
{ 'struct': 'ProxmoxSupportStatus',
'data': { 'pbs-dirty-bitmap': 'bool',
@@ -379,7 +379,7 @@ index 7d25aa4fa1..69571d86eb 100644
'pbs-dirty-bitmap-savevm': 'bool',
'pbs-library-version': 'str' } }
-@@ -896,6 +899,59 @@
+@@ -892,6 +895,59 @@
##
{ 'command': 'query-proxmox-support', 'returns': 'ProxmoxSupportStatus' }
diff --git a/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch b/debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
similarity index 86%
rename from debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
rename to debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
index 89727a4..c5be26b 100644
--- a/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
+++ b/debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
-index d3783a83e4..715245ba20 100644
+index be4785e2f6..3fc7c8d435 100644
--- a/meson.build
+++ b/meson.build
-@@ -1268,6 +1268,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1463,6 +1463,7 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
libuuid = cc.find_library('uuid', required: true)
@@ -25,7 +25,7 @@ index d3783a83e4..715245ba20 100644
libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
# libselinux
-@@ -2861,6 +2862,7 @@ if have_block
+@@ -3105,6 +3106,7 @@ if have_block
# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
# os-win32.c does not
blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
@@ -34,7 +34,7 @@ index d3783a83e4..715245ba20 100644
endif
diff --git a/os-posix.c b/os-posix.c
-index 24692c8593..d1bc5ac12d 100644
+index 321fc4bd13..b1870d2690 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -28,6 +28,8 @@
@@ -44,15 +44,15 @@ index 24692c8593..d1bc5ac12d 100644
+#include <systemd/sd-journal.h>
+#include <syslog.h>
- #include "qemu-common.h"
/* Needed early for CONFIG_BSD etc. */
-@@ -291,9 +293,10 @@ void os_setup_post(void)
+ #include "net/slirp.h"
+@@ -281,9 +283,10 @@ void os_setup_post(void)
dup2(fd, 0);
dup2(fd, 1);
- /* In case -D is given do not redirect stderr to /dev/null */
+ /* In case -D is given do not redirect stderr to journal */
- if (!qemu_logfile) {
+ if (!qemu_log_enabled()) {
- dup2(fd, 2);
+ int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0);
+ dup2(journal_fd, 2);
diff --git a/debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch b/debian/patches/pve/0037-PVE-Add-sequential-job-transaction-support.patch
similarity index 100%
rename from debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch
rename to debian/patches/pve/0037-PVE-Add-sequential-job-transaction-support.patch
diff --git a/debian/patches/pve/0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch b/debian/patches/pve/0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
similarity index 100%
rename from debian/patches/pve/0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
rename to debian/patches/pve/0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
diff --git a/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch b/debian/patches/pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
similarity index 99%
rename from debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
rename to debian/patches/pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
index 51a2b53..44c167b 100644
--- a/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
+++ b/debian/patches/pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
@@ -481,10 +481,10 @@ index 63c686463f..6f05796fad 100644
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 69571d86eb..e6c3687bea 100644
+index 16e184dd28..cb17d00fe0 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -774,12 +774,15 @@
+@@ -770,12 +770,15 @@
#
# @uuid: uuid for this backup job
#
diff --git a/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
similarity index 96%
rename from debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
rename to debian/patches/pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
index 36c6d96..e80a716 100644
--- a/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+++ b/debian/patches/pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
@@ -36,11 +36,11 @@ index 465906710d..4f0aeceb6f 100644
+
#endif
diff --git a/migration/meson.build b/migration/meson.build
-index 1e2aec8486..259e863a43 100644
+index 0842d00cd2..d012f4d8d3 100644
--- a/migration/meson.build
+++ b/migration/meson.build
-@@ -7,8 +7,10 @@ migration_files = files(
- 'qemu-file-channel.c',
+@@ -6,8 +6,10 @@ migration_files = files(
+ 'vmstate.c',
'qemu-file.c',
'yank_functions.c',
+ 'pbs-state.c',
@@ -51,10 +51,10 @@ index 1e2aec8486..259e863a43 100644
softmmu_ss.add(files(
'block-dirty-bitmap.c',
diff --git a/migration/migration.c b/migration/migration.c
-index 695f0f2900..6e17f8e91c 100644
+index bb8bbddfe4..8109e468eb 100644
--- a/migration/migration.c
+++ b/migration/migration.c
-@@ -214,6 +214,7 @@ void migration_object_init(void)
+@@ -229,6 +229,7 @@ void migration_object_init(void)
blk_mig_init();
ram_mig_init();
dirty_bitmap_mig_init();
@@ -187,10 +187,10 @@ index 6f05796fad..5fa3cc1352 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index e6c3687bea..05382a1069 100644
+index cb17d00fe0..bd978ea562 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -883,6 +883,11 @@
+@@ -879,6 +879,11 @@
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
# safely be set for savevm-async.
#
@@ -202,7 +202,7 @@ index e6c3687bea..05382a1069 100644
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
#
##
-@@ -890,6 +895,7 @@
+@@ -886,6 +891,7 @@
'data': { 'pbs-dirty-bitmap': 'bool',
'query-bitmap-info': 'bool',
'pbs-dirty-bitmap-savevm': 'bool',
diff --git a/debian/patches/pve/0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch b/debian/patches/pve/0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
similarity index 100%
rename from debian/patches/pve/0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
rename to debian/patches/pve/0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
diff --git a/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch b/debian/patches/pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
similarity index 98%
rename from debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
rename to debian/patches/pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
index c30bb2b..bed3e62 100644
--- a/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
+++ b/debian/patches/pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
@@ -21,7 +21,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 30 insertions(+)
diff --git a/block/iscsi.c b/block/iscsi.c
-index 51f2a5eeaa..f11591ac94 100644
+index d707d0b354..da6ed52323 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1386,12 +1386,42 @@ static char *get_initiator_name(QemuOpts *opts)
diff --git a/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch b/debian/patches/pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
similarity index 99%
rename from debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
rename to debian/patches/pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
index 3de10a6..c07cdce 100644
--- a/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
+++ b/debian/patches/pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
@@ -54,10 +54,10 @@ index ea7b665aa2..ef45552e3b 100644
Error *error = NULL;
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 994445f301..aaea875970 100644
+index 97f24942b3..7a2be816da 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
-@@ -109,6 +109,7 @@ ERST
+@@ -111,6 +111,7 @@ ERST
"\n\t\t\t Use -d to dump data into a directory instead"
"\n\t\t\t of using VMA format.",
.cmd = hmp_backup,
@@ -65,7 +65,7 @@ index 994445f301..aaea875970 100644
},
SRST
-@@ -122,6 +123,7 @@ ERST
+@@ -124,6 +125,7 @@ ERST
.params = "",
.help = "cancel the current VM backup",
.cmd = hmp_backup_cancel,
@@ -575,10 +575,10 @@ index 5fa3cc1352..323014744c 100644
BackupStatus *qmp_query_backup(Error **errp)
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 05382a1069..f0399bf249 100644
+index bd978ea562..ca1966f54b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -846,7 +846,7 @@
+@@ -842,7 +842,7 @@
'*config-file': 'str',
'*firewall-file': 'str',
'*devlist': 'str', '*speed': 'int' },
@@ -587,7 +587,7 @@ index 05382a1069..f0399bf249 100644
##
# @query-backup:
-@@ -868,7 +868,7 @@
+@@ -864,7 +864,7 @@
# Notes: This command succeeds even if there is no backup process running.
#
##
diff --git a/debian/patches/pve/0043-PBS-add-master-key-support.patch b/debian/patches/pve/0044-PBS-add-master-key-support.patch
similarity index 97%
rename from debian/patches/pve/0043-PBS-add-master-key-support.patch
rename to debian/patches/pve/0044-PBS-add-master-key-support.patch
index 356cfd9..1716c05 100644
--- a/debian/patches/pve/0043-PBS-add-master-key-support.patch
+++ b/debian/patches/pve/0044-PBS-add-master-key-support.patch
@@ -58,10 +58,10 @@ index 323014744c..9f6c04a512 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index f0399bf249..13e03ca154 100644
+index ca1966f54b..fc8a125451 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -817,6 +817,8 @@
+@@ -813,6 +813,8 @@
#
# @key-password: password for keyfile (optional for format 'pbs')
#
@@ -70,7 +70,7 @@ index f0399bf249..13e03ca154 100644
# @fingerprint: server cert fingerprint (optional for format 'pbs')
#
# @backup-id: backup ID (required for format 'pbs')
-@@ -836,6 +838,7 @@
+@@ -832,6 +834,7 @@
'*password': 'str',
'*keyfile': 'str',
'*key-password': 'str',
@@ -78,7 +78,7 @@ index f0399bf249..13e03ca154 100644
'*fingerprint': 'str',
'*backup-id': 'str',
'*backup-time': 'int',
-@@ -888,6 +891,9 @@
+@@ -884,6 +887,9 @@
# migration cap if this is false/unset may lead
# to crashes on migration!
#
@@ -88,7 +88,7 @@ index f0399bf249..13e03ca154 100644
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
#
##
-@@ -896,6 +902,7 @@
+@@ -892,6 +898,7 @@
'query-bitmap-info': 'bool',
'pbs-dirty-bitmap-savevm': 'bool',
'pbs-dirty-bitmap-migration': 'bool',
diff --git a/debian/patches/pve/0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch b/debian/patches/pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
similarity index 100%
rename from debian/patches/pve/0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
rename to debian/patches/pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
diff --git a/debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch b/debian/patches/pve/0046-PVE-block-stream-increase-chunk-size.patch
similarity index 100%
rename from debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch
rename to debian/patches/pve/0046-PVE-block-stream-increase-chunk-size.patch
diff --git a/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch b/debian/patches/pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
similarity index 90%
rename from debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
rename to debian/patches/pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
index d1d30b1..b294d43 100644
--- a/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
+++ b/debian/patches/pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
@@ -17,10 +17,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+)
diff --git a/block/io.c b/block/io.c
-index 3280144a17..cd7ba08768 100644
+index 0a8cbefe86..531b3b7a2d 100644
--- a/block/io.c
+++ b/block/io.c
-@@ -1794,6 +1794,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
+@@ -1734,6 +1734,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
{
int ret;
diff --git a/debian/patches/pve/0047-block-add-alloc-track-driver.patch b/debian/patches/pve/0048-block-add-alloc-track-driver.patch
similarity index 99%
rename from debian/patches/pve/0047-block-add-alloc-track-driver.patch
rename to debian/patches/pve/0048-block-add-alloc-track-driver.patch
index 1cf88ab..45c1c4d 100644
--- a/debian/patches/pve/0047-block-add-alloc-track-driver.patch
+++ b/debian/patches/pve/0048-block-add-alloc-track-driver.patch
@@ -389,7 +389,7 @@ index 0000000000..6b50fbe537
+
+block_init(bdrv_alloc_track_init);
diff --git a/block/meson.build b/block/meson.build
-index f94cc0cd25..1716febb1d 100644
+index a26a69434e..74e5f49758 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -2,6 +2,7 @@ block_ss.add(genh)
diff --git a/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch b/debian/patches/pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
similarity index 95%
rename from debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
rename to debian/patches/pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
index 0496b93..95f191f 100644
--- a/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
+++ b/debian/patches/pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
@@ -10,7 +10,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/qapi/pragma.json b/qapi/pragma.json
-index 41139d8645..a581acf7d4 100644
+index a2358e303a..9ff5c84ffd 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
@@ -15,6 +15,7 @@
@@ -21,7 +21,7 @@ index 41139d8645..a581acf7d4 100644
'migrate_cancel',
'netdev_add',
'netdev_del',
-@@ -63,6 +64,8 @@
+@@ -64,6 +65,8 @@
'SysEmuTarget', # query-cpu-fast, query-target
'UuidInfo', # query-uuid
'VncClientInfo', # query-vnc, query-vnc-servers, ...
diff --git a/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch b/debian/patches/pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
similarity index 90%
rename from debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
rename to debian/patches/pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
index a9413ab..68622c2 100644
--- a/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
+++ b/debian/patches/pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 5 insertions(+)
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
-index 0bc5799cf8..10ebefef06 100644
+index e65a5e3482..2ed2536816 100644
--- a/migration/savevm-async.c
+++ b/migration/savevm-async.c
-@@ -19,6 +19,7 @@
+@@ -20,6 +20,7 @@
#include "qemu/timer.h"
#include "qemu/main-loop.h"
#include "qemu/rcu.h"
@@ -22,7 +22,7 @@ index 0bc5799cf8..10ebefef06 100644
/* #define DEBUG_SAVEVM_STATE */
-@@ -586,6 +587,10 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
+@@ -514,6 +515,10 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
dirty_bitmap_mig_before_vm_start();
qemu_fclose(f);
diff --git a/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch b/debian/patches/pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
similarity index 91%
rename from debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
rename to debian/patches/pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
index 9b7c51e..e5c467d 100644
--- a/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
+++ b/debian/patches/pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
@@ -12,7 +12,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index 33979b7430..68e9c80788 100644
+index 699229eef6..4189ced8bc 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -492,10 +492,10 @@ Command description:
@@ -46,10 +46,10 @@ index b5b0bb4467..36f97e1f19 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 35c2bdc95c..6e93bbd425 100644
+index c6b4a5567d..041c203fc3 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4938,6 +4938,7 @@ static int img_dd(int argc, char **argv)
+@@ -4943,6 +4943,7 @@ static int img_dd(int argc, char **argv)
BlockDriver *drv = NULL, *proto_drv = NULL;
BlockBackend *blk1 = NULL, *blk2 = NULL;
QemuOpts *opts = NULL;
@@ -57,7 +57,7 @@ index 35c2bdc95c..6e93bbd425 100644
QemuOptsList *create_opts = NULL;
Error *local_err = NULL;
bool image_opts = false;
-@@ -4947,6 +4948,7 @@ static int img_dd(int argc, char **argv)
+@@ -4952,6 +4953,7 @@ static int img_dd(int argc, char **argv)
int64_t size = 0, readsize = 0;
int64_t block_count = 0, out_pos, in_pos;
bool force_share = false, skip_create = false;
@@ -65,7 +65,7 @@ index 35c2bdc95c..6e93bbd425 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4984,7 +4986,7 @@ static int img_dd(int argc, char **argv)
+@@ -4989,7 +4991,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -74,7 +74,7 @@ index 35c2bdc95c..6e93bbd425 100644
if (c == EOF) {
break;
}
-@@ -5007,6 +5009,19 @@ static int img_dd(int argc, char **argv)
+@@ -5012,6 +5014,19 @@ static int img_dd(int argc, char **argv)
case 'n':
skip_create = true;
break;
@@ -94,7 +94,7 @@ index 35c2bdc95c..6e93bbd425 100644
case 'U':
force_share = true;
break;
-@@ -5066,11 +5081,24 @@ static int img_dd(int argc, char **argv)
+@@ -5071,11 +5086,24 @@ static int img_dd(int argc, char **argv)
if (dd.flags & C_IF) {
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
force_share);
@@ -120,7 +120,7 @@ index 35c2bdc95c..6e93bbd425 100644
}
if (dd.flags & C_OSIZE) {
-@@ -5219,6 +5247,7 @@ static int img_dd(int argc, char **argv)
+@@ -5230,6 +5258,7 @@ static int img_dd(int argc, char **argv)
out:
g_free(arg);
qemu_opts_del(opts);
diff --git a/debian/patches/pve/0051-vma-allow-partial-restore.patch b/debian/patches/pve/0052-vma-allow-partial-restore.patch
similarity index 94%
rename from debian/patches/pve/0051-vma-allow-partial-restore.patch
rename to debian/patches/pve/0052-vma-allow-partial-restore.patch
index ede4d67..f1fd7cb 100644
--- a/debian/patches/pve/0051-vma-allow-partial-restore.patch
+++ b/debian/patches/pve/0052-vma-allow-partial-restore.patch
@@ -24,10 +24,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 126 insertions(+), 97 deletions(-)
diff --git a/vma-reader.c b/vma-reader.c
-index 4f4ee2b47b..844d95a5ba 100644
+index e65f1e8415..81a891c6b1 100644
--- a/vma-reader.c
+++ b/vma-reader.c
-@@ -29,6 +29,7 @@ typedef struct VmaRestoreState {
+@@ -28,6 +28,7 @@ typedef struct VmaRestoreState {
bool write_zeroes;
unsigned long *bitmap;
int bitmap_size;
@@ -35,7 +35,7 @@ index 4f4ee2b47b..844d95a5ba 100644
} VmaRestoreState;
struct VmaReader {
-@@ -426,13 +427,14 @@ VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id)
+@@ -425,13 +426,14 @@ VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id)
}
static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
@@ -51,7 +51,7 @@ index 4f4ee2b47b..844d95a5ba 100644
int64_t size = vmar->devinfo[dev_id].size;
-@@ -447,28 +449,30 @@ static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
+@@ -446,28 +448,30 @@ static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
}
int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockBackend *target,
@@ -99,7 +99,7 @@ index 4f4ee2b47b..844d95a5ba 100644
return 0;
}
-@@ -561,19 +565,23 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -560,19 +564,23 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
VmaRestoreState *rstate = &vmar->rstate[dev_id];
BlockBackend *target = NULL;
@@ -129,7 +129,7 @@ index 4f4ee2b47b..844d95a5ba 100644
max_sector = vmar->devinfo[dev_id].size/BDRV_SECTOR_SIZE;
} else {
-@@ -619,7 +627,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -618,7 +626,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
return -1;
}
@@ -138,7 +138,7 @@ index 4f4ee2b47b..844d95a5ba 100644
int nb_sectors = end_sector - sector_num;
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
buf + start, sector_num, nb_sectors,
-@@ -655,7 +663,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -654,7 +662,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
return -1;
}
@@ -147,7 +147,7 @@ index 4f4ee2b47b..844d95a5ba 100644
int nb_sectors = end_sector - sector_num;
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
buf + start, sector_num,
-@@ -680,7 +688,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -679,7 +687,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
vmar->partial_zero_cluster_data += zero_size;
}
@@ -156,7 +156,7 @@ index 4f4ee2b47b..844d95a5ba 100644
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
zero_vma_block, sector_num,
nb_sectors, errp) < 0) {
-@@ -851,7 +859,7 @@ int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp)
+@@ -850,7 +858,7 @@ int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp)
for (dev_id = 1; dev_id < 255; dev_id++) {
if (vma_reader_get_device_info(vmar, dev_id)) {
@@ -166,10 +166,10 @@ index 4f4ee2b47b..844d95a5ba 100644
}
diff --git a/vma.c b/vma.c
-index 91612d50a2..e1a750ff50 100644
+index e8dffb43e0..e6e9ffc7fe 100644
--- a/vma.c
+++ b/vma.c
-@@ -139,6 +139,7 @@ typedef struct RestoreMap {
+@@ -138,6 +138,7 @@ typedef struct RestoreMap {
char *throttling_group;
char *cache;
bool write_zero;
@@ -177,7 +177,7 @@ index 91612d50a2..e1a750ff50 100644
} RestoreMap;
static bool try_parse_option(char **line, const char *optname, char **out, const char *inbuf) {
-@@ -246,47 +247,61 @@ static int extract_content(int argc, char **argv)
+@@ -245,47 +246,61 @@ static int extract_content(int argc, char **argv)
char *bps = NULL;
char *group = NULL;
char *cache = NULL;
@@ -265,7 +265,7 @@ index 91612d50a2..e1a750ff50 100644
if (!devname) {
g_error("read map failed - no dev name specified ('%s')",
inbuf);
-@@ -300,6 +315,7 @@ static int extract_content(int argc, char **argv)
+@@ -299,6 +314,7 @@ static int extract_content(int argc, char **argv)
map->throttling_group = group;
map->cache = cache;
map->write_zero = write_zero;
@@ -273,7 +273,7 @@ index 91612d50a2..e1a750ff50 100644
g_hash_table_insert(devmap, map->devname, map);
-@@ -329,6 +345,7 @@ static int extract_content(int argc, char **argv)
+@@ -328,6 +344,7 @@ static int extract_content(int argc, char **argv)
const char *cache = NULL;
int flags = BDRV_O_RDWR;
bool write_zero = true;
@@ -281,7 +281,7 @@ index 91612d50a2..e1a750ff50 100644
BlockBackend *blk = NULL;
-@@ -344,6 +361,7 @@ static int extract_content(int argc, char **argv)
+@@ -343,6 +360,7 @@ static int extract_content(int argc, char **argv)
throttling_group = map->throttling_group;
cache = map->cache;
write_zero = map->write_zero;
@@ -289,7 +289,7 @@ index 91612d50a2..e1a750ff50 100644
} else {
devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
dirname, di->devname);
-@@ -362,57 +380,60 @@ static int extract_content(int argc, char **argv)
+@@ -361,57 +379,60 @@ static int extract_content(int argc, char **argv)
write_zero = false;
}
diff --git a/debian/patches/pve/0052-pbs-namespace-support.patch b/debian/patches/pve/0053-pbs-namespace-support.patch
similarity index 96%
rename from debian/patches/pve/0052-pbs-namespace-support.patch
rename to debian/patches/pve/0053-pbs-namespace-support.patch
index 67bda69..dce468d 100644
--- a/debian/patches/pve/0052-pbs-namespace-support.patch
+++ b/debian/patches/pve/0053-pbs-namespace-support.patch
@@ -112,10 +112,10 @@ index c5eb4d5bad..7471e2ef9d 100644
static const char *const pbs_strong_runtime_opts[] = {
diff --git a/pbs-restore.c b/pbs-restore.c
-index 4d3f925a1b..62042bdd93 100644
+index 2f834cf42e..f03d9bab8d 100644
--- a/pbs-restore.c
+++ b/pbs-restore.c
-@@ -30,7 +30,7 @@
+@@ -29,7 +29,7 @@
static void help(void)
{
const char *help_msg =
@@ -124,7 +124,7 @@ index 4d3f925a1b..62042bdd93 100644
;
printf("%s", help_msg);
-@@ -78,6 +78,7 @@ int main(int argc, char **argv)
+@@ -77,6 +77,7 @@ int main(int argc, char **argv)
Error *main_loop_err = NULL;
const char *format = "raw";
const char *repository = NULL;
@@ -132,7 +132,7 @@ index 4d3f925a1b..62042bdd93 100644
const char *keyfile = NULL;
int verbose = false;
bool skip_zero = false;
-@@ -91,6 +92,7 @@ int main(int argc, char **argv)
+@@ -90,6 +91,7 @@ int main(int argc, char **argv)
{"verbose", no_argument, 0, 'v'},
{"format", required_argument, 0, 'f'},
{"repository", required_argument, 0, 'r'},
@@ -140,7 +140,7 @@ index 4d3f925a1b..62042bdd93 100644
{"keyfile", required_argument, 0, 'k'},
{0, 0, 0, 0}
};
-@@ -111,6 +113,9 @@ int main(int argc, char **argv)
+@@ -110,6 +112,9 @@ int main(int argc, char **argv)
case 'r':
repository = g_strdup(argv[optind - 1]);
break;
@@ -150,7 +150,7 @@ index 4d3f925a1b..62042bdd93 100644
case 'k':
keyfile = g_strdup(argv[optind - 1]);
break;
-@@ -161,8 +166,16 @@ int main(int argc, char **argv)
+@@ -160,8 +165,16 @@ int main(int argc, char **argv)
fprintf(stderr, "connecting to repository '%s'\n", repository);
}
char *pbs_error = NULL;
@@ -202,10 +202,10 @@ index 9f6c04a512..f6a5f8c785 100644
backup_time,
dump_cb_block_size,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 13e03ca154..89875f309c 100644
+index fc8a125451..cc2ead0b75 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -821,6 +821,8 @@
+@@ -817,6 +817,8 @@
#
# @fingerprint: server cert fingerprint (optional for format 'pbs')
#
@@ -214,7 +214,7 @@ index 13e03ca154..89875f309c 100644
# @backup-id: backup ID (required for format 'pbs')
#
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
-@@ -840,6 +842,7 @@
+@@ -836,6 +838,7 @@
'*key-password': 'str',
'*master-keyfile': 'str',
'*fingerprint': 'str',
@@ -222,7 +222,7 @@ index 13e03ca154..89875f309c 100644
'*backup-id': 'str',
'*backup-time': 'int',
'*use-dirty-bitmap': 'bool',
-@@ -3256,7 +3259,7 @@
+@@ -3282,7 +3285,7 @@
{ 'struct': 'BlockdevOptionsPbs',
'data': { 'repository': 'str', 'snapshot': 'str', 'archive': 'str',
'*keyfile': 'str', '*password': 'str', '*fingerprint': 'str',
diff --git a/debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch b/debian/patches/pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
similarity index 92%
rename from debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
rename to debian/patches/pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
index 4fd82ac..9827983 100644
--- a/debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
+++ b/debian/patches/pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
@@ -12,10 +12,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 2 insertions(+), 40 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
-index 0cec24c86d..0a9b97aa5e 100644
+index 64a8d7d48b..9fc6dcb957 100644
--- a/block/rbd.c
+++ b/block/rbd.c
-@@ -1324,7 +1324,6 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+@@ -1348,7 +1348,6 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
int status, r;
RBDDiffIterateReq req = { .offs = offset };
uint64_t features, flags;
@@ -23,7 +23,7 @@ index 0cec24c86d..0a9b97aa5e 100644
assert(offset + bytes <= s->image_size);
-@@ -1352,43 +1351,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+@@ -1376,43 +1375,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
return status;
}
@@ -68,7 +68,7 @@ index 0cec24c86d..0a9b97aa5e 100644
qemu_rbd_diff_iterate_cb, &req);
if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
return status;
-@@ -1407,8 +1370,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+@@ -1431,8 +1394,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
}
diff --git a/debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch b/debian/patches/pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
similarity index 90%
rename from debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
rename to debian/patches/pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
index 6624c1d..6972373 100644
--- a/debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
+++ b/debian/patches/pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
@@ -13,10 +13,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
-index 0a9b97aa5e..1c585d23e9 100644
+index 9fc6dcb957..98f4ba2620 100644
--- a/block/rbd.c
+++ b/block/rbd.c
-@@ -1283,11 +1283,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
+@@ -1307,11 +1307,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
RBDDiffIterateReq *req = opaque;
assert(req->offs + req->bytes <= offs);
diff --git a/debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch b/debian/patches/pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
similarity index 97%
rename from debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
rename to debian/patches/pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
index 13e71b7..f7025a3 100644
--- a/debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
+++ b/debian/patches/pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
@@ -23,7 +23,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 112 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
-index 1c585d23e9..1704767041 100644
+index 98f4ba2620..efcbbe5949 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -97,12 +97,6 @@ typedef struct RBDTask {
@@ -39,7 +39,7 @@ index 1c585d23e9..1704767041 100644
static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
BlockdevOptionsRbd *opts, bool cache,
const char *keypairs, const char *secretid,
-@@ -1269,111 +1263,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
+@@ -1293,111 +1287,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
return spec_info;
}
@@ -151,7 +151,7 @@ index 1c585d23e9..1704767041 100644
static int64_t qemu_rbd_getlength(BlockDriverState *bs)
{
BDRVRBDState *s = bs->opaque;
-@@ -1609,7 +1498,6 @@ static BlockDriver bdrv_rbd = {
+@@ -1633,7 +1522,6 @@ static BlockDriver bdrv_rbd = {
#ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
.bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
#endif
diff --git a/debian/patches/pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch b/debian/patches/pve/0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
similarity index 100%
rename from debian/patches/pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
rename to debian/patches/pve/0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
diff --git a/debian/patches/pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch b/debian/patches/pve/0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
similarity index 100%
rename from debian/patches/pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
rename to debian/patches/pve/0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
diff --git a/debian/patches/pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch b/debian/patches/pve/0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
similarity index 100%
rename from debian/patches/pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
rename to debian/patches/pve/0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
diff --git a/debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch b/debian/patches/pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
similarity index 92%
rename from debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
rename to debian/patches/pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
index 3097cf6..ffa8d0e 100644
--- a/debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
+++ b/debian/patches/pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
@@ -25,10 +25,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/vma.c b/vma.c
-index e1a750ff50..b1137e27a7 100644
+index e6e9ffc7fe..304f02bc84 100644
--- a/vma.c
+++ b/vma.c
-@@ -549,7 +549,7 @@ static void coroutine_fn backup_run(void *opaque)
+@@ -548,7 +548,7 @@ static void coroutine_fn backup_run(void *opaque)
struct iovec iov;
QEMUIOVector qiov;
@@ -37,7 +37,7 @@ index e1a750ff50..b1137e27a7 100644
int ret = 0;
unsigned char *buf = blk_blockalign(job->target, VMA_CLUSTER_SIZE);
-@@ -563,8 +563,16 @@ static void coroutine_fn backup_run(void *opaque)
+@@ -562,8 +562,16 @@ static void coroutine_fn backup_run(void *opaque)
iov.iov_len = VMA_CLUSTER_SIZE;
qemu_iovec_init_external(&qiov, &iov, 1);
diff --git a/debian/patches/pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch b/debian/patches/pve/0061-vma-create-avoid-triggering-assertion-in-error-case.patch
similarity index 100%
rename from debian/patches/pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
rename to debian/patches/pve/0061-vma-create-avoid-triggering-assertion-in-error-case.patch
diff --git a/debian/patches/pve/0061-block-alloc-track-avoid-premature-break.patch b/debian/patches/pve/0062-block-alloc-track-avoid-premature-break.patch
similarity index 100%
rename from debian/patches/pve/0061-block-alloc-track-avoid-premature-break.patch
rename to debian/patches/pve/0062-block-alloc-track-avoid-premature-break.patch
diff --git a/debian/patches/pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch b/debian/patches/pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
similarity index 98%
rename from debian/patches/pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch
rename to debian/patches/pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
index 08df987..a20a383 100644
--- a/debian/patches/pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch
+++ b/debian/patches/pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
@@ -109,10 +109,10 @@ index 2e22030eec..e9aa7e0f49 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 89875f309c..43281aca79 100644
+index cc2ead0b75..e3f62faa81 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -833,6 +833,8 @@
+@@ -829,6 +829,8 @@
#
# @encrypt: use encryption ((optional for format 'pbs', defaults to true if there is a keyfile)
#
@@ -121,7 +121,7 @@ index 89875f309c..43281aca79 100644
# Returns: the uuid of the backup job
#
##
-@@ -851,7 +853,9 @@
+@@ -847,7 +849,9 @@
'*format': 'BackupFormat',
'*config-file': 'str',
'*firewall-file': 'str',
@@ -132,7 +132,7 @@ index 89875f309c..43281aca79 100644
'returns': 'UuidInfo', 'coroutine': true }
##
-@@ -906,7 +910,8 @@
+@@ -902,7 +906,8 @@
'pbs-dirty-bitmap-savevm': 'bool',
'pbs-dirty-bitmap-migration': 'bool',
'pbs-masterkey': 'bool',
diff --git a/debian/patches/series b/debian/patches/series
index 8745fcc..b45710f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,24 +1,4 @@
extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
-extra/0002-block-gluster-correctly-set-max_pdiscard.patch
-extra/0003-block-vmdk-Fix-reopening-bs-file.patch
-extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
-extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
-extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
-extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
-extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
-extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
-extra/0010-coroutine-Revert-to-constant-batch-size.patch
-extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
-extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
-extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
-extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
-extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
-extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
-extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
-extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
-extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
-extra/0020-io_uring-fix-short-read-slow-path.patch
-extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
@@ -40,50 +20,51 @@ pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
pve/0014-PVE-qapi-modify-query-machines.patch
pve/0015-PVE-qapi-modify-spice-query.patch
-pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
-pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
-pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
-pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
-pve/0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
-pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
-pve/0022-PVE-monitor-disable-oob-capability.patch
-pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
-pve/0024-PVE-Allow-version-code-in-machine-type.patch
-pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
-pve/0026-PVE-Backup-add-vma-backup-format-code.patch
-pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
-pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
-pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
-pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
-pve/0031-PVE-various-PBS-fixes.patch
-pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
-pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
-pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
-pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
-pve/0036-PVE-Add-sequential-job-transaction-support.patch
-pve/0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
-pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
-pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
-pve/0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
-pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
-pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
-pve/0043-PBS-add-master-key-support.patch
-pve/0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
-pve/0045-PVE-block-stream-increase-chunk-size.patch
-pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
-pve/0047-block-add-alloc-track-driver.patch
-pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
-pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
-pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
-pve/0051-vma-allow-partial-restore.patch
-pve/0052-pbs-namespace-support.patch
-pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
-pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
-pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
-pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
-pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
-pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
-pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
-pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
-pve/0061-block-alloc-track-avoid-premature-break.patch
-pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch
+pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
+pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
+pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
+pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
+pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
+pve/0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
+pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+pve/0023-PVE-monitor-disable-oob-capability.patch
+pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
+pve/0025-PVE-Allow-version-code-in-machine-type.patch
+pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
+pve/0027-PVE-Backup-add-vma-backup-format-code.patch
+pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
+pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
+pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
+pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
+pve/0032-PVE-various-PBS-fixes.patch
+pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
+pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
+pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
+pve/0037-PVE-Add-sequential-job-transaction-support.patch
+pve/0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
+pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
+pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+pve/0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
+pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
+pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
+pve/0044-PBS-add-master-key-support.patch
+pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
+pve/0046-PVE-block-stream-increase-chunk-size.patch
+pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
+pve/0048-block-add-alloc-track-driver.patch
+pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
+pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
+pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
+pve/0052-vma-allow-partial-restore.patch
+pve/0053-pbs-namespace-support.patch
+pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
+pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
+pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
+pve/0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
+pve/0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
+pve/0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
+pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
+pve/0061-vma-create-avoid-triggering-assertion-in-error-case.patch
+pve/0062-block-alloc-track-avoid-premature-break.patch
+pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
diff --git a/qemu b/qemu
index 823a3f1..621da77 160000
--- a/qemu
+++ b/qemu
@@ -1 +1 @@
-Subproject commit 823a3f11fb8f04c3c3cc0f95f968fef1bfc6534f
+Subproject commit 621da7789083b80d6f1ff1c0fb499334007b4f51
--
2.30.2
^ permalink raw reply related [relevance 11%]
* [pve-devel] [PATCH qemu 1/4] update submodule and patches to 7.1.0
@ 2022-10-13 12:44 11% Fiona Ebner
0 siblings, 0 replies; 23+ results
From: Fiona Ebner @ 2022-10-13 12:44 UTC (permalink / raw)
To: pve-devel
Notable changes:
* The only big change is the switch to using a custom QIOChannel for
savevm-async, because the previously used QEMUFileOps was dropped.
Changes to the current implementation:
* Switch to vector based methods as required for an IO channel. For
short reads the passed-in IO vector is stuffed with zeroes at the
end, just to be sure.
* For reading: The documentation in include/io/channel.h states that
at least one byte should be read, so also error out when whe are
at the very end instead of returning 0.
* For reading: Fix off-by-one error when request goes beyond end.
The wrong code piece was:
if ((pos + size) > maxlen) {
size = maxlen - pos - 1;
}
Previously, the last byte would not be read. It's actually
possible to get a snapshot .raw file that has content all the way
up the final 512 byte (= BDRV_SECTOR_SIZE) boundary without any
trailing zero bytes (I wrote a script to do it).
Luckily, it didn't cause a real issue, because qemu_loadvm_state()
is not interested in the final (i.e. QEMU_VM_VMDESCRIPTION)
section. The buffer for reading it is simply freed up afterwards
and the function will assume that it read the whole section, even
if that's not the case.
* Adapt to changed interfaces for blk_{pread,pwrite}:
* a9262f551e ("block: Change blk_{pread,pwrite}() param order")
* 3b35d4542c ("block: Add a 'flags' param to blk_pread()")
* bf5b16fa40 ("block: Make blk_{pread,pwrite}() return 0 on success")
Those changes especially affected the qemu-img dd patches, because
the context also changed, but also some of our block drivers used
the functions.
* Drop qemu-common.h include: it got renamed after essentially
everything was moved to other headers. The only remaining user I
could find for things dropped from the header between 7.0 and 7.1
was qemu_get_vm_name() in the iscsi-initiatorname patch, but it
already includes the header to which the function was moved.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
...d-support-for-sync-bitmap-mode-never.patch | 22 +-
...-support-for-conditional-and-always-.patch | 2 +-
...check-for-bitmap-mode-without-bitmap.patch | 2 +-
...-to-bdrv_dirty_bitmap_merge_internal.patch | 2 +-
.../0006-mirror-move-some-checks-to-qmp.patch | 4 +-
...race-with-clients-disconnecting-earl.patch | 8 +-
...k-gluster-correctly-set-max_pdiscard.patch | 47 ---
...003-block-vmdk-Fix-reopening-bs-file.patch | 129 --------
...balanced-plugged-counter-in-laio_io_.patch | 44 ---
...erflow-in-snprintf-string-formatting.patch | 100 ------
...Fix-disabling-MPX-on-cpu-host-with-M.patch | 48 ---
...ontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch | 121 -------
...outine-use-QEMU_DEFINE_STATIC_CO_TLS.patch | 123 -------
...ame-qemu_coroutine_inc-dec_pool_size.patch | 90 ------
...outine-Revert-to-constant-batch-size.patch | 121 -------
...-not-consult-nonexistent-host-leaves.patch | 117 -------
...ctrl-and-event-handler-functions-in-.patch | 108 -------
...t-waste-CPU-polling-the-event-virtqu.patch | 91 ------
...k-descriptor-chain-in-private-at-SVQ.patch | 102 ------
...Fix-device-s-used-descriptor-dequeue.patch | 62 ----
...ex-calculus-at-vhost_vdpa_get_vring_.patch | 39 ---
...ex-calculus-at-vhost_vdpa_svqs_start.patch | 35 --
...virtio-Replace-g_memdup-by-g_memdup2.patch | 74 -----
...Fix-element-in-vhost_svq_add-failure.patch | 47 ---
...20-io_uring-fix-short-read-slow-path.patch | 49 ---
...criptor-status-in-a-separate-operati.patch | 82 -----
...k-file-change-locking-default-to-off.patch | 6 +-
...he-CPU-model-to-kvm64-32-instead-of-.patch | 4 +-
...erfs-no-default-logfile-if-daemonize.patch | 2 +-
...lock-rbd-disable-rbd_cache_writethro.patch | 2 +-
.../0007-PVE-Up-qmp-add-get_link_status.patch | 12 +-
...PVE-Up-glusterfs-allow-partial-reads.patch | 2 +-
...return-success-on-info-without-snaps.patch | 4 +-
...dd-add-osize-and-read-from-to-stdin-.patch | 70 ++--
...E-Up-qemu-img-dd-add-isize-parameter.patch | 23 +-
...PVE-Up-qemu-img-dd-add-n-skip_create.patch | 12 +-
...virtio-balloon-improve-query-balloon.patch | 13 +-
.../0014-PVE-qapi-modify-query-machines.patch | 6 +-
.../0015-PVE-qapi-modify-spice-query.patch | 4 +-
...nnel-implementation-for-savevm-async.patch | 306 ++++++++++++++++++
...sync-for-background-state-snapshots.patch} | 148 +++------
...dd-optional-buffer-size-to-QEMUFile.patch} | 132 +++++---
...dd-the-zeroinit-block-driver-filter.patch} | 2 +-
...Add-dummy-id-command-line-parameter.patch} | 12 +-
...-target-i386-disable-LINT0-after-re.patch} | 0
...e-posix-make-locking-optiono-on-cre.patch} | 18 +-
...-PVE-monitor-disable-oob-capability.patch} | 0
...ed-balloon-qemu-4-0-config-size-fal.patch} | 4 +-
...-Allow-version-code-in-machine-type.patch} | 16 +-
...-bcs-bitmap-initialization-to-job-c.patch} | 10 +-
...E-Backup-add-vma-backup-format-code.patch} | 26 +-
...Backup-add-backup-dump-block-driver.patch} | 15 +-
...kup-proxmox-backup-patches-for-qemu.patch} | 36 +--
...store-new-command-to-restore-from-p.patch} | 15 +-
...rty-bitmap-tracking-for-incremental.patch} | 14 +-
...patch => 0032-PVE-various-PBS-fixes.patch} | 6 +-
...-driver-to-map-backup-archives-into.patch} | 63 ++--
...d-query_proxmox_support-QMP-command.patch} | 4 +-
...-add-query-pbs-bitmap-info-QMP-call.patch} | 14 +-
...t-stderr-to-journal-when-daemonized.patch} | 14 +-
...-sequential-job-transaction-support.patch} | 0
...transaction-to-synchronize-job-stat.patch} | 0
...block-on-finishing-and-cleanup-crea.patch} | 4 +-
...grate-dirty-bitmap-state-via-savevm.patch} | 16 +-
...irty-bitmap-migrate-other-bitmaps-e.patch} | 0
...ll-back-to-open-iscsi-initiatorname.patch} | 2 +-
...outine-QMP-for-backup-cancel_backup.patch} | 12 +-
... => 0044-PBS-add-master-key-support.patch} | 10 +-
...t-path-reads-without-allocation-if-.patch} | 0
...VE-block-stream-increase-chunk-size.patch} | 0
...ccept-NULL-qiov-in-bdrv_pad_request.patch} | 4 +-
...> 0048-block-add-alloc-track-driver.patch} | 2 +-
...alid-QAPI-names-for-backwards-compa.patch} | 4 +-
...register-yank-before-migration_inco.patch} | 6 +-
...add-l-option-for-loading-a-snapshot.patch} | 16 +-
...h => 0052-vma-allow-partial-restore.patch} | 32 +-
...patch => 0053-pbs-namespace-support.patch} | 20 +-
...rbd-workaround-for-ceph-issue-53784.patch} | 8 +-
...fix-handling-of-holes-in-.bdrv_co_b.patch} | 4 +-
...-rbd-implement-bdrv_co_block_status.patch} | 6 +-
...-jobs-correctly-cancel-in-error-sce.patch} | 0
...sure-jobs-in-di_list-are-referenced.patch} | 0
...-segfault-issues-upon-backup-cancel.patch} | 0
...upport-64KiB-unaligned-input-images.patch} | 6 +-
...-triggering-assertion-in-error-case.patch} | 0
...k-alloc-track-avoid-premature-break.patch} | 0
...passing-max-workers-performance-set.patch} | 8 +-
debian/patches/series | 115 +++----
qemu | 2 +-
89 files changed, 794 insertions(+), 2167 deletions(-)
delete mode 100644 debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch
delete mode 100644 debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch
delete mode 100644 debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
delete mode 100644 debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
delete mode 100644 debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
delete mode 100644 debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
delete mode 100644 debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
delete mode 100644 debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
delete mode 100644 debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch
delete mode 100644 debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
delete mode 100644 debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
delete mode 100644 debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
delete mode 100644 debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
delete mode 100644 debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
delete mode 100644 debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
delete mode 100644 debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
delete mode 100644 debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
delete mode 100644 debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
delete mode 100644 debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch
delete mode 100644 debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
create mode 100644 debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
rename debian/patches/pve/{0016-PVE-add-savevm-async-for-background-state-snapshots.patch => 0017-PVE-add-savevm-async-for-background-state-snapshots.patch} (88%)
rename debian/patches/pve/{0017-PVE-add-optional-buffer-size-to-QEMUFile.patch => 0018-PVE-add-optional-buffer-size-to-QEMUFile.patch} (52%)
rename debian/patches/pve/{0018-PVE-block-add-the-zeroinit-block-driver-filter.patch => 0019-PVE-block-add-the-zeroinit-block-driver-filter.patch} (99%)
rename debian/patches/pve/{0019-PVE-Add-dummy-id-command-line-parameter.patch => 0020-PVE-Add-dummy-id-command-line-parameter.patch} (86%)
rename debian/patches/pve/{0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch => 0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch} (100%)
rename debian/patches/pve/{0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch => 0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch} (90%)
rename debian/patches/pve/{0022-PVE-monitor-disable-oob-capability.patch => 0023-PVE-monitor-disable-oob-capability.patch} (100%)
rename debian/patches/pve/{0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch => 0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch} (95%)
rename debian/patches/pve/{0024-PVE-Allow-version-code-in-machine-type.patch => 0025-PVE-Allow-version-code-in-machine-type.patch} (93%)
rename debian/patches/pve/{0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch => 0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch} (88%)
rename debian/patches/pve/{0026-PVE-Backup-add-vma-backup-format-code.patch => 0027-PVE-Backup-add-vma-backup-format-code.patch} (99%)
rename debian/patches/pve/{0027-PVE-Backup-add-backup-dump-block-driver.patch => 0028-PVE-Backup-add-backup-dump-block-driver.patch} (96%)
rename debian/patches/pve/{0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch => 0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch} (98%)
rename debian/patches/pve/{0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch => 0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch} (95%)
rename debian/patches/pve/{0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch => 0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch} (98%)
rename debian/patches/pve/{0031-PVE-various-PBS-fixes.patch => 0032-PVE-various-PBS-fixes.patch} (99%)
rename debian/patches/pve/{0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch => 0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch} (91%)
rename debian/patches/pve/{0033-PVE-add-query_proxmox_support-QMP-command.patch => 0034-PVE-add-query_proxmox_support-QMP-command.patch} (97%)
rename debian/patches/pve/{0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch => 0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch} (98%)
rename debian/patches/pve/{0035-PVE-redirect-stderr-to-journal-when-daemonized.patch => 0036-PVE-redirect-stderr-to-journal-when-daemonized.patch} (86%)
rename debian/patches/pve/{0036-PVE-Add-sequential-job-transaction-support.patch => 0037-PVE-Add-sequential-job-transaction-support.patch} (100%)
rename debian/patches/pve/{0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch => 0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch} (100%)
rename debian/patches/pve/{0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch => 0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch} (99%)
rename debian/patches/pve/{0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch => 0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch} (96%)
rename debian/patches/pve/{0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch => 0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch} (100%)
rename debian/patches/pve/{0041-PVE-fall-back-to-open-iscsi-initiatorname.patch => 0042-PVE-fall-back-to-open-iscsi-initiatorname.patch} (98%)
rename debian/patches/pve/{0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch => 0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch} (99%)
rename debian/patches/pve/{0043-PBS-add-master-key-support.patch => 0044-PBS-add-master-key-support.patch} (97%)
rename debian/patches/pve/{0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch => 0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch} (100%)
rename debian/patches/pve/{0045-PVE-block-stream-increase-chunk-size.patch => 0046-PVE-block-stream-increase-chunk-size.patch} (100%)
rename debian/patches/pve/{0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch => 0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch} (90%)
rename debian/patches/pve/{0047-block-add-alloc-track-driver.patch => 0048-block-add-alloc-track-driver.patch} (99%)
rename debian/patches/pve/{0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch => 0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch} (95%)
rename debian/patches/pve/{0049-PVE-savevm-async-register-yank-before-migration_inco.patch => 0050-PVE-savevm-async-register-yank-before-migration_inco.patch} (90%)
rename debian/patches/pve/{0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch => 0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch} (91%)
rename debian/patches/pve/{0051-vma-allow-partial-restore.patch => 0052-vma-allow-partial-restore.patch} (94%)
rename debian/patches/pve/{0052-pbs-namespace-support.patch => 0053-pbs-namespace-support.patch} (96%)
rename debian/patches/pve/{0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch => 0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch} (92%)
rename debian/patches/pve/{0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch => 0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch} (90%)
rename debian/patches/pve/{0055-Revert-block-rbd-implement-bdrv_co_block_status.patch => 0056-Revert-block-rbd-implement-bdrv_co_block_status.patch} (97%)
rename debian/patches/pve/{0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch => 0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch} (100%)
rename debian/patches/pve/{0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch => 0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch} (100%)
rename debian/patches/pve/{0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch => 0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch} (100%)
rename debian/patches/pve/{0059-vma-create-support-64KiB-unaligned-input-images.patch => 0060-vma-create-support-64KiB-unaligned-input-images.patch} (92%)
rename debian/patches/pve/{0060-vma-create-avoid-triggering-assertion-in-error-case.patch => 0061-vma-create-avoid-triggering-assertion-in-error-case.patch} (100%)
rename debian/patches/pve/{0061-block-alloc-track-avoid-premature-break.patch => 0062-block-alloc-track-avoid-premature-break.patch} (100%)
rename debian/patches/pve/{0062-PVE-Backup-allow-passing-max-workers-performance-set.patch => 0063-PVE-Backup-allow-passing-max-workers-performance-set.patch} (98%)
diff --git a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
index 5301cf0..8cdca68 100644
--- a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
+++ b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
@@ -36,7 +36,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 files changed, 145 insertions(+), 29 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index d8ecb9efa2..d95a7d7940 100644
+index 3c4ab1159d..f2eca983f1 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -51,7 +51,7 @@ typedef struct MirrorBlockJob {
@@ -252,7 +252,7 @@ index d8ecb9efa2..d95a7d7940 100644
errp);
if (!job) {
diff --git a/blockdev.c b/blockdev.c
-index e46e831212..fa601838a3 100644
+index 9230888e34..9a1a3118ed 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2951,6 +2951,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
@@ -344,10 +344,10 @@ index e46e831212..fa601838a3 100644
has_granularity, granularity,
has_buf_size, buf_size,
diff --git a/include/block/block_int-global-state.h b/include/block/block_int-global-state.h
-index 0f21b0570b..e7f901d048 100644
+index b49f4eb35b..9d744db618 100644
--- a/include/block/block_int-global-state.h
+++ b/include/block/block_int-global-state.h
-@@ -148,7 +148,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
+@@ -149,7 +149,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, const char *replaces,
int creation_flags, int64_t speed,
uint32_t granularity, int64_t buf_size,
@@ -359,10 +359,10 @@ index 0f21b0570b..e7f901d048 100644
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index beeb91952a..fb25c2b245 100644
+index 2173e7734a..e1857e7094 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -1993,10 +1993,19 @@
+@@ -2000,10 +2000,19 @@
# (all the disk, only the sectors allocated in the topmost image, or
# only new I/O).
#
@@ -383,7 +383,7 @@ index beeb91952a..fb25c2b245 100644
#
# @buf-size: maximum amount of data in flight from source to
# target (since 1.4).
-@@ -2034,7 +2043,9 @@
+@@ -2043,7 +2052,9 @@
{ 'struct': 'DriveMirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*format': 'str', '*node-name': 'str', '*replaces': 'str',
@@ -394,7 +394,7 @@ index beeb91952a..fb25c2b245 100644
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
-@@ -2306,10 +2317,19 @@
+@@ -2322,10 +2333,19 @@
# (all the disk, only the sectors allocated in the topmost image, or
# only new I/O).
#
@@ -415,7 +415,7 @@ index beeb91952a..fb25c2b245 100644
#
# @buf-size: maximum amount of data in flight from source to
# target
-@@ -2358,7 +2378,8 @@
+@@ -2375,7 +2395,8 @@
{ 'command': 'blockdev-mirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*replaces': 'str',
@@ -426,10 +426,10 @@ index beeb91952a..fb25c2b245 100644
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
-index 94718c9319..7977ac14f4 100644
+index 8b55eccc89..f4650be8e5 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
-@@ -626,8 +626,8 @@ static void test_propagate_mirror(void)
+@@ -753,8 +753,8 @@ static void test_propagate_mirror(void)
/* Start a mirror job */
mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0,
diff --git a/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch b/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
index d30b46d..8c01d80 100644
--- a/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
+++ b/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
@@ -24,7 +24,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index d95a7d7940..2c79ee41af 100644
+index f2eca983f1..b6475d50ad 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -673,8 +673,6 @@ static int mirror_exit_common(Job *job)
diff --git a/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch b/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
index ffd3efe..2fac2ca 100644
--- a/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
+++ b/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 3 insertions(+)
diff --git a/blockdev.c b/blockdev.c
-index fa601838a3..93fd0a61a4 100644
+index 9a1a3118ed..a57b0af2e7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3050,6 +3050,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
diff --git a/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch b/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
index c86ceca..4d5f62a 100644
--- a/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
+++ b/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index 2c79ee41af..e04a3ea6f4 100644
+index b6475d50ad..8b3342f9ec 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -779,8 +779,8 @@ static int mirror_exit_common(Job *job)
diff --git a/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch b/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
index 4d4747b..336efbe 100644
--- a/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
+++ b/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 70 insertions(+), 59 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index e04a3ea6f4..4feec2a002 100644
+index 8b3342f9ec..1d4ff0efad 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1634,31 +1634,13 @@ static BlockJob *mirror_start_job(
@@ -60,7 +60,7 @@ index e04a3ea6f4..4feec2a002 100644
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
diff --git a/blockdev.c b/blockdev.c
-index 93fd0a61a4..1af5a1fcb2 100644
+index a57b0af2e7..ce62a9b439 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3029,7 +3029,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
diff --git a/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch b/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
index 9d8322c..cd72a8e 100644
--- a/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
+++ b/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
@@ -48,7 +48,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
-index cc4cc6c6ad..82f649d9ab 100644
+index a4b40e8391..d64ae8f34e 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
@@ -78,7 +78,7 @@ index caa2e90ef2..e1596f79ab 100644
/**
diff --git a/monitor/monitor.c b/monitor/monitor.c
-index 21c7a68758..ad9813567a 100644
+index 86949024f6..c306cadcf4 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -135,6 +135,21 @@ bool monitor_cur_is_qmp(void)
@@ -189,10 +189,10 @@ index 0990873ec8..e605003771 100644
aio_bh_schedule_oneshot(qemu_get_aio_context(), do_qmp_dispatch_bh,
&data);
diff --git a/stubs/monitor-core.c b/stubs/monitor-core.c
-index d058a2a00d..3290b58120 100644
+index afa477aae6..d3ff124bf3 100644
--- a/stubs/monitor-core.c
+++ b/stubs/monitor-core.c
-@@ -13,6 +13,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
+@@ -12,6 +12,11 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)
return NULL;
}
diff --git a/debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch b/debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch
deleted file mode 100644
index c0b8ee0..0000000
--- a/debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Fabian Ebner <f.ebner@proxmox.com>
-Date: Fri, 20 May 2022 09:59:22 +0200
-Subject: [PATCH] block/gluster: correctly set max_pdiscard
-
-On 64-bit platforms, assigning SIZE_MAX to the int64_t max_pdiscard
-results in a negative value, and the following assertion would trigger
-down the line (it's not the same max_pdiscard, but computed from the
-other one):
-qemu-system-x86_64: ../block/io.c:3166: bdrv_co_pdiscard: Assertion
-`max_pdiscard >= bs->bl.request_alignment' failed.
-
-On 32-bit platforms, it's fine to keep using SIZE_MAX.
-
-The assertion in qemu_gluster_co_pdiscard() is checking that the value
-of 'bytes' can safely be passed to glfs_discard_async(), which takes a
-size_t for the argument in question, so it is kept as is. And since
-max_pdiscard is still <= SIZE_MAX, relying on max_pdiscard is still
-fine.
-
-Fixes: 0c8022876f ("block: use int64_t instead of int in driver discard handlers")
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
-Message-Id: <20220520075922.43972-1-f.ebner@proxmox.com>
-Reviewed-by: Eric Blake <eblake@redhat.com>
-Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
-Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 9b38fc56c054c7de65fa3bf7cdd82b32654f6b7d)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/gluster.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/block/gluster.c b/block/gluster.c
-index 80b75cb96c..1079b6186b 100644
---- a/block/gluster.c
-+++ b/block/gluster.c
-@@ -901,7 +901,7 @@ out:
- static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp)
- {
- bs->bl.max_transfer = GLUSTER_MAX_TRANSFER;
-- bs->bl.max_pdiscard = SIZE_MAX;
-+ bs->bl.max_pdiscard = MIN(SIZE_MAX, INT64_MAX);
- }
-
- static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
diff --git a/debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch b/debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch
deleted file mode 100644
index 65c43de..0000000
--- a/debian/patches/extra/0003-block-vmdk-Fix-reopening-bs-file.patch
+++ /dev/null
@@ -1,129 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Hanna Reitz <hreitz@redhat.com>
-Date: Mon, 14 Mar 2022 17:27:18 +0100
-Subject: [PATCH] block/vmdk: Fix reopening bs->file
-
-VMDK disk data is stored in extents, which may or may not be separate
-from bs->file. VmdkExtent.file points to where they are stored. Each
-that is stored in bs->file will simply reuse the exact pointer value of
-bs->file.
-
-(That is why vmdk_free_extents() will unref VmdkExtent.file (e->file)
-only if e->file != bs->file.)
-
-Reopen operations can change bs->file (they will replace the whole
-BdrvChild object, not just the BDS stored in that BdrvChild), and then
-we will need to change all .file pointers of all such VmdkExtents to
-point to the new BdrvChild.
-
-In vmdk_reopen_prepare(), we have to check which VmdkExtents are
-affected, and in vmdk_reopen_commit(), we can modify them. We have to
-split this because:
-- The new BdrvChild is created only after prepare, so we can change
- VmdkExtent.file only in commit
-- In commit, there no longer is any (valid) reference to the old
- BdrvChild object, so there would be nothing to compare VmdkExtent.file
- against to see whether it was equal to bs->file before reopening
- (There is BDRVReopenState.old_file_bs, but the old bs->file
- BdrvChild's .bs pointer will be NULL-ed when the new BdrvChild is
- created, and so we cannot compare VmdkExtent.file->bs against
- BDRVReopenState.old_file_bs)
-
-Signed-off-by: Hanna Reitz <hreitz@redhat.com>
-Message-Id: <20220314162719.65384-2-hreitz@redhat.com>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 6d17e2879854d7d0e623c06a9286085e97bf3545)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/vmdk.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++-
- 1 file changed, 55 insertions(+), 1 deletion(-)
-
-diff --git a/block/vmdk.c b/block/vmdk.c
-index 37c0946066..38e5ab3806 100644
---- a/block/vmdk.c
-+++ b/block/vmdk.c
-@@ -178,6 +178,10 @@ typedef struct BDRVVmdkState {
- char *create_type;
- } BDRVVmdkState;
-
-+typedef struct BDRVVmdkReopenState {
-+ bool *extents_using_bs_file;
-+} BDRVVmdkReopenState;
-+
- typedef struct VmdkMetaData {
- unsigned int l1_index;
- unsigned int l2_index;
-@@ -400,15 +404,63 @@ static int vmdk_is_cid_valid(BlockDriverState *bs)
- return 1;
- }
-
--/* We have nothing to do for VMDK reopen, stubs just return success */
- static int vmdk_reopen_prepare(BDRVReopenState *state,
- BlockReopenQueue *queue, Error **errp)
- {
-+ BDRVVmdkState *s;
-+ BDRVVmdkReopenState *rs;
-+ int i;
-+
- assert(state != NULL);
- assert(state->bs != NULL);
-+ assert(state->opaque == NULL);
-+
-+ s = state->bs->opaque;
-+
-+ rs = g_new0(BDRVVmdkReopenState, 1);
-+ state->opaque = rs;
-+
-+ /*
-+ * Check whether there are any extents stored in bs->file; if bs->file
-+ * changes, we will need to update their .file pointers to follow suit
-+ */
-+ rs->extents_using_bs_file = g_new(bool, s->num_extents);
-+ for (i = 0; i < s->num_extents; i++) {
-+ rs->extents_using_bs_file[i] = s->extents[i].file == state->bs->file;
-+ }
-+
- return 0;
- }
-
-+static void vmdk_reopen_clean(BDRVReopenState *state)
-+{
-+ BDRVVmdkReopenState *rs = state->opaque;
-+
-+ g_free(rs->extents_using_bs_file);
-+ g_free(rs);
-+ state->opaque = NULL;
-+}
-+
-+static void vmdk_reopen_commit(BDRVReopenState *state)
-+{
-+ BDRVVmdkState *s = state->bs->opaque;
-+ BDRVVmdkReopenState *rs = state->opaque;
-+ int i;
-+
-+ for (i = 0; i < s->num_extents; i++) {
-+ if (rs->extents_using_bs_file[i]) {
-+ s->extents[i].file = state->bs->file;
-+ }
-+ }
-+
-+ vmdk_reopen_clean(state);
-+}
-+
-+static void vmdk_reopen_abort(BDRVReopenState *state)
-+{
-+ vmdk_reopen_clean(state);
-+}
-+
- static int vmdk_parent_open(BlockDriverState *bs)
- {
- char *p_name;
-@@ -3072,6 +3124,8 @@ static BlockDriver bdrv_vmdk = {
- .bdrv_open = vmdk_open,
- .bdrv_co_check = vmdk_co_check,
- .bdrv_reopen_prepare = vmdk_reopen_prepare,
-+ .bdrv_reopen_commit = vmdk_reopen_commit,
-+ .bdrv_reopen_abort = vmdk_reopen_abort,
- .bdrv_child_perm = bdrv_default_perms,
- .bdrv_co_preadv = vmdk_co_preadv,
- .bdrv_co_pwritev = vmdk_co_pwritev,
diff --git a/debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch b/debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
deleted file mode 100644
index cf130ac..0000000
--- a/debian/patches/extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Thu, 9 Jun 2022 17:47:11 +0100
-Subject: [PATCH] linux-aio: fix unbalanced plugged counter in laio_io_unplug()
-
-Every laio_io_plug() call has a matching laio_io_unplug() call. There is
-a plugged counter that tracks the number of levels of plugging and
-allows for nesting.
-
-The plugged counter must reflect the balance between laio_io_plug() and
-laio_io_unplug() calls accurately. Otherwise I/O stalls occur since
-io_submit(2) calls are skipped while plugged.
-
-Reported-by: Nikolay Tenev <nt@storpool.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
-Message-id: 20220609164712.1539045-2-stefanha@redhat.com
-Cc: Stefano Garzarella <sgarzare@redhat.com>
-Fixes: 68d7946648 ("linux-aio: add `dev_max_batch` parameter to laio_io_unplug()")
-[Stefano Garzarella suggested adding a Fixes tag.
---Stefan]
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit f387cac5af030a58ac5a0dacf64cab5e5a4fe5c7)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/linux-aio.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/block/linux-aio.c b/block/linux-aio.c
-index 4c423fcccf..6078da7e42 100644
---- a/block/linux-aio.c
-+++ b/block/linux-aio.c
-@@ -363,8 +363,10 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
- uint64_t dev_max_batch)
- {
- assert(s->io_q.plugged);
-+ s->io_q.plugged--;
-+
- if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
-- (--s->io_q.plugged == 0 &&
-+ (!s->io_q.plugged &&
- !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
- ioq_submit(s);
- }
diff --git a/debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch b/debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
deleted file mode 100644
index 3f2dfa9..0000000
--- a/debian/patches/extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Claudio Fontana <cfontana@suse.de>
-Date: Tue, 31 May 2022 13:47:07 +0200
-Subject: [PATCH] pci: fix overflow in snprintf string formatting
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-the code in pcibus_get_fw_dev_path contained the potential for a
-stack buffer overflow of 1 byte, potentially writing to the stack an
-extra NUL byte.
-
-This overflow could happen if the PCI slot is >= 0x10000000,
-and the PCI function is >= 0x10000000, due to the size parameter
-of snprintf being incorrectly calculated in the call:
-
- if (PCI_FUNC(d->devfn))
- snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
-
-since the off obtained from a previous call to snprintf is added
-instead of subtracted from the total available size of the buffer.
-
-Without the accurate size guard from snprintf, we end up writing in the
-worst case:
-
-name (32) + "@" (1) + SLOT (8) + "," (1) + FUNC (8) + term NUL (1) = 51 bytes
-
-In order to provide something more robust, replace all of the code in
-pcibus_get_fw_dev_path with a single call to g_strdup_printf,
-so there is no need to rely on manual calculations.
-
-Found by compiling QEMU with FORTIFY_SOURCE=3 as the error:
-
-*** buffer overflow detected ***: terminated
-
-Thread 1 "qemu-system-x86" received signal SIGABRT, Aborted.
-[Switching to Thread 0x7ffff642c380 (LWP 121307)]
-0x00007ffff71ff55c in __pthread_kill_implementation () from /lib64/libc.so.6
-(gdb) bt
- #0 0x00007ffff71ff55c in __pthread_kill_implementation () at /lib64/libc.so.6
- #1 0x00007ffff71ac6f6 in raise () at /lib64/libc.so.6
- #2 0x00007ffff7195814 in abort () at /lib64/libc.so.6
- #3 0x00007ffff71f279e in __libc_message () at /lib64/libc.so.6
- #4 0x00007ffff729767a in __fortify_fail () at /lib64/libc.so.6
- #5 0x00007ffff7295c36 in () at /lib64/libc.so.6
- #6 0x00007ffff72957f5 in __snprintf_chk () at /lib64/libc.so.6
- #7 0x0000555555b1c1fd in pcibus_get_fw_dev_path ()
- #8 0x0000555555f2bde4 in qdev_get_fw_dev_path_helper.constprop ()
- #9 0x0000555555f2bd86 in qdev_get_fw_dev_path_helper.constprop ()
- #10 0x00005555559a6e5d in get_boot_device_path ()
- #11 0x00005555559a712c in get_boot_devices_list ()
- #12 0x0000555555b1a3d0 in fw_cfg_machine_reset ()
- #13 0x0000555555bf4c2d in pc_machine_reset ()
- #14 0x0000555555c66988 in qemu_system_reset ()
- #15 0x0000555555a6dff6 in qdev_machine_creation_done ()
- #16 0x0000555555c79186 in qmp_x_exit_preconfig.part ()
- #17 0x0000555555c7b459 in qemu_init ()
- #18 0x0000555555960a29 in main ()
-
-Found-by: Dario Faggioli <Dario Faggioli <dfaggioli@suse.com>
-Found-by: Martin Liška <martin.liska@suse.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Claudio Fontana <cfontana@suse.de>
-Message-Id: <20220531114707.18830-1-cfontana@suse.de>
-Reviewed-by: Ani Sinha <ani@anisinha.ca>
-(cherry-picked from commit 36f18c6989a3d1ff1d7a0e50b0868ef3958299b4)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/pci/pci.c | 18 +++++++++---------
- 1 file changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/hw/pci/pci.c b/hw/pci/pci.c
-index dae9119bfe..c69b412434 100644
---- a/hw/pci/pci.c
-+++ b/hw/pci/pci.c
-@@ -2625,15 +2625,15 @@ static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
- static char *pcibus_get_fw_dev_path(DeviceState *dev)
- {
- PCIDevice *d = (PCIDevice *)dev;
-- char path[50], name[33];
-- int off;
--
-- off = snprintf(path, sizeof(path), "%s@%x",
-- pci_dev_fw_name(dev, name, sizeof name),
-- PCI_SLOT(d->devfn));
-- if (PCI_FUNC(d->devfn))
-- snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
-- return g_strdup(path);
-+ char name[33];
-+ int has_func = !!PCI_FUNC(d->devfn);
-+
-+ return g_strdup_printf("%s@%x%s%.*x",
-+ pci_dev_fw_name(dev, name, sizeof(name)),
-+ PCI_SLOT(d->devfn),
-+ has_func ? "," : "",
-+ has_func,
-+ PCI_FUNC(d->devfn));
- }
-
- static char *pcibus_get_dev_path(DeviceState *dev)
diff --git a/debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch b/debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
deleted file mode 100644
index d393ed1..0000000
--- a/debian/patches/extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
-Date: Mon, 23 May 2022 18:26:58 +0200
-Subject: [PATCH] target/i386/kvm: Fix disabling MPX on "-cpu host" with
- MPX-capable host
-
-Since KVM commit 5f76f6f5ff96 ("KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled")
-it is not possible to disable MPX on a "-cpu host" just by adding "-mpx"
-there if the host CPU does indeed support MPX.
-QEMU will fail to set MSR_IA32_VMX_TRUE_{EXIT,ENTRY}_CTLS MSRs in this case
-and so trigger an assertion failure.
-
-Instead, besides "-mpx" one has to explicitly add also
-"-vmx-exit-clear-bndcfgs" and "-vmx-entry-load-bndcfgs" to QEMU command
-line to make it work, which is a bit convoluted.
-
-Make the MPX-related bits in FEAT_VMX_{EXIT,ENTRY}_CTLS dependent on MPX
-being actually enabled so such workarounds are no longer necessary.
-
-Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
-Message-Id: <51aa2125c76363204cc23c27165e778097c33f0b.1653323077.git.maciej.szmigiero@oracle.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry-picked from commit 267b5e7e378afd260004cb37a66a6fcd641e3b53)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- target/i386/cpu.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/target/i386/cpu.c b/target/i386/cpu.c
-index cb6b5467d0..6e6945139b 100644
---- a/target/i386/cpu.c
-+++ b/target/i386/cpu.c
-@@ -1327,6 +1327,14 @@ static FeatureDep feature_dependencies[] = {
- .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_INVPCID },
- .to = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_ENABLE_INVPCID },
- },
-+ {
-+ .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_MPX },
-+ .to = { FEAT_VMX_EXIT_CTLS, VMX_VM_EXIT_CLEAR_BNDCFGS },
-+ },
-+ {
-+ .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_MPX },
-+ .to = { FEAT_VMX_ENTRY_CTLS, VMX_VM_ENTRY_LOAD_BNDCFGS },
-+ },
- {
- .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_RDSEED },
- .to = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_RDSEED_EXITING },
diff --git a/debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch b/debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
deleted file mode 100644
index 6c4d523..0000000
--- a/debian/patches/extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
+++ /dev/null
@@ -1,121 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Mon, 7 Mar 2022 15:38:51 +0000
-Subject: [PATCH] coroutine-ucontext: use QEMU_DEFINE_STATIC_CO_TLS()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Thread-Local Storage variables cannot be used directly from coroutine
-code because the compiler may optimize TLS variable accesses across
-qemu_coroutine_yield() calls. When the coroutine is re-entered from
-another thread the TLS variables from the old thread must no longer be
-used.
-
-Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
-
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Message-Id: <20220307153853.602859-2-stefanha@redhat.com>
-Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 34145a307d849d0b6734d0222a7aa0bb9eef7407)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- util/coroutine-ucontext.c | 38 ++++++++++++++++++++++++--------------
- 1 file changed, 24 insertions(+), 14 deletions(-)
-
-diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c
-index 904b375192..127d5a13c8 100644
---- a/util/coroutine-ucontext.c
-+++ b/util/coroutine-ucontext.c
-@@ -25,6 +25,7 @@
- #include "qemu/osdep.h"
- #include <ucontext.h>
- #include "qemu/coroutine_int.h"
-+#include "qemu/coroutine-tls.h"
-
- #ifdef CONFIG_VALGRIND_H
- #include <valgrind/valgrind.h>
-@@ -66,8 +67,8 @@ typedef struct {
- /**
- * Per-thread coroutine bookkeeping
- */
--static __thread CoroutineUContext leader;
--static __thread Coroutine *current;
-+QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
-+QEMU_DEFINE_STATIC_CO_TLS(CoroutineUContext, leader);
-
- /*
- * va_args to makecontext() must be type 'int', so passing
-@@ -97,14 +98,15 @@ static inline __attribute__((always_inline))
- void finish_switch_fiber(void *fake_stack_save)
- {
- #ifdef CONFIG_ASAN
-+ CoroutineUContext *leaderp = get_ptr_leader();
- const void *bottom_old;
- size_t size_old;
-
- __sanitizer_finish_switch_fiber(fake_stack_save, &bottom_old, &size_old);
-
-- if (!leader.stack) {
-- leader.stack = (void *)bottom_old;
-- leader.stack_size = size_old;
-+ if (!leaderp->stack) {
-+ leaderp->stack = (void *)bottom_old;
-+ leaderp->stack_size = size_old;
- }
- #endif
- #ifdef CONFIG_TSAN
-@@ -161,8 +163,10 @@ static void coroutine_trampoline(int i0, int i1)
-
- /* Initialize longjmp environment and switch back the caller */
- if (!sigsetjmp(self->env, 0)) {
-- start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save, leader.stack,
-- leader.stack_size);
-+ CoroutineUContext *leaderp = get_ptr_leader();
-+
-+ start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save,
-+ leaderp->stack, leaderp->stack_size);
- start_switch_fiber_tsan(&fake_stack_save, self, true); /* true=caller */
- siglongjmp(*(sigjmp_buf *)co->entry_arg, 1);
- }
-@@ -297,7 +301,7 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
- int ret;
- void *fake_stack_save = NULL;
-
-- current = to_;
-+ set_current(to_);
-
- ret = sigsetjmp(from->env, 0);
- if (ret == 0) {
-@@ -315,18 +319,24 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
-
- Coroutine *qemu_coroutine_self(void)
- {
-- if (!current) {
-- current = &leader.base;
-+ Coroutine *self = get_current();
-+ CoroutineUContext *leaderp = get_ptr_leader();
-+
-+ if (!self) {
-+ self = &leaderp->base;
-+ set_current(self);
- }
- #ifdef CONFIG_TSAN
-- if (!leader.tsan_co_fiber) {
-- leader.tsan_co_fiber = __tsan_get_current_fiber();
-+ if (!leaderp->tsan_co_fiber) {
-+ leaderp->tsan_co_fiber = __tsan_get_current_fiber();
- }
- #endif
-- return current;
-+ return self;
- }
-
- bool qemu_in_coroutine(void)
- {
-- return current && current->caller;
-+ Coroutine *self = get_current();
-+
-+ return self && self->caller;
- }
diff --git a/debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch b/debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
deleted file mode 100644
index b5c4d3b..0000000
--- a/debian/patches/extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
+++ /dev/null
@@ -1,123 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Mon, 7 Mar 2022 15:38:52 +0000
-Subject: [PATCH] coroutine: use QEMU_DEFINE_STATIC_CO_TLS()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Thread-Local Storage variables cannot be used directly from coroutine
-code because the compiler may optimize TLS variable accesses across
-qemu_coroutine_yield() calls. When the coroutine is re-entered from
-another thread the TLS variables from the old thread must no longer be
-used.
-
-Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
-The alloc_pool QSLIST needs a typedef so the return value of
-get_ptr_alloc_pool() can be stored in a local variable.
-
-One example of why this code is necessary: a coroutine that yields
-before calling qemu_coroutine_create() to create another coroutine is
-affected by the TLS issue.
-
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Message-Id: <20220307153853.602859-3-stefanha@redhat.com>
-Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit ac387a08a9c9f6b36757da912f0339c25f421f90)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- util/qemu-coroutine.c | 41 ++++++++++++++++++++++++-----------------
- 1 file changed, 24 insertions(+), 17 deletions(-)
-
-diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
-index c03b2422ff..f3e8300c8d 100644
---- a/util/qemu-coroutine.c
-+++ b/util/qemu-coroutine.c
-@@ -18,6 +18,7 @@
- #include "qemu/atomic.h"
- #include "qemu/coroutine.h"
- #include "qemu/coroutine_int.h"
-+#include "qemu/coroutine-tls.h"
- #include "block/aio.h"
-
- /** Initial batch size is 64, and is increased on demand */
-@@ -29,17 +30,20 @@ enum {
- static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
- static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE;
- static unsigned int release_pool_size;
--static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
--static __thread unsigned int alloc_pool_size;
--static __thread Notifier coroutine_pool_cleanup_notifier;
-+
-+typedef QSLIST_HEAD(, Coroutine) CoroutineQSList;
-+QEMU_DEFINE_STATIC_CO_TLS(CoroutineQSList, alloc_pool);
-+QEMU_DEFINE_STATIC_CO_TLS(unsigned int, alloc_pool_size);
-+QEMU_DEFINE_STATIC_CO_TLS(Notifier, coroutine_pool_cleanup_notifier);
-
- static void coroutine_pool_cleanup(Notifier *n, void *value)
- {
- Coroutine *co;
- Coroutine *tmp;
-+ CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
-
-- QSLIST_FOREACH_SAFE(co, &alloc_pool, pool_next, tmp) {
-- QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
-+ QSLIST_FOREACH_SAFE(co, alloc_pool, pool_next, tmp) {
-+ QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
- qemu_coroutine_delete(co);
- }
- }
-@@ -49,27 +53,30 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
- Coroutine *co = NULL;
-
- if (CONFIG_COROUTINE_POOL) {
-- co = QSLIST_FIRST(&alloc_pool);
-+ CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
-+
-+ co = QSLIST_FIRST(alloc_pool);
- if (!co) {
- if (release_pool_size > qatomic_read(&pool_batch_size)) {
- /* Slow path; a good place to register the destructor, too. */
-- if (!coroutine_pool_cleanup_notifier.notify) {
-- coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
-- qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
-+ Notifier *notifier = get_ptr_coroutine_pool_cleanup_notifier();
-+ if (!notifier->notify) {
-+ notifier->notify = coroutine_pool_cleanup;
-+ qemu_thread_atexit_add(notifier);
- }
-
- /* This is not exact; there could be a little skew between
- * release_pool_size and the actual size of release_pool. But
- * it is just a heuristic, it does not need to be perfect.
- */
-- alloc_pool_size = qatomic_xchg(&release_pool_size, 0);
-- QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool);
-- co = QSLIST_FIRST(&alloc_pool);
-+ set_alloc_pool_size(qatomic_xchg(&release_pool_size, 0));
-+ QSLIST_MOVE_ATOMIC(alloc_pool, &release_pool);
-+ co = QSLIST_FIRST(alloc_pool);
- }
- }
- if (co) {
-- QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
-- alloc_pool_size--;
-+ QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
-+ set_alloc_pool_size(get_alloc_pool_size() - 1);
- }
- }
-
-@@ -93,9 +100,9 @@ static void coroutine_delete(Coroutine *co)
- qatomic_inc(&release_pool_size);
- return;
- }
-- if (alloc_pool_size < qatomic_read(&pool_batch_size)) {
-- QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
-- alloc_pool_size++;
-+ if (get_alloc_pool_size() < qatomic_read(&pool_batch_size)) {
-+ QSLIST_INSERT_HEAD(get_ptr_alloc_pool(), co, pool_next);
-+ set_alloc_pool_size(get_alloc_pool_size() + 1);
- return;
- }
- }
diff --git a/debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch b/debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
deleted file mode 100644
index 9459471..0000000
--- a/debian/patches/extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Kevin Wolf <kwolf@redhat.com>
-Date: Tue, 10 May 2022 17:10:19 +0200
-Subject: [PATCH] coroutine: Rename qemu_coroutine_inc/dec_pool_size()
-
-It's true that these functions currently affect the batch size in which
-coroutines are reused (i.e. moved from the global release pool to the
-allocation pool of a specific thread), but this is a bug and will be
-fixed in a separate patch.
-
-In fact, the comment in the header file already just promises that it
-influences the pool size, so reflect this in the name of the functions.
-As a nice side effect, the shorter function name makes some line
-wrapping unnecessary.
-
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-Message-Id: <20220510151020.105528-2-kwolf@redhat.com>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 98e3ab35054b946f7c2aba5408822532b0920b53)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/block/virtio-blk.c | 6 ++----
- include/qemu/coroutine.h | 6 +++---
- util/qemu-coroutine.c | 4 ++--
- 3 files changed, 7 insertions(+), 9 deletions(-)
-
-diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
-index 540c38f829..6a1cc41877 100644
---- a/hw/block/virtio-blk.c
-+++ b/hw/block/virtio-blk.c
-@@ -1215,8 +1215,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
- for (i = 0; i < conf->num_queues; i++) {
- virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
- }
-- qemu_coroutine_increase_pool_batch_size(conf->num_queues * conf->queue_size
-- / 2);
-+ qemu_coroutine_inc_pool_size(conf->num_queues * conf->queue_size / 2);
- virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
- if (err != NULL) {
- error_propagate(errp, err);
-@@ -1253,8 +1252,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev)
- for (i = 0; i < conf->num_queues; i++) {
- virtio_del_queue(vdev, i);
- }
-- qemu_coroutine_decrease_pool_batch_size(conf->num_queues * conf->queue_size
-- / 2);
-+ qemu_coroutine_dec_pool_size(conf->num_queues * conf->queue_size / 2);
- qemu_del_vm_change_state_handler(s->change);
- blockdev_mark_auto_del(s->blk);
- virtio_cleanup(vdev);
-diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
-index c828a95ee0..5b621d1295 100644
---- a/include/qemu/coroutine.h
-+++ b/include/qemu/coroutine.h
-@@ -334,12 +334,12 @@ void coroutine_fn yield_until_fd_readable(int fd);
- /**
- * Increase coroutine pool size
- */
--void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size);
-+void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size);
-
- /**
-- * Devcrease coroutine pool size
-+ * Decrease coroutine pool size
- */
--void qemu_coroutine_decrease_pool_batch_size(unsigned int additional_pool_size);
-+void qemu_coroutine_dec_pool_size(unsigned int additional_pool_size);
-
- #include "qemu/lockable.h"
-
-diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
-index f3e8300c8d..ea23929a74 100644
---- a/util/qemu-coroutine.c
-+++ b/util/qemu-coroutine.c
-@@ -212,12 +212,12 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
- return co->ctx;
- }
-
--void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size)
-+void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size)
- {
- qatomic_add(&pool_batch_size, additional_pool_size);
- }
-
--void qemu_coroutine_decrease_pool_batch_size(unsigned int removing_pool_size)
-+void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size)
- {
- qatomic_sub(&pool_batch_size, removing_pool_size);
- }
diff --git a/debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch b/debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch
deleted file mode 100644
index 711ffe0..0000000
--- a/debian/patches/extra/0010-coroutine-Revert-to-constant-batch-size.patch
+++ /dev/null
@@ -1,121 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Kevin Wolf <kwolf@redhat.com>
-Date: Tue, 10 May 2022 17:10:20 +0200
-Subject: [PATCH] coroutine: Revert to constant batch size
-
-Commit 4c41c69e changed the way the coroutine pool is sized because for
-virtio-blk devices with a large queue size and heavy I/O, it was just
-too small and caused coroutines to be deleted and reallocated soon
-afterwards. The change made the size dynamic based on the number of
-queues and the queue size of virtio-blk devices.
-
-There are two important numbers here: Slightly simplified, when a
-coroutine terminates, it is generally stored in the global release pool
-up to a certain pool size, and if the pool is full, it is freed.
-Conversely, when allocating a new coroutine, the coroutines in the
-release pool are reused if the pool already has reached a certain
-minimum size (the batch size), otherwise we allocate new coroutines.
-
-The problem after commit 4c41c69e is that it not only increases the
-maximum pool size (which is the intended effect), but also the batch
-size for reusing coroutines (which is a bug). It means that in cases
-with many devices and/or a large queue size (which defaults to the
-number of vcpus for virtio-blk-pci), many thousand coroutines could be
-sitting in the release pool without being reused.
-
-This is not only a waste of memory and allocations, but it actually
-makes the QEMU process likely to hit the vm.max_map_count limit on Linux
-because each coroutine requires two mappings (its stack and the guard
-page for the stack), causing it to abort() in qemu_alloc_stack() because
-when the limit is hit, mprotect() starts to fail with ENOMEM.
-
-In order to fix the problem, change the batch size back to 64 to avoid
-uselessly accumulating coroutines in the release pool, but keep the
-dynamic maximum pool size so that coroutines aren't freed too early
-in heavy I/O scenarios.
-
-Note that this fix doesn't strictly make it impossible to hit the limit,
-but this would only happen if most of the coroutines are actually in use
-at the same time, not just sitting in a pool. This is the same behaviour
-as we already had before commit 4c41c69e. Fully preventing this would
-require allowing qemu_coroutine_create() to return an error, but it
-doesn't seem to be a scenario that people hit in practice.
-
-Cc: qemu-stable@nongnu.org
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2079938
-Fixes: 4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-Message-Id: <20220510151020.105528-3-kwolf@redhat.com>
-Tested-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
-Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-(cherry-picked from commit 9ec7a59b5aad4b736871c378d30f5ef5ec51cb52)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- util/qemu-coroutine.c | 22 ++++++++++++++--------
- 1 file changed, 14 insertions(+), 8 deletions(-)
-
-diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
-index ea23929a74..4a8bd63ef0 100644
---- a/util/qemu-coroutine.c
-+++ b/util/qemu-coroutine.c
-@@ -21,14 +21,20 @@
- #include "qemu/coroutine-tls.h"
- #include "block/aio.h"
-
--/** Initial batch size is 64, and is increased on demand */
-+/**
-+ * The minimal batch size is always 64, coroutines from the release_pool are
-+ * reused as soon as there are 64 coroutines in it. The maximum pool size starts
-+ * with 64 and is increased on demand so that coroutines are not deleted even if
-+ * they are not immediately reused.
-+ */
- enum {
-- POOL_INITIAL_BATCH_SIZE = 64,
-+ POOL_MIN_BATCH_SIZE = 64,
-+ POOL_INITIAL_MAX_SIZE = 64,
- };
-
- /** Free list to speed up creation */
- static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
--static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE;
-+static unsigned int pool_max_size = POOL_INITIAL_MAX_SIZE;
- static unsigned int release_pool_size;
-
- typedef QSLIST_HEAD(, Coroutine) CoroutineQSList;
-@@ -57,7 +63,7 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
-
- co = QSLIST_FIRST(alloc_pool);
- if (!co) {
-- if (release_pool_size > qatomic_read(&pool_batch_size)) {
-+ if (release_pool_size > POOL_MIN_BATCH_SIZE) {
- /* Slow path; a good place to register the destructor, too. */
- Notifier *notifier = get_ptr_coroutine_pool_cleanup_notifier();
- if (!notifier->notify) {
-@@ -95,12 +101,12 @@ static void coroutine_delete(Coroutine *co)
- co->caller = NULL;
-
- if (CONFIG_COROUTINE_POOL) {
-- if (release_pool_size < qatomic_read(&pool_batch_size) * 2) {
-+ if (release_pool_size < qatomic_read(&pool_max_size) * 2) {
- QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next);
- qatomic_inc(&release_pool_size);
- return;
- }
-- if (get_alloc_pool_size() < qatomic_read(&pool_batch_size)) {
-+ if (get_alloc_pool_size() < qatomic_read(&pool_max_size)) {
- QSLIST_INSERT_HEAD(get_ptr_alloc_pool(), co, pool_next);
- set_alloc_pool_size(get_alloc_pool_size() + 1);
- return;
-@@ -214,10 +220,10 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
-
- void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size)
- {
-- qatomic_add(&pool_batch_size, additional_pool_size);
-+ qatomic_add(&pool_max_size, additional_pool_size);
- }
-
- void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size)
- {
-- qatomic_sub(&pool_batch_size, removing_pool_size);
-+ qatomic_sub(&pool_max_size, removing_pool_size);
- }
diff --git a/debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch b/debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
deleted file mode 100644
index cf535bb..0000000
--- a/debian/patches/extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
+++ /dev/null
@@ -1,117 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Paolo Bonzini <pbonzini@redhat.com>
-Date: Fri, 29 Apr 2022 21:16:28 +0200
-Subject: [PATCH] target/i386: do not consult nonexistent host leaves
-
-When cache_info_passthrough is requested, QEMU passes the host values
-of the cache information CPUID leaves down to the guest. However,
-it blindly assumes that the CPUID leaf exists on the host, and this
-cannot be guaranteed: for example, KVM has recently started to
-synthesize AMD leaves up to 0x80000021 in order to provide accurate
-CPU bug information to guests.
-
-Querying a nonexistent host leaf fills the output arguments of
-host_cpuid with data that (albeit deterministic) is nonsensical
-as cache information, namely the data in the highest Intel CPUID
-leaf. If said highest leaf is not ECX-dependent, this can even
-cause an infinite loop when kvm_arch_init_vcpu prepares the input
-to KVM_SET_CPUID2. The infinite loop is only terminated by an
-abort() when the array gets full.
-
-Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
-Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-(cherry-picked from commit 798d8ec0dacd4cc0034298d94f430c14f23e2919)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- target/i386/cpu.c | 41 ++++++++++++++++++++++++++++++++++++-----
- 1 file changed, 36 insertions(+), 5 deletions(-)
-
-diff --git a/target/i386/cpu.c b/target/i386/cpu.c
-index 6e6945139b..c79e151887 100644
---- a/target/i386/cpu.c
-+++ b/target/i386/cpu.c
-@@ -5030,6 +5030,37 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
- return r;
- }
-
-+static void x86_cpu_get_cache_cpuid(uint32_t func, uint32_t index,
-+ uint32_t *eax, uint32_t *ebx,
-+ uint32_t *ecx, uint32_t *edx)
-+{
-+ uint32_t level, unused;
-+
-+ /* Only return valid host leaves. */
-+ switch (func) {
-+ case 2:
-+ case 4:
-+ host_cpuid(0, 0, &level, &unused, &unused, &unused);
-+ break;
-+ case 0x80000005:
-+ case 0x80000006:
-+ case 0x8000001d:
-+ host_cpuid(0x80000000, 0, &level, &unused, &unused, &unused);
-+ break;
-+ default:
-+ return;
-+ }
-+
-+ if (func > level) {
-+ *eax = 0;
-+ *ebx = 0;
-+ *ecx = 0;
-+ *edx = 0;
-+ } else {
-+ host_cpuid(func, index, eax, ebx, ecx, edx);
-+ }
-+}
-+
- /*
- * Only for builtin_x86_defs models initialized with x86_register_cpudef_types.
- */
-@@ -5288,7 +5319,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 2:
- /* cache info: needed for Pentium Pro compatibility */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, 0, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, 0, eax, ebx, ecx, edx);
- break;
- } else if (cpu->vendor_cpuid_only && IS_AMD_CPU(env)) {
- *eax = *ebx = *ecx = *edx = 0;
-@@ -5308,7 +5339,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 4:
- /* cache info: needed for Core compatibility */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, count, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, count, eax, ebx, ecx, edx);
- /* QEMU gives out its own APIC IDs, never pass down bits 31..26. */
- *eax &= ~0xFC000000;
- if ((*eax & 31) && cs->nr_cores > 1) {
-@@ -5710,7 +5741,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 0x80000005:
- /* cache info (L1 cache) */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, 0, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, 0, eax, ebx, ecx, edx);
- break;
- }
- *eax = (L1_DTLB_2M_ASSOC << 24) | (L1_DTLB_2M_ENTRIES << 16) |
-@@ -5723,7 +5754,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 0x80000006:
- /* cache info (L2 cache) */
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, 0, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, 0, eax, ebx, ecx, edx);
- break;
- }
- *eax = (AMD_ENC_ASSOC(L2_DTLB_2M_ASSOC) << 28) |
-@@ -5783,7 +5814,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
- case 0x8000001D:
- *eax = 0;
- if (cpu->cache_info_passthrough) {
-- host_cpuid(index, count, eax, ebx, ecx, edx);
-+ x86_cpu_get_cache_cpuid(index, count, eax, ebx, ecx, edx);
- break;
- }
- switch (count) {
diff --git a/debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch b/debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
deleted file mode 100644
index 92a57cf..0000000
--- a/debian/patches/extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Wed, 27 Apr 2022 15:35:36 +0100
-Subject: [PATCH] virtio-scsi: fix ctrl and event handler functions in
- dataplane mode
-
-Commit f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare
-virtio_scsi_handle_cmd for dataplane") prepared the virtio-scsi cmd
-virtqueue handler function to be used in both the dataplane and
-non-datpalane code paths.
-
-It failed to convert the ctrl and event virtqueue handler functions,
-which are not designed to be called from the dataplane code path but
-will be since the ioeventfd is set up for those virtqueues when
-dataplane starts.
-
-Convert the ctrl and event virtqueue handler functions now so they
-operate correctly when called from the dataplane code path. Avoid code
-duplication by extracting this code into a helper function.
-
-Fixes: f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane")
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
-Message-id: 20220427143541.119567-2-stefanha@redhat.com
-[Fixed s/by used/be used/ typo pointed out by Michael Tokarev
-<mjt@tls.msk.ru>.
---Stefan]
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit 2f743ef6366c2df4ef51ef3ae318138cdc0125ab)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/scsi/virtio-scsi.c | 42 +++++++++++++++++++++++++++---------------
- 1 file changed, 27 insertions(+), 15 deletions(-)
-
-diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
-index 34a968ecfb..417fbc71d6 100644
---- a/hw/scsi/virtio-scsi.c
-+++ b/hw/scsi/virtio-scsi.c
-@@ -472,16 +472,32 @@ bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
- return progress;
- }
-
-+/*
-+ * If dataplane is configured but not yet started, do so now and return true on
-+ * success.
-+ *
-+ * Dataplane is started by the core virtio code but virtqueue handler functions
-+ * can also be invoked when a guest kicks before DRIVER_OK, so this helper
-+ * function helps us deal with manually starting ioeventfd in that case.
-+ */
-+static bool virtio_scsi_defer_to_dataplane(VirtIOSCSI *s)
-+{
-+ if (!s->ctx || s->dataplane_started) {
-+ return false;
-+ }
-+
-+ virtio_device_start_ioeventfd(&s->parent_obj.parent_obj);
-+ return !s->dataplane_fenced;
-+}
-+
- static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
- {
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
-
-- if (s->ctx) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_ctrl_vq(s, vq);
- virtio_scsi_release(s);
-@@ -720,12 +736,10 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
- /* use non-QOM casts in the data path */
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
-
-- if (s->ctx && !s->dataplane_started) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_cmd_vq(s, vq);
- virtio_scsi_release(s);
-@@ -855,12 +869,10 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
- {
- VirtIOSCSI *s = VIRTIO_SCSI(vdev);
-
-- if (s->ctx) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_event_vq(s, vq);
- virtio_scsi_release(s);
diff --git a/debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch b/debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
deleted file mode 100644
index 238d456..0000000
--- a/debian/patches/extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Wed, 27 Apr 2022 15:35:37 +0100
-Subject: [PATCH] virtio-scsi: don't waste CPU polling the event virtqueue
-
-The virtio-scsi event virtqueue is not emptied by its handler function.
-This is typical for rx virtqueues where the device uses buffers when
-some event occurs (e.g. a packet is received, an error condition
-happens, etc).
-
-Polling non-empty virtqueues wastes CPU cycles. We are not waiting for
-new buffers to become available, we are waiting for an event to occur,
-so it's a misuse of CPU resources to poll for buffers.
-
-Introduce the new virtio_queue_aio_attach_host_notifier_no_poll() API,
-which is identical to virtio_queue_aio_attach_host_notifier() except
-that it does not poll the virtqueue.
-
-Before this patch the following command-line consumed 100% CPU in the
-IOThread polling and calling virtio_scsi_handle_event():
-
- $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
- --object iothread,id=iothread0 \
- --device virtio-scsi-pci,iothread=iothread0 \
- --blockdev file,filename=test.img,aio=native,cache.direct=on,node-name=drive0 \
- --device scsi-hd,drive=drive0
-
-After this patch CPU is no longer wasted.
-
-Reported-by: Nir Soffer <nsoffer@redhat.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Tested-by: Nir Soffer <nsoffer@redhat.com>
-Message-id: 20220427143541.119567-3-stefanha@redhat.com
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit 38738f7dbbda90fbc161757b7f4be35b52205552)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/scsi/virtio-scsi-dataplane.c | 2 +-
- hw/virtio/virtio.c | 13 +++++++++++++
- include/hw/virtio/virtio.h | 1 +
- 3 files changed, 15 insertions(+), 1 deletion(-)
-
-diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
-index 29575cbaf6..8bb6e6acfc 100644
---- a/hw/scsi/virtio-scsi-dataplane.c
-+++ b/hw/scsi/virtio-scsi-dataplane.c
-@@ -138,7 +138,7 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
-
- aio_context_acquire(s->ctx);
- virtio_queue_aio_attach_host_notifier(vs->ctrl_vq, s->ctx);
-- virtio_queue_aio_attach_host_notifier(vs->event_vq, s->ctx);
-+ virtio_queue_aio_attach_host_notifier_no_poll(vs->event_vq, s->ctx);
-
- for (i = 0; i < vs->conf.num_queues; i++) {
- virtio_queue_aio_attach_host_notifier(vs->cmd_vqs[i], s->ctx);
-diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
-index 9d637e043e..67a873f54a 100644
---- a/hw/virtio/virtio.c
-+++ b/hw/virtio/virtio.c
-@@ -3534,6 +3534,19 @@ void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx)
- virtio_queue_host_notifier_aio_poll_end);
- }
-
-+/*
-+ * Same as virtio_queue_aio_attach_host_notifier() but without polling. Use
-+ * this for rx virtqueues and similar cases where the virtqueue handler
-+ * function does not pop all elements. When the virtqueue is left non-empty
-+ * polling consumes CPU cycles and should not be used.
-+ */
-+void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx)
-+{
-+ aio_set_event_notifier(ctx, &vq->host_notifier, true,
-+ virtio_queue_host_notifier_read,
-+ NULL, NULL);
-+}
-+
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx)
- {
- aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL, NULL);
-diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
-index b31c4507f5..b62a35fdca 100644
---- a/include/hw/virtio/virtio.h
-+++ b/include/hw/virtio/virtio.h
-@@ -317,6 +317,7 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
- void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
- void virtio_queue_host_notifier_read(EventNotifier *n);
- void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx);
-+void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx);
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
- VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
- VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
diff --git a/debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch b/debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
deleted file mode 100644
index 2f52fd3..0000000
--- a/debian/patches/extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
+++ /dev/null
@@ -1,102 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:42 +0200
-Subject: [PATCH] vhost: Track descriptor chain in private at SVQ
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The device could have access to modify them, and it definitely have
-access when we implement packed vq. Harden SVQ maintaining a private
-copy of the descriptor chain. Other fields like buffer addresses are
-already maintained sepparatedly.
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-2-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 495fe3a78749c39c0e772c4e1a55d6cb8a7e5292)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-shadow-virtqueue.c | 12 +++++++-----
- hw/virtio/vhost-shadow-virtqueue.h | 6 ++++++
- 2 files changed, 13 insertions(+), 5 deletions(-)
-
-diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
-index b232803d1b..3155801f50 100644
---- a/hw/virtio/vhost-shadow-virtqueue.c
-+++ b/hw/virtio/vhost-shadow-virtqueue.c
-@@ -138,6 +138,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
- for (n = 0; n < num; n++) {
- if (more_descs || (n + 1 < num)) {
- descs[i].flags = flags | cpu_to_le16(VRING_DESC_F_NEXT);
-+ descs[i].next = cpu_to_le16(svq->desc_next[i]);
- } else {
- descs[i].flags = flags;
- }
-@@ -145,10 +146,10 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr *sg,
- descs[i].len = cpu_to_le32(iovec[n].iov_len);
-
- last = i;
-- i = cpu_to_le16(descs[i].next);
-+ i = cpu_to_le16(svq->desc_next[i]);
- }
-
-- svq->free_head = le16_to_cpu(descs[last].next);
-+ svq->free_head = le16_to_cpu(svq->desc_next[last]);
- }
-
- static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
-@@ -336,7 +337,6 @@ static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
- static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- uint32_t *len)
- {
-- vring_desc_t *descs = svq->vring.desc;
- const vring_used_t *used = svq->vring.used;
- vring_used_elem_t used_elem;
- uint16_t last_used;
-@@ -365,7 +365,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- return NULL;
- }
-
-- descs[used_elem.id].next = svq->free_head;
-+ svq->desc_next[used_elem.id] = svq->free_head;
- svq->free_head = used_elem.id;
-
- *len = used_elem.len;
-@@ -540,8 +540,9 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
- svq->vring.used = qemu_memalign(qemu_real_host_page_size, device_size);
- memset(svq->vring.used, 0, device_size);
- svq->ring_id_maps = g_new0(VirtQueueElement *, svq->vring.num);
-+ svq->desc_next = g_new0(uint16_t, svq->vring.num);
- for (unsigned i = 0; i < svq->vring.num - 1; i++) {
-- svq->vring.desc[i].next = cpu_to_le16(i + 1);
-+ svq->desc_next[i] = cpu_to_le16(i + 1);
- }
- }
-
-@@ -574,6 +575,7 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
- virtqueue_detach_element(svq->vq, next_avail_elem, 0);
- }
- svq->vq = NULL;
-+ g_free(svq->desc_next);
- g_free(svq->ring_id_maps);
- qemu_vfree(svq->vring.desc);
- qemu_vfree(svq->vring.used);
-diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
-index e5e24c536d..c132c994e9 100644
---- a/hw/virtio/vhost-shadow-virtqueue.h
-+++ b/hw/virtio/vhost-shadow-virtqueue.h
-@@ -53,6 +53,12 @@ typedef struct VhostShadowVirtqueue {
- /* Next VirtQueue element that guest made available */
- VirtQueueElement *next_guest_avail_elem;
-
-+ /*
-+ * Backup next field for each descriptor so we can recover securely, not
-+ * needing to trust the device access.
-+ */
-+ uint16_t *desc_next;
-+
- /* Next head to expose to the device */
- uint16_t shadow_avail_idx;
-
diff --git a/debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch b/debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
deleted file mode 100644
index 497bcec..0000000
--- a/debian/patches/extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:43 +0200
-Subject: [PATCH] vhost: Fix device's used descriptor dequeue
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Only the first one of them were properly enqueued back.
-
-Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-3-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 81abfa5724c9a6502d7a1d3a67c55f2a303a1170)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-shadow-virtqueue.c | 17 +++++++++++++++--
- 1 file changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
-index 3155801f50..31fc50907d 100644
---- a/hw/virtio/vhost-shadow-virtqueue.c
-+++ b/hw/virtio/vhost-shadow-virtqueue.c
-@@ -334,12 +334,22 @@ static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
- svq->vring.avail->flags |= cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
- }
-
-+static uint16_t vhost_svq_last_desc_of_chain(const VhostShadowVirtqueue *svq,
-+ uint16_t num, uint16_t i)
-+{
-+ for (uint16_t j = 0; j < (num - 1); ++j) {
-+ i = le16_to_cpu(svq->desc_next[i]);
-+ }
-+
-+ return i;
-+}
-+
- static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- uint32_t *len)
- {
- const vring_used_t *used = svq->vring.used;
- vring_used_elem_t used_elem;
-- uint16_t last_used;
-+ uint16_t last_used, last_used_chain, num;
-
- if (!vhost_svq_more_used(svq)) {
- return NULL;
-@@ -365,7 +375,10 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
- return NULL;
- }
-
-- svq->desc_next[used_elem.id] = svq->free_head;
-+ num = svq->ring_id_maps[used_elem.id]->in_num +
-+ svq->ring_id_maps[used_elem.id]->out_num;
-+ last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
-+ svq->desc_next[last_used_chain] = svq->free_head;
- svq->free_head = used_elem.id;
-
- *len = used_elem.len;
diff --git a/debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch b/debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
deleted file mode 100644
index 6f33164..0000000
--- a/debian/patches/extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:44 +0200
-Subject: [PATCH] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Fixes: 6d0b222666 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ")
-
-Acked-by: Jason Wang <jasowang@redhat.com>
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-4-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 639036477ef890958415967e753ca2cbb348c16c)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-vdpa.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
-index 8adf7c0b92..8555a84f87 100644
---- a/hw/virtio/vhost-vdpa.c
-+++ b/hw/virtio/vhost-vdpa.c
-@@ -1170,11 +1170,11 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
- struct vhost_vring_state *ring)
- {
- struct vhost_vdpa *v = dev->opaque;
-+ int vdpa_idx = ring->index - dev->vq_index;
- int ret;
-
- if (v->shadow_vqs_enabled) {
-- VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs,
-- ring->index);
-+ VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, vdpa_idx);
-
- /*
- * Setting base as last used idx, so destination will see as available
diff --git a/debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch b/debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
deleted file mode 100644
index 8c74f0c..0000000
--- a/debian/patches/extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:45 +0200
-Subject: [PATCH] vdpa: Fix index calculus at vhost_vdpa_svqs_start
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-With the introduction of MQ the index of the vq needs to be calculated
-with the device model vq_index.
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Acked-by: Jason Wang <jasowang@redhat.com>
-Message-Id: <20220512175747.142058-5-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 1c82fdfef8a227518ffecae9d419bcada995c202)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-vdpa.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
-index 8555a84f87..aa43cfa7d9 100644
---- a/hw/virtio/vhost-vdpa.c
-+++ b/hw/virtio/vhost-vdpa.c
-@@ -1016,7 +1016,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
- VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
- VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
- struct vhost_vring_addr addr = {
-- .index = i,
-+ .index = dev->vq_index + i,
- };
- int r;
- bool ok = vhost_vdpa_svq_setup(dev, svq, i, &err);
diff --git a/debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch b/debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
deleted file mode 100644
index 12ea0ad..0000000
--- a/debian/patches/extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
-Date: Thu, 12 May 2022 19:57:46 +0200
-Subject: [PATCH] hw/virtio: Replace g_memdup() by g_memdup2()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Per https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538
-
- The old API took the size of the memory to duplicate as a guint,
- whereas most memory functions take memory sizes as a gsize. This
- made it easy to accidentally pass a gsize to g_memdup(). For large
- values, that would lead to a silent truncation of the size from 64
- to 32 bits, and result in a heap area being returned which is
- significantly smaller than what the caller expects. This can likely
- be exploited in various modules to cause a heap buffer overflow.
-
-Replace g_memdup() by the safer g_memdup2() wrapper.
-
-Acked-by: Jason Wang <jasowang@redhat.com>
-Acked-by: Eugenio Pérez <eperezma@redhat.com>
-Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
-Message-Id: <20220512175747.142058-6-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit d792199de55ca5cb5334016884039c740290b5c7)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/net/virtio-net.c | 3 ++-
- hw/virtio/virtio-crypto.c | 6 +++---
- 2 files changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
-index 1067e72b39..e4748a7e6c 100644
---- a/hw/net/virtio-net.c
-+++ b/hw/net/virtio-net.c
-@@ -1443,7 +1443,8 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
- }
-
- iov_cnt = elem->out_num;
-- iov2 = iov = g_memdup(elem->out_sg, sizeof(struct iovec) * elem->out_num);
-+ iov2 = iov = g_memdup2(elem->out_sg,
-+ sizeof(struct iovec) * elem->out_num);
- s = iov_to_buf(iov, iov_cnt, 0, &ctrl, sizeof(ctrl));
- iov_discard_front(&iov, &iov_cnt, sizeof(ctrl));
- if (s != sizeof(ctrl)) {
-diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
-index dcd80b904d..0e31e3cc04 100644
---- a/hw/virtio/virtio-crypto.c
-+++ b/hw/virtio/virtio-crypto.c
-@@ -242,7 +242,7 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
- }
-
- out_num = elem->out_num;
-- out_iov_copy = g_memdup(elem->out_sg, sizeof(out_iov[0]) * out_num);
-+ out_iov_copy = g_memdup2(elem->out_sg, sizeof(out_iov[0]) * out_num);
- out_iov = out_iov_copy;
-
- in_num = elem->in_num;
-@@ -605,11 +605,11 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)
- }
-
- out_num = elem->out_num;
-- out_iov_copy = g_memdup(elem->out_sg, sizeof(out_iov[0]) * out_num);
-+ out_iov_copy = g_memdup2(elem->out_sg, sizeof(out_iov[0]) * out_num);
- out_iov = out_iov_copy;
-
- in_num = elem->in_num;
-- in_iov_copy = g_memdup(elem->in_sg, sizeof(in_iov[0]) * in_num);
-+ in_iov_copy = g_memdup2(elem->in_sg, sizeof(in_iov[0]) * in_num);
- in_iov = in_iov_copy;
-
- if (unlikely(iov_to_buf(out_iov, out_num, 0, &req, sizeof(req))
diff --git a/debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch b/debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
deleted file mode 100644
index daa5bca..0000000
--- a/debian/patches/extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
-Date: Thu, 12 May 2022 19:57:47 +0200
-Subject: [PATCH] vhost: Fix element in vhost_svq_add failure
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Coverity rightly reports that is not free in that case.
-
-Fixes: Coverity CID 1487559
-Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
-
-Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
-Message-Id: <20220512175747.142058-7-eperezma@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry-picked from commit 5181db132b587754dda3a520eec923b87a65bbb7)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/virtio/vhost-shadow-virtqueue.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
-index 31fc50907d..06d0bb39d9 100644
---- a/hw/virtio/vhost-shadow-virtqueue.c
-+++ b/hw/virtio/vhost-shadow-virtqueue.c
-@@ -199,11 +199,19 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
- return true;
- }
-
-+/**
-+ * Add an element to a SVQ.
-+ *
-+ * The caller must check that there is enough slots for the new element. It
-+ * takes ownership of the element: In case of failure, it is free and the SVQ
-+ * is considered broken.
-+ */
- static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
- {
- unsigned qemu_head;
- bool ok = vhost_svq_add_split(svq, elem, &qemu_head);
- if (unlikely(!ok)) {
-+ g_free(elem);
- return false;
- }
-
diff --git a/debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch b/debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch
deleted file mode 100644
index 88cf137..0000000
--- a/debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Dominique Martinet <dominique.martinet@atmark-techno.com>
-Date: Thu, 30 Jun 2022 10:01:37 +0900
-Subject: [PATCH] io_uring: fix short read slow path
-
-sqeq.off here is the offset to read within the disk image, so obviously
-not 'nread' (the amount we just read), but as the author meant to write
-its current value incremented by the amount we just read.
-
-Normally recent versions of linux will not issue short reads,
-but it can happen so we should fix this.
-
-This lead to weird image corruptions when short read happened
-
-Fixes: 6663a0a33764 ("block/io_uring: implements interfaces for io_uring")
-Link: https://lkml.kernel.org/r/YrrFGO4A1jS0GI0G@atmark-techno.com
-Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
-Message-Id: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com>
-Reviewed-by: Hanna Reitz <hreitz@redhat.com>
-Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-(cherry-picked from commit c06fc7ce147e57ab493bad9263f1601b8298484b)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/io_uring.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/block/io_uring.c b/block/io_uring.c
-index 782afdb433..e451e55de0 100644
---- a/block/io_uring.c
-+++ b/block/io_uring.c
-@@ -89,7 +89,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
- trace_luring_resubmit_short_read(s, luringcb, nread);
-
- /* Update read position */
-- luringcb->total_read = nread;
-+ luringcb->total_read += nread;
- remaining = luringcb->qiov->size - luringcb->total_read;
-
- /* Shorten qiov */
-@@ -103,7 +103,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
- remaining);
-
- /* Update sqe */
-- luringcb->sqeq.off = nread;
-+ luringcb->sqeq.off += nread;
- luringcb->sqeq.addr = (__u64)(uintptr_t)luringcb->resubmit_qiov.iov;
- luringcb->sqeq.len = luringcb->resubmit_qiov.niov;
-
diff --git a/debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch b/debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
deleted file mode 100644
index ee66fba..0000000
--- a/debian/patches/extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Ding Hui <dinghui@sangfor.com.cn>
-Date: Wed, 29 Jun 2022 17:40:26 +0800
-Subject: [PATCH] e1000: set RX descriptor status in a separate operation
-
-The code of setting RX descriptor status field maybe work fine in
-previously, however with the update of glibc version, it shows two
-issues when guest using dpdk receive packets:
-
- 1. The dpdk has a certain probability getting wrong buffer_addr
-
- this impact may be not obvious, such as lost a packet once in
- a while
-
- 2. The dpdk may consume a packet twice when scan the RX desc queue
- over again
-
- this impact will lead a infinite wait in Qemu, since the RDT
- (tail pointer) be inscreased to equal to RDH by unexpected,
- which regard as the RX desc queue is full
-
-Write a whole of RX desc with DD flag on is not quite correct, because
-when the underlying implementation of memcpy using XMM registers to
-copy e1000_rx_desc (when AVX or something else CPU feature is usable),
-the bytes order of desc writing to memory is indeterminacy
-
-We can use full-scale test case to reproduce the issue-2 by
-https://github.com/BASM/qemu_dpdk_e1000_test (thanks to Leonid Myravjev)
-
-I also write a POC test case at https://github.com/cdkey/e1000_poc
-which can reproduce both of them, and easy to verify the patch effect.
-
-The hw watchpoint also shows that, when Qemu using XMM related instructions
-writing 16 bytes e1000_rx_desc, concurrent with DPDK using movb
-writing 1 byte status, the final result of writing to memory will be one
-of them, if it made by Qemu which DD flag is on, DPDK will consume it
-again.
-
-Setting DD status in a separate operation, can prevent the impact of
-disorder memory writing by memcpy, also avoid unexpected data when
-concurrent writing status by qemu and guest dpdk.
-
-Links: https://lore.kernel.org/qemu-devel/20200102110504.GG121208@stefanha-x1.localdomain/T/
-
-Reported-by: Leonid Myravjev <asm@asm.pp.ru>
-Cc: Stefan Hajnoczi <stefanha@gmail.com>
-Cc: Paolo Bonzini <pbonzini@redhat.com>
-Cc: Michael S. Tsirkin <mst@redhat.com>
-Cc: qemu-stable@nongnu.org
-Tested-by: Jing Zhang <zhangjing@sangfor.com.cn>
-Reviewed-by: Frank Lee <lifan38153@sangfor.com.cn>
-Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
-Signed-off-by: Jason Wang <jasowang@redhat.com>
-(cherry-picked from commit 034d00d4858161e1d4cff82d8d230bce874a04d3)
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hw/net/e1000.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/hw/net/e1000.c b/hw/net/e1000.c
-index f5bc81296d..e26e0a64c1 100644
---- a/hw/net/e1000.c
-+++ b/hw/net/e1000.c
-@@ -979,7 +979,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
- base = rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH];
- pci_dma_read(d, base, &desc, sizeof(desc));
- desc.special = vlan_special;
-- desc.status |= (vlan_status | E1000_RXD_STAT_DD);
-+ desc.status &= ~E1000_RXD_STAT_DD;
- if (desc.buffer_addr) {
- if (desc_offset < size) {
- size_t iov_copy;
-@@ -1013,6 +1013,9 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
- DBGOUT(RX, "Null RX descriptor!!\n");
- }
- pci_dma_write(d, base, &desc, sizeof(desc));
-+ desc.status |= (vlan_status | E1000_RXD_STAT_DD);
-+ pci_dma_write(d, base + offsetof(struct e1000_rx_desc, status),
-+ &desc.status, sizeof(desc.status));
-
- if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
- s->mac_reg[RDH] = 0;
diff --git a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
index 700afed..b21d8a7 100644
--- a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
+++ b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index 39a3d6dbe6..e5bf5d59bf 100644
+index 48cd096624..3d60b80286 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -554,7 +554,7 @@ static QemuOptsList raw_runtime_opts = {
+@@ -553,7 +553,7 @@ static QemuOptsList raw_runtime_opts = {
{
.name = "locking",
.type = QEMU_OPT_STRING,
@@ -26,7 +26,7 @@ index 39a3d6dbe6..e5bf5d59bf 100644
},
{
.name = "pr-manager",
-@@ -654,7 +654,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
+@@ -653,7 +653,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
s->use_lock = false;
break;
case ON_OFF_AUTO_AUTO:
diff --git a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
index 6a19ef0..0184097 100644
--- a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
+++ b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
@@ -10,10 +10,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
-index 982c532353..5395e7e471 100644
+index 82004b65b9..4868db8f94 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
-@@ -2087,9 +2087,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
+@@ -2133,9 +2133,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
#ifdef TARGET_X86_64
diff --git a/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch b/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch
index f8775dc..0890369 100644
--- a/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch
+++ b/debian/patches/pve/0005-PVE-Config-glusterfs-no-default-logfile-if-daemonize.patch
@@ -9,7 +9,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
-index 592e71b22a..aebfece6eb 100644
+index b60213ab80..93da76bc31 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -42,7 +42,7 @@
diff --git a/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch b/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
index ce4366d..a87a46a 100644
--- a/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
+++ b/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
@@ -18,7 +18,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+)
diff --git a/block/rbd.c b/block/rbd.c
-index 6caf35cbba..0cec24c86d 100644
+index f826410f40..64a8d7d48b 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -820,6 +820,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
diff --git a/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch b/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
index d6b5440..cd90b46 100644
--- a/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
+++ b/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 43 insertions(+)
diff --git a/net/net.c b/net/net.c
-index f0d14dbfc1..6d476c47ef 100644
+index 2db160e063..8329347891 100644
--- a/net/net.c
+++ b/net/net.c
-@@ -1334,6 +1334,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
+@@ -1343,6 +1343,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
}
}
@@ -49,7 +49,7 @@ index f0d14dbfc1..6d476c47ef 100644
{
NetClientState *nc;
diff --git a/qapi/net.json b/qapi/net.json
-index b92f3f5fb4..52c7e1f82b 100644
+index 75ba2cb989..a3c93ab88f 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -35,6 +35,21 @@
@@ -75,12 +75,12 @@ index b92f3f5fb4..52c7e1f82b 100644
# @netdev_add:
#
diff --git a/qapi/pragma.json b/qapi/pragma.json
-index e6a021c19c..41139d8645 100644
+index 7f810b0e97..a2358e303a 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
-@@ -25,6 +25,7 @@
- 'system_reset',
+@@ -26,6 +26,7 @@
'system_wakeup' ],
+ # Commands allowed to return a non-dictionary
'command-returns-exceptions': [
+ 'get_link_status',
'human-monitor-command',
diff --git a/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch b/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch
index 1c16ff7..88becc5 100644
--- a/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch
+++ b/debian/patches/pve/0008-PVE-Up-glusterfs-allow-partial-reads.patch
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/gluster.c b/block/gluster.c
-index aebfece6eb..3b7ee2f649 100644
+index 93da76bc31..1079b6186b 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
diff --git a/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch b/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
index 0d67cd2..b2a27d8 100644
--- a/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
+++ b/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 1caddfb23a..2782e181c0 100644
+index 7d4b33b3da..bb36f42dd2 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -3005,7 +3005,8 @@ static int img_info(int argc, char **argv)
+@@ -3010,7 +3010,8 @@ static int img_info(int argc, char **argv)
list = collect_image_info_list(image_opts, filename, fmt, chain,
force_share);
if (!list) {
diff --git a/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch b/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
index 7163f0f..bed5c25 100644
--- a/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
+++ b/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
@@ -31,10 +31,11 @@ override the output file's size.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
qemu-img-cmds.hx | 4 +-
- qemu-img.c | 187 +++++++++++++++++++++++++++++------------------
- 2 files changed, 119 insertions(+), 72 deletions(-)
+ qemu-img.c | 202 ++++++++++++++++++++++++++++++-----------------
+ 2 files changed, 133 insertions(+), 73 deletions(-)
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index 1b1dab5b17..d1616c045a 100644
@@ -53,10 +54,10 @@ index 1b1dab5b17..d1616c045a 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 2782e181c0..8cd43b3601 100644
+index bb36f42dd2..74afcb79ef 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4821,10 +4821,12 @@ static int img_bitmap(int argc, char **argv)
+@@ -4826,10 +4826,12 @@ static int img_bitmap(int argc, char **argv)
#define C_IF 04
#define C_OF 010
#define C_SKIP 020
@@ -69,7 +70,7 @@ index 2782e181c0..8cd43b3601 100644
};
struct DdIo {
-@@ -4900,6 +4902,19 @@ static int img_dd_skip(const char *arg,
+@@ -4905,6 +4907,19 @@ static int img_dd_skip(const char *arg,
return 0;
}
@@ -89,7 +90,7 @@ index 2782e181c0..8cd43b3601 100644
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4940,6 +4955,7 @@ static int img_dd(int argc, char **argv)
+@@ -4945,6 +4960,7 @@ static int img_dd(int argc, char **argv)
{ "if", img_dd_if, C_IF },
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
@@ -97,7 +98,7 @@ index 2782e181c0..8cd43b3601 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5015,91 +5031,112 @@ static int img_dd(int argc, char **argv)
+@@ -5020,91 +5036,112 @@ static int img_dd(int argc, char **argv)
arg = NULL;
}
@@ -153,9 +154,9 @@ index 2782e181c0..8cd43b3601 100644
}
- create_opts = qemu_opts_append(create_opts, drv->create_opts);
- create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
-
-- opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
-
+- opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
+
- size = blk_getlength(blk1);
- if (size < 0) {
- error_report("Failed to get size for '%s'", in.filename);
@@ -274,41 +275,54 @@ index 2782e181c0..8cd43b3601 100644
}
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
-@@ -5117,11 +5154,17 @@ static int img_dd(int argc, char **argv)
+@@ -5121,20 +5158,43 @@ static int img_dd(int argc, char **argv)
+ in.buf = g_new(uint8_t, in.bsz);
for (out_pos = 0; in_pos < size; block_count++) {
- int in_ret, out_ret;
++ int in_ret, out_ret;
+ int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
-
-- if (in_pos + in.bsz > size) {
-- in_ret = blk_pread(blk1, in_pos, in.buf, size - in_pos);
-+ size_t in_bsz = in_pos + in.bsz > size ? size - in_pos : in.bsz;
+- ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
+- if (ret < 0) {
+ if (blk1) {
-+ in_ret = blk_pread(blk1, in_pos, in.buf, in_bsz);
- } else {
-- in_ret = blk_pread(blk1, in_pos, in.buf, in.bsz);
-+ in_ret = read(STDIN_FILENO, in.buf, in_bsz);
++ in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
++ if (in_ret == 0) {
++ in_ret = bytes;
++ }
++ } else {
++ in_ret = read(STDIN_FILENO, in.buf, bytes);
+ if (in_ret == 0) {
+ /* early EOF is considered an error */
+ error_report("Input ended unexpectedly");
+ ret = -1;
+ goto out;
+ }
- }
- if (in_ret < 0) {
++ }
++ if (in_ret < 0) {
error_report("error while reading from input image file: %s",
-@@ -5131,9 +5174,13 @@ static int img_dd(int argc, char **argv)
+- strerror(-ret));
++ strerror(-in_ret));
++ ret = -1;
+ goto out;
}
- in_pos += in_ret;
+ in_pos += bytes;
-- out_ret = blk_pwrite(blk2, out_pos, in.buf, in_ret, 0);
+- ret = blk_pwrite(blk2, out_pos, bytes, in.buf, 0);
+- if (ret < 0) {
+ if (blk2) {
-+ out_ret = blk_pwrite(blk2, out_pos, in.buf, in_ret, 0);
++ out_ret = blk_pwrite(blk2, out_pos, in_ret, in.buf, 0);
++ if (out_ret == 0) {
++ out_ret = in_ret;
++ }
+ } else {
+ out_ret = write(STDOUT_FILENO, in.buf, in_ret);
+ }
-
-- if (out_ret < 0) {
++
+ if (out_ret != in_ret) {
error_report("error while writing to output image file: %s",
- strerror(-out_ret));
- ret = -1;
+- strerror(-ret));
++ strerror(-out_ret));
++ ret = -1;
+ goto out;
+ }
+ out_pos += bytes;
diff --git a/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch b/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
index 29df3de..f367a53 100644
--- a/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
+++ b/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
@@ -10,15 +10,16 @@ an expected end of input.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
qemu-img.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 8cd43b3601..67033b2d2c 100644
+index 74afcb79ef..14594d44b6 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4822,11 +4822,13 @@ static int img_bitmap(int argc, char **argv)
+@@ -4827,11 +4827,13 @@ static int img_bitmap(int argc, char **argv)
#define C_OF 010
#define C_SKIP 020
#define C_OSIZE 040
@@ -32,7 +33,7 @@ index 8cd43b3601..67033b2d2c 100644
};
struct DdIo {
-@@ -4915,6 +4917,19 @@ static int img_dd_osize(const char *arg,
+@@ -4920,6 +4922,19 @@ static int img_dd_osize(const char *arg,
return 0;
}
@@ -52,7 +53,7 @@ index 8cd43b3601..67033b2d2c 100644
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4929,12 +4944,14 @@ static int img_dd(int argc, char **argv)
+@@ -4934,12 +4949,14 @@ static int img_dd(int argc, char **argv)
int c, i;
const char *out_fmt = "raw";
const char *fmt = NULL;
@@ -68,7 +69,7 @@ index 8cd43b3601..67033b2d2c 100644
};
struct DdIo in = {
.bsz = 512, /* Block size is by default 512 bytes */
-@@ -4956,6 +4973,7 @@ static int img_dd(int argc, char **argv)
+@@ -4961,6 +4978,7 @@ static int img_dd(int argc, char **argv)
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
{ "osize", img_dd_osize, C_OSIZE },
@@ -76,7 +77,7 @@ index 8cd43b3601..67033b2d2c 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5152,14 +5170,18 @@ static int img_dd(int argc, char **argv)
+@@ -5157,9 +5175,10 @@ static int img_dd(int argc, char **argv)
in.buf = g_new(uint8_t, in.bsz);
@@ -84,12 +85,14 @@ index 8cd43b3601..67033b2d2c 100644
+ readsize = (dd.isize > 0) ? dd.isize : size;
+ for (out_pos = 0; in_pos < readsize; block_count++) {
int in_ret, out_ret;
-- size_t in_bsz = in_pos + in.bsz > size ? size - in_pos : in.bsz;
-+ size_t in_bsz = in_pos + in.bsz > readsize ? readsize - in_pos : in.bsz;
+- int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
++ int bytes = (in_pos + in.bsz > readsize) ? readsize - in_pos : in.bsz;
if (blk1) {
- in_ret = blk_pread(blk1, in_pos, in.buf, in_bsz);
+ in_ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
+ if (in_ret == 0) {
+@@ -5168,6 +5187,9 @@ static int img_dd(int argc, char **argv)
} else {
- in_ret = read(STDIN_FILENO, in.buf, in_bsz);
+ in_ret = read(STDIN_FILENO, in.buf, bytes);
if (in_ret == 0) {
+ if (dd.isize == 0) {
+ goto out;
diff --git a/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch b/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
index 39991dd..f24932d 100644
--- a/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
+++ b/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
@@ -13,7 +13,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index 8885ea11cf..33979b7430 100644
+index 85a6e05b35..699229eef6 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -208,6 +208,10 @@ Parameters to convert subcommand:
@@ -65,10 +65,10 @@ index d1616c045a..b5b0bb4467 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 67033b2d2c..35c2bdc95c 100644
+index 14594d44b6..c6b4a5567d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4946,7 +4946,7 @@ static int img_dd(int argc, char **argv)
+@@ -4951,7 +4951,7 @@ static int img_dd(int argc, char **argv)
const char *fmt = NULL;
int64_t size = 0, readsize = 0;
int64_t block_count = 0, out_pos, in_pos;
@@ -77,7 +77,7 @@ index 67033b2d2c..35c2bdc95c 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4984,7 +4984,7 @@ static int img_dd(int argc, char **argv)
+@@ -4989,7 +4989,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -86,7 +86,7 @@ index 67033b2d2c..35c2bdc95c 100644
if (c == EOF) {
break;
}
-@@ -5004,6 +5004,9 @@ static int img_dd(int argc, char **argv)
+@@ -5009,6 +5009,9 @@ static int img_dd(int argc, char **argv)
case 'h':
help();
break;
@@ -96,7 +96,7 @@ index 67033b2d2c..35c2bdc95c 100644
case 'U':
force_share = true;
break;
-@@ -5134,13 +5137,15 @@ static int img_dd(int argc, char **argv)
+@@ -5139,13 +5142,15 @@ static int img_dd(int argc, char **argv)
size - in.bsz * in.offset, &error_abort);
}
diff --git a/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch b/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
index a52235f..12beef5 100644
--- a/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
+++ b/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
-index 163d244eb4..389907f1f8 100644
+index 73ac5eb675..bbfe7eca62 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
-@@ -813,8 +813,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+@@ -806,8 +806,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
@@ -58,10 +58,10 @@ index 163d244eb4..389907f1f8 100644
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 634968498b..5482dd0569 100644
+index c6cd6f91dd..15572befb1 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -708,7 +708,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
+@@ -715,7 +715,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
return;
}
@@ -99,10 +99,10 @@ index 634968498b..5482dd0569 100644
qapi_free_BalloonInfo(info);
}
diff --git a/qapi/machine.json b/qapi/machine.json
-index d25a481ce4..3627172aed 100644
+index 6afd1936b0..8b4be9b718 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -1018,10 +1018,30 @@
+@@ -1054,9 +1054,29 @@
# @actual: the logical size of the VM in bytes
# Formula used: logical_vm_size = vm_ram_size - balloon_size
#
@@ -123,7 +123,6 @@ index d25a481ce4..3627172aed 100644
+# @max_mem: amount of memory (in bytes) assigned to the guest
+#
# Since: 0.14
- #
##
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
+{ 'struct': 'BalloonInfo',
diff --git a/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch b/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
index 8c7d776..cc3c92e 100644
--- a/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
+++ b/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
@@ -30,10 +30,10 @@ index 4f4ab30f8c..76fff60a6b 100644
info->default_cpu_type = g_strdup(mc->default_cpu_type);
info->has_default_cpu_type = true;
diff --git a/qapi/machine.json b/qapi/machine.json
-index 3627172aed..ca133e68ce 100644
+index 8b4be9b718..555458f785 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -139,6 +139,8 @@
+@@ -138,6 +138,8 @@
#
# @is-default: whether the machine is default
#
@@ -42,7 +42,7 @@ index 3627172aed..ca133e68ce 100644
# @cpu-max: maximum number of CPUs supported by the machine type
# (since 1.5)
#
-@@ -160,7 +162,7 @@
+@@ -159,7 +161,7 @@
##
{ 'struct': 'MachineInfo',
'data': { 'name': 'str', '*alias': 'str',
diff --git a/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch b/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
index 3f7fd62..c3f3fc3 100644
--- a/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
+++ b/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
@@ -12,10 +12,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 8 insertions(+)
diff --git a/qapi/ui.json b/qapi/ui.json
-index 13a8bb82aa..4c34436ba7 100644
+index cf58ab4283..0be2388941 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
-@@ -300,11 +300,14 @@
+@@ -310,11 +310,14 @@
#
# @channels: a list of @SpiceChannel for each active spice channel
#
diff --git a/debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch b/debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
new file mode 100644
index 0000000..8e419d2
--- /dev/null
+++ b/debian/patches/pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
@@ -0,0 +1,306 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Fiona Ebner <f.ebner@proxmox.com>
+Date: Thu, 13 Oct 2022 11:33:50 +0200
+Subject: [PATCH] PVE: add IOChannel implementation for savevm-async
+
+based on migration/channel-block.c and the implementation that was
+present in migration/savevm-async.c before QEMU 7.1.
+
+Passes along read/write requests to the given BlockBackend, while
+ensuring that a read request going beyond the end results in a
+graceful short read.
+
+Additionally, allows tracking the current position from the outside
+(intended to be used for progress tracking).
+
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
+---
+ migration/channel-savevm-async.c | 207 +++++++++++++++++++++++++++++++
+ migration/channel-savevm-async.h | 51 ++++++++
+ migration/meson.build | 1 +
+ 3 files changed, 259 insertions(+)
+ create mode 100644 migration/channel-savevm-async.c
+ create mode 100644 migration/channel-savevm-async.h
+
+diff --git a/migration/channel-savevm-async.c b/migration/channel-savevm-async.c
+new file mode 100644
+index 0000000000..0fbde5676b
+--- /dev/null
++++ b/migration/channel-savevm-async.c
+@@ -0,0 +1,207 @@
++/*
++ * QIO Channel implementation to be used by savevm-async QMP calls
++ */
++#include "qemu/osdep.h"
++#include "migration/channel-savevm-async.h"
++#include "qapi/error.h"
++#include "sysemu/block-backend.h"
++#include "trace.h"
++
++/* used while emulated sync operation in progress */
++#define NOT_DONE -EINPROGRESS
++
++QIOChannelSavevmAsync *
++qio_channel_savevm_async_new(BlockBackend *be, size_t *bs_pos)
++{
++ QIOChannelSavevmAsync *ioc;
++
++ ioc = QIO_CHANNEL_SAVEVM_ASYNC(object_new(TYPE_QIO_CHANNEL_SAVEVM_ASYNC));
++
++ bdrv_ref(blk_bs(be));
++ ioc->be = be;
++ ioc->bs_pos = bs_pos;
++
++ return ioc;
++}
++
++
++static void
++qio_channel_savevm_async_finalize(Object *obj)
++{
++ QIOChannelSavevmAsync *ioc = QIO_CHANNEL_SAVEVM_ASYNC(obj);
++
++ if (ioc->be) {
++ bdrv_unref(blk_bs(ioc->be));
++ ioc->be = NULL;
++ }
++ ioc->bs_pos = NULL;
++}
++
++
++static ssize_t
++qio_channel_savevm_async_readv(QIOChannel *ioc,
++ const struct iovec *iov,
++ size_t niov,
++ int **fds,
++ size_t *nfds,
++ Error **errp)
++{
++ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
++ BlockBackend *be = saioc->be;
++ int64_t maxlen = blk_getlength(be);
++ QEMUIOVector qiov;
++ size_t size;
++ int ret;
++
++ qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
++
++ if (*saioc->bs_pos >= maxlen) {
++ error_setg(errp, "cannot read beyond maxlen");
++ return -1;
++ }
++
++ if (maxlen - *saioc->bs_pos < qiov.size) {
++ size = maxlen - *saioc->bs_pos;
++ qemu_iovec_memset(&qiov, size, 0, qiov.size - size);
++ } else {
++ size = qiov.size;
++ }
++
++ // returns 0 on success
++ ret = blk_preadv(be, *saioc->bs_pos, size, &qiov, 0);
++ if (ret < 0) {
++ error_setg(errp, "blk_preadv returned %d", ret);
++ return -1;
++ }
++
++
++ *saioc->bs_pos += size;
++ return size;
++}
++
++typedef struct BlkRwCo {
++ BlockBackend *be;
++ int64_t offset;
++ QEMUIOVector *qiov;
++ ssize_t ret;
++} BlkRwCo;
++
++static void coroutine_fn block_state_write_entry(void *opaque) {
++ BlkRwCo *rwco = opaque;
++ rwco->ret = blk_co_pwritev(rwco->be, rwco->offset, rwco->qiov->size,
++ rwco->qiov, 0);
++ aio_wait_kick();
++}
++
++
++static ssize_t
++qio_channel_savevm_async_writev(QIOChannel *ioc,
++ const struct iovec *iov,
++ size_t niov,
++ int *fds,
++ size_t nfds,
++ int flags,
++ Error **errp)
++{
++ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
++ BlockBackend *be = saioc->be;
++ QEMUIOVector qiov;
++ BlkRwCo rwco;
++
++ rwco = (BlkRwCo) {
++ .be = be,
++ .offset = *saioc->bs_pos,
++ .qiov = &qiov,
++ .ret = NOT_DONE,
++ };
++
++ qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov);
++
++ if (qemu_in_coroutine()) {
++ block_state_write_entry(&rwco);
++ } else {
++ Coroutine *co = qemu_coroutine_create(&block_state_write_entry, &rwco);
++ bdrv_coroutine_enter(blk_bs(be), co);
++ BDRV_POLL_WHILE(blk_bs(be), rwco.ret == NOT_DONE);
++ }
++ if (rwco.ret < 0) {
++ return rwco.ret;
++ }
++
++ *saioc->bs_pos += qiov.size;
++ return qiov.size;
++}
++
++
++static int
++qio_channel_savevm_async_set_blocking(QIOChannel *ioc,
++ bool enabled,
++ Error **errp)
++{
++ if (!enabled) {
++ error_setg(errp, "Non-blocking mode not supported for savevm-async");
++ return -1;
++ }
++ return 0;
++}
++
++
++static int
++qio_channel_savevm_async_close(QIOChannel *ioc,
++ Error **errp)
++{
++ QIOChannelSavevmAsync *saioc = QIO_CHANNEL_SAVEVM_ASYNC(ioc);
++ int rv = bdrv_flush(blk_bs(saioc->be));
++
++ if (rv < 0) {
++ error_setg_errno(errp, -rv, "Unable to flush VMState");
++ return -1;
++ }
++
++ bdrv_unref(blk_bs(saioc->be));
++ saioc->be = NULL;
++ saioc->bs_pos = NULL;
++
++ return 0;
++}
++
++
++static void
++qio_channel_savevm_async_set_aio_fd_handler(QIOChannel *ioc,
++ AioContext *ctx,
++ IOHandler *io_read,
++ IOHandler *io_write,
++ void *opaque)
++{
++ // if channel-block starts doing something, check if this needs adaptation
++}
++
++
++static void
++qio_channel_savevm_async_class_init(ObjectClass *klass,
++ void *class_data G_GNUC_UNUSED)
++{
++ QIOChannelClass *ioc_klass = QIO_CHANNEL_CLASS(klass);
++
++ ioc_klass->io_writev = qio_channel_savevm_async_writev;
++ ioc_klass->io_readv = qio_channel_savevm_async_readv;
++ ioc_klass->io_set_blocking = qio_channel_savevm_async_set_blocking;
++ ioc_klass->io_close = qio_channel_savevm_async_close;
++ ioc_klass->io_set_aio_fd_handler = qio_channel_savevm_async_set_aio_fd_handler;
++}
++
++static const TypeInfo qio_channel_savevm_async_info = {
++ .parent = TYPE_QIO_CHANNEL,
++ .name = TYPE_QIO_CHANNEL_SAVEVM_ASYNC,
++ .instance_size = sizeof(QIOChannelSavevmAsync),
++ .instance_finalize = qio_channel_savevm_async_finalize,
++ .class_init = qio_channel_savevm_async_class_init,
++};
++
++static void
++qio_channel_savevm_async_register_types(void)
++{
++ type_register_static(&qio_channel_savevm_async_info);
++}
++
++type_init(qio_channel_savevm_async_register_types);
+diff --git a/migration/channel-savevm-async.h b/migration/channel-savevm-async.h
+new file mode 100644
+index 0000000000..17ae2cb261
+--- /dev/null
++++ b/migration/channel-savevm-async.h
+@@ -0,0 +1,51 @@
++/*
++ * QEMU I/O channels driver for savevm-async.c
++ *
++ * Copyright (c) 2022 Proxmox Server Solutions
++ *
++ * Authors:
++ * Fiona Ebner (f.ebner@proxmox.com)
++ *
++ * This work is licensed under the terms of the GNU GPL, version 2 or later.
++ * See the COPYING file in the top-level directory.
++ */
++
++#ifndef QIO_CHANNEL_SAVEVM_ASYNC_H
++#define QIO_CHANNEL_SAVEVM_ASYNC_H
++
++#include "io/channel.h"
++#include "qom/object.h"
++
++#define TYPE_QIO_CHANNEL_SAVEVM_ASYNC "qio-channel-savevm-async"
++OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelSavevmAsync, QIO_CHANNEL_SAVEVM_ASYNC)
++
++
++/**
++ * QIOChannelSavevmAsync:
++ *
++ * The QIOChannelBlock object provides a channel implementation that is able to
++ * perform I/O on any BlockBackend whose BlockDriverState directly contains a
++ * VMState (as opposed to indirectly, like qcow2). It allows tracking the
++ * current position from the outside.
++ */
++struct QIOChannelSavevmAsync {
++ QIOChannel parent;
++ BlockBackend *be;
++ size_t *bs_pos;
++};
++
++
++/**
++ * qio_channel_savevm_async_new:
++ * @be: the block backend
++ * @bs_pos: used to keep track of the IOChannels current position
++ *
++ * Create a new IO channel object that can perform I/O on a BlockBackend object
++ * whose BlockDriverState directly contains a VMState.
++ *
++ * Returns: the new channel object
++ */
++QIOChannelSavevmAsync *
++qio_channel_savevm_async_new(BlockBackend *be, size_t *bs_pos);
++
++#endif /* QIO_CHANNEL_SAVEVM_ASYNC_H */
+diff --git a/migration/meson.build b/migration/meson.build
+index 690487cf1a..8cac83c06c 100644
+--- a/migration/meson.build
++++ b/migration/meson.build
+@@ -13,6 +13,7 @@ softmmu_ss.add(files(
+ 'block-dirty-bitmap.c',
+ 'channel.c',
+ 'channel-block.c',
++ 'channel-savevm-async.c',
+ 'colo-failover.c',
+ 'colo.c',
+ 'exec.c',
diff --git a/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch b/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
similarity index 88%
rename from debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
rename to debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
index 6bb06ec..7058cb2 100644
--- a/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
+++ b/debian/patches/pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
@@ -23,25 +23,26 @@ Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
[improve aborting]
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
-[FE: further improve aborting]
+[FE: further improve aborting
+ adapt to removal of QEMUFileOps]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
hmp-commands-info.hx | 13 +
- hmp-commands.hx | 33 ++
+ hmp-commands.hx | 33 +++
include/migration/snapshot.h | 2 +
include/monitor/hmp.h | 5 +
migration/meson.build | 1 +
- migration/savevm-async.c | 604 +++++++++++++++++++++++++++++++++++
+ migration/savevm-async.c | 531 +++++++++++++++++++++++++++++++++++
monitor/hmp-cmds.c | 57 ++++
- qapi/migration.json | 34 ++
- qapi/misc.json | 32 ++
+ qapi/migration.json | 34 +++
+ qapi/misc.json | 32 +++
qemu-options.hx | 12 +
softmmu/vl.c | 10 +
- 11 files changed, 803 insertions(+)
+ 11 files changed, 730 insertions(+)
create mode 100644 migration/savevm-async.c
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index adfa085a9b..925e680e5a 100644
+index 188d9ece3b..97b88eaaad 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -538,6 +538,19 @@ SRST
@@ -65,12 +66,12 @@ index adfa085a9b..925e680e5a 100644
.name = "balloon",
.args_type = "",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 8476277aa9..7f0ac498c4 100644
+index 182e639d14..bbcc73e942 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
-@@ -1746,3 +1746,36 @@ ERST
- "\n\t\t\t -b to specify dirty bitmap as method of calculation)",
- .cmd = hmp_calc_dirty_rate,
+@@ -1800,3 +1800,36 @@ ERST
+ "\n\t\t\t\t\t limit on a specified virtual cpu",
+ .cmd = hmp_cancel_vcpu_dirty_limit,
},
+
+ {
@@ -117,7 +118,7 @@ index e72083b117..c846d37806 100644
+
#endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
-index 96d014826a..3a39ba41b5 100644
+index a618eb1e4e..55067beff1 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -26,6 +26,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
@@ -140,10 +141,10 @@ index 96d014826a..3a39ba41b5 100644
void hmp_screendump(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
diff --git a/migration/meson.build b/migration/meson.build
-index 8b5ca5c047..1e2aec8486 100644
+index 8cac83c06c..0842d00cd2 100644
--- a/migration/meson.build
+++ b/migration/meson.build
-@@ -23,6 +23,7 @@ softmmu_ss.add(files(
+@@ -24,6 +24,7 @@ softmmu_ss.add(files(
'multifd-zlib.c',
'postcopy-ram.c',
'savevm.c',
@@ -153,11 +154,12 @@ index 8b5ca5c047..1e2aec8486 100644
), gnutls)
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
new file mode 100644
-index 0000000000..b9a43c56bc
+index 0000000000..b3692739a0
--- /dev/null
+++ b/migration/savevm-async.c
-@@ -0,0 +1,604 @@
+@@ -0,0 +1,531 @@
+#include "qemu/osdep.h"
++#include "migration/channel-savevm-async.h"
+#include "migration/migration.h"
+#include "migration/savevm.h"
+#include "migration/snapshot.h"
@@ -181,9 +183,6 @@ index 0000000000..b9a43c56bc
+
+/* #define DEBUG_SAVEVM_STATE */
+
-+/* used while emulated sync operation in progress */
-+#define NOT_DONE -EINPROGRESS
-+
+#ifdef DEBUG_SAVEVM_STATE
+#define DPRINTF(fmt, ...) \
+ do { printf("savevm-async: " fmt, ## __VA_ARGS__); } while (0)
@@ -270,6 +269,7 @@ index 0000000000..b9a43c56bc
+
+ if (snap_state.file) {
+ ret = qemu_fclose(snap_state.file);
++ snap_state.file = NULL;
+ }
+
+ if (snap_state.target) {
@@ -313,60 +313,6 @@ index 0000000000..b9a43c56bc
+ snap_state.state = SAVE_STATE_ERROR;
+}
+
-+static int block_state_close(void *opaque, Error **errp)
-+{
-+ snap_state.file = NULL;
-+ return blk_flush(snap_state.target);
-+}
-+
-+typedef struct BlkRwCo {
-+ int64_t offset;
-+ QEMUIOVector *qiov;
-+ ssize_t ret;
-+} BlkRwCo;
-+
-+static void coroutine_fn block_state_write_entry(void *opaque) {
-+ BlkRwCo *rwco = opaque;
-+ rwco->ret = blk_co_pwritev(snap_state.target, rwco->offset, rwco->qiov->size,
-+ rwco->qiov, 0);
-+ aio_wait_kick();
-+}
-+
-+static ssize_t block_state_writev_buffer(void *opaque, struct iovec *iov,
-+ int iovcnt, int64_t pos, Error **errp)
-+{
-+ QEMUIOVector qiov;
-+ BlkRwCo rwco;
-+
-+ assert(pos == snap_state.bs_pos);
-+ rwco = (BlkRwCo) {
-+ .offset = pos,
-+ .qiov = &qiov,
-+ .ret = NOT_DONE,
-+ };
-+
-+ qemu_iovec_init_external(&qiov, iov, iovcnt);
-+
-+ if (qemu_in_coroutine()) {
-+ block_state_write_entry(&rwco);
-+ } else {
-+ Coroutine *co = qemu_coroutine_create(&block_state_write_entry, &rwco);
-+ bdrv_coroutine_enter(blk_bs(snap_state.target), co);
-+ BDRV_POLL_WHILE(blk_bs(snap_state.target), rwco.ret == NOT_DONE);
-+ }
-+ if (rwco.ret < 0) {
-+ return rwco.ret;
-+ }
-+
-+ snap_state.bs_pos += qiov.size;
-+ return qiov.size;
-+}
-+
-+static const QEMUFileOps block_file_ops = {
-+ .writev_buffer = block_state_writev_buffer,
-+ .close = block_state_close,
-+};
-+
+static void process_savevm_finalize(void *opaque)
+{
+ int ret;
@@ -579,7 +525,9 @@ index 0000000000..b9a43c56bc
+ goto restart;
+ }
+
-+ snap_state.file = qemu_fopen_ops(&snap_state, &block_file_ops);
++ QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target,
++ &snap_state.bs_pos));
++ snap_state.file = qemu_file_new_output(ioc);
+
+ if (!snap_state.file) {
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
@@ -691,27 +639,6 @@ index 0000000000..b9a43c56bc
+ true, name, errp);
+}
+
-+static ssize_t loadstate_get_buffer(void *opaque, uint8_t *buf, int64_t pos,
-+ size_t size, Error **errp)
-+{
-+ BlockBackend *be = opaque;
-+ int64_t maxlen = blk_getlength(be);
-+ if (pos > maxlen) {
-+ return -EIO;
-+ }
-+ if ((pos + size) > maxlen) {
-+ size = maxlen - pos - 1;
-+ }
-+ if (size == 0) {
-+ return 0;
-+ }
-+ return blk_pread(be, pos, buf, size);
-+}
-+
-+static const QEMUFileOps loadstate_file_ops = {
-+ .get_buffer = loadstate_get_buffer,
-+};
-+
+int load_snapshot_from_blockdev(const char *filename, Error **errp)
+{
+ BlockBackend *be;
@@ -719,6 +646,7 @@ index 0000000000..b9a43c56bc
+ Error *blocker = NULL;
+
+ QEMUFile *f;
++ size_t bs_pos = 0;
+ int ret = -EINVAL;
+
+ be = blk_new_open(filename, NULL, NULL, 0, &local_err);
@@ -732,7 +660,7 @@ index 0000000000..b9a43c56bc
+ blk_op_block_all(be, blocker);
+
+ /* restore the VM state */
-+ f = qemu_fopen_ops(be, &loadstate_file_ops);
++ f = qemu_file_new_input(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)));
+ if (!f) {
+ error_setg(errp, "Could not open VM state file");
+ goto the_end;
@@ -762,10 +690,10 @@ index 0000000000..b9a43c56bc
+ return ret;
+}
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 5482dd0569..c64b959738 100644
+index 15572befb1..1507180990 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -1906,6 +1906,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
+@@ -1925,6 +1925,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, err);
}
@@ -830,10 +758,10 @@ index 5482dd0569..c64b959738 100644
{
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
diff --git a/qapi/migration.json b/qapi/migration.json
-index 27d7b28158..31d6cc902e 100644
+index 81185d4311..3129f71fa8 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
-@@ -258,6 +258,40 @@
+@@ -261,6 +261,40 @@
'*compression': 'CompressionStats',
'*socket-address': ['SocketAddress'] } }
@@ -875,7 +803,7 @@ index 27d7b28158..31d6cc902e 100644
# @query-migrate:
#
diff --git a/qapi/misc.json b/qapi/misc.json
-index b83cc39029..1e5dd7db29 100644
+index 27ef5a2b20..b3ce75dcae 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -435,6 +435,38 @@
@@ -918,10 +846,10 @@ index b83cc39029..1e5dd7db29 100644
# @CommandLineParameterType:
#
diff --git a/qemu-options.hx b/qemu-options.hx
-index 34e9b32a5c..aeade4ef80 100644
+index 31c04f7eea..c2ca6e91b5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -4254,6 +4254,18 @@ SRST
+@@ -4341,6 +4341,18 @@ SRST
Start right away with a saved state (``loadvm`` in monitor)
ERST
@@ -941,18 +869,18 @@ index 34e9b32a5c..aeade4ef80 100644
DEF("daemonize", 0, QEMU_OPTION_daemonize, \
"-daemonize daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 6f646531a0..a3f2a3818c 100644
+index 706bd7cff7..b8637c4262 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -157,6 +157,7 @@ static const char *incoming;
- static const char *loadvm;
- static const char *accelerators;
+@@ -165,6 +165,7 @@ static const char *accelerators;
+ static bool have_custom_ram_size;
+ static const char *ram_memdev_id;
static QDict *machine_opts_dict;
+static const char *loadstate;
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
- static ram_addr_t maxram_size;
-@@ -2749,6 +2750,12 @@ void qmp_x_exit_preconfig(Error **errp)
+ static int display_remote;
+@@ -2584,6 +2585,12 @@ void qmp_x_exit_preconfig(Error **errp)
if (loadvm) {
load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
@@ -965,7 +893,7 @@ index 6f646531a0..a3f2a3818c 100644
}
if (replay_mode != REPLAY_MODE_NONE) {
replay_vmstate_init();
-@@ -3289,6 +3296,9 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3133,6 +3140,9 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_loadvm:
loadvm = optarg;
break;
diff --git a/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
similarity index 52%
rename from debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
rename to debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
index c5cca9d..71ee72d 100644
--- a/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
+++ b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
@@ -10,14 +10,16 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
[increase max IOV count in QEMUFile to actually write more data]
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+[FE: adapt to removal of QEMUFileOps]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
- migration/qemu-file.c | 38 +++++++++++++++++++++++++-------------
- migration/qemu-file.h | 1 +
- migration/savevm-async.c | 4 ++--
- 3 files changed, 28 insertions(+), 15 deletions(-)
+ migration/qemu-file.c | 49 +++++++++++++++++++++++++++-------------
+ migration/qemu-file.h | 2 ++
+ migration/savevm-async.c | 5 ++--
+ 3 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
-index 1479cddad9..21a3355ae2 100644
+index 4f400c2e52..21e8998867 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -31,8 +31,8 @@
@@ -30,9 +32,9 @@ index 1479cddad9..21a3355ae2 100644
+#define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 256)
struct QEMUFile {
- const QEMUFileOps *ops;
-@@ -46,7 +46,8 @@ struct QEMUFile {
- when reading */
+ const QEMUFileHooks *hooks;
+@@ -55,7 +55,8 @@ struct QEMUFile {
+
int buf_index;
int buf_size; /* 0 when writing */
- uint8_t buf[IO_BUF_SIZE];
@@ -41,53 +43,76 @@ index 1479cddad9..21a3355ae2 100644
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
struct iovec iov[MAX_IOV_SIZE];
-@@ -104,7 +105,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
+@@ -106,7 +107,9 @@ bool qemu_file_mode_is_not_valid(const char *mode)
return false;
}
--QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
-+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size)
+-static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
++static QEMUFile *qemu_file_new_impl(QIOChannel *ioc,
++ bool is_writable,
++ size_t buffer_size)
{
QEMUFile *f;
-@@ -113,9 +114,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
- f->opaque = opaque;
- f->ops = ops;
- f->has_ioc = has_ioc;
+@@ -115,6 +118,8 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
+ object_ref(ioc);
+ f->ioc = ioc;
+ f->is_writable = is_writable;
+ f->buf_allocated_size = buffer_size;
+ f->buf = malloc(buffer_size);
-+
+
return f;
}
+@@ -125,17 +130,27 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
+ */
+ QEMUFile *qemu_file_get_return_path(QEMUFile *f)
+ {
+- return qemu_file_new_impl(f->ioc, !f->is_writable);
++ return qemu_file_new_impl(f->ioc, !f->is_writable, DEFAULT_IO_BUF_SIZE);
+ }
-+QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
+ QEMUFile *qemu_file_new_output(QIOChannel *ioc)
+ {
+- return qemu_file_new_impl(ioc, true);
++ return qemu_file_new_impl(ioc, true, DEFAULT_IO_BUF_SIZE);
++}
++
++QEMUFile *qemu_file_new_output_sized(QIOChannel *ioc, size_t buffer_size)
+{
-+ return qemu_fopen_ops_sized(opaque, ops, has_ioc, DEFAULT_IO_BUF_SIZE);
++ return qemu_file_new_impl(ioc, true, buffer_size);
+ }
+
+ QEMUFile *qemu_file_new_input(QIOChannel *ioc)
+ {
+- return qemu_file_new_impl(ioc, false);
++ return qemu_file_new_impl(ioc, false, DEFAULT_IO_BUF_SIZE);
+}
+
++QEMUFile *qemu_file_new_input_sized(QIOChannel *ioc, size_t buffer_size)
++{
++ return qemu_file_new_impl(ioc, false, buffer_size);
+ }
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
- {
-@@ -350,7 +359,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
+@@ -393,7 +408,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
+ do {
+ len = qio_channel_read(f->ioc,
+ (char *)f->buf + pending,
+- IO_BUF_SIZE - pending,
++ f->buf_allocated_size - pending,
+ &local_error);
+ if (len == QIO_CHANNEL_ERR_BLOCK) {
+ if (qemu_in_coroutine()) {
+@@ -443,6 +458,8 @@ int qemu_fclose(QEMUFile *f)
}
+ g_clear_pointer(&f->ioc, object_unref);
- len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
-- IO_BUF_SIZE - pending, &local_error);
-+ f->buf_allocated_size - pending, &local_error);
- if (len > 0) {
- f->buf_size += len;
- f->pos += len;
-@@ -390,6 +399,9 @@ int qemu_fclose(QEMUFile *f)
- ret = ret2;
- }
- }
-+
+ free(f->buf);
+
/* If any error was spotted before closing, we should report it
* instead of the close() return value.
*/
-@@ -444,7 +456,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
+@@ -497,7 +514,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
{
if (!add_to_iovec(f, f->buf + f->buf_index, len, false)) {
f->buf_index += len;
@@ -96,7 +121,7 @@ index 1479cddad9..21a3355ae2 100644
qemu_fflush(f);
}
}
-@@ -470,7 +482,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
+@@ -523,7 +540,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
}
while (size > 0) {
@@ -105,7 +130,7 @@ index 1479cddad9..21a3355ae2 100644
if (l > size) {
l = size;
}
-@@ -517,8 +529,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
+@@ -570,8 +587,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
size_t index;
assert(!qemu_file_is_writable(f));
@@ -116,7 +141,7 @@ index 1479cddad9..21a3355ae2 100644
/* The 1st byte to read from */
index = f->buf_index + offset;
-@@ -568,7 +580,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -621,7 +638,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
size_t res;
uint8_t *src;
@@ -125,7 +150,7 @@ index 1479cddad9..21a3355ae2 100644
if (res == 0) {
return done;
}
-@@ -602,7 +614,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -655,7 +672,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
*/
size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size)
{
@@ -134,7 +159,7 @@ index 1479cddad9..21a3355ae2 100644
size_t res;
uint8_t *src = NULL;
-@@ -627,7 +639,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
+@@ -680,7 +697,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
int index = f->buf_index + offset;
assert(!qemu_file_is_writable(f));
@@ -143,7 +168,7 @@ index 1479cddad9..21a3355ae2 100644
if (index >= f->buf_size) {
qemu_fill_buffer(f);
-@@ -779,7 +791,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
+@@ -832,7 +849,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
const uint8_t *p, size_t size)
{
@@ -153,36 +178,39 @@ index 1479cddad9..21a3355ae2 100644
if (blen < compressBound(size)) {
return -1;
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
-index 3f36d4dc8c..67501fd9cf 100644
+index fa13d04d78..914f1a63a8 100644
--- a/migration/qemu-file.h
+++ b/migration/qemu-file.h
-@@ -121,6 +121,7 @@ typedef struct QEMUFileHooks {
+@@ -63,7 +63,9 @@ typedef struct QEMUFileHooks {
} QEMUFileHooks;
- QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc);
-+QEMUFile *qemu_fopen_ops_sized(void *opaque, const QEMUFileOps *ops, bool has_ioc, size_t buffer_size);
+ QEMUFile *qemu_file_new_input(QIOChannel *ioc);
++QEMUFile *qemu_file_new_input_sized(QIOChannel *ioc, size_t buffer_size);
+ QEMUFile *qemu_file_new_output(QIOChannel *ioc);
++QEMUFile *qemu_file_new_output_sized(QIOChannel *ioc, size_t buffer_size);
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
- int qemu_get_fd(QEMUFile *f);
int qemu_fclose(QEMUFile *f);
+
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
-index b9a43c56bc..0bc5799cf8 100644
+index b3692739a0..e65a5e3482 100644
--- a/migration/savevm-async.c
+++ b/migration/savevm-async.c
-@@ -420,7 +420,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
- goto restart;
- }
+@@ -367,7 +367,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
-- snap_state.file = qemu_fopen_ops(&snap_state, &block_file_ops);
-+ snap_state.file = qemu_fopen_ops_sized(&snap_state, &block_file_ops, false, 4 * 1024 * 1024);
+ QIOChannel *ioc = QIO_CHANNEL(qio_channel_savevm_async_new(snap_state.target,
+ &snap_state.bs_pos));
+- snap_state.file = qemu_file_new_output(ioc);
++ snap_state.file = qemu_file_new_output_sized(ioc, 4 * 1024 * 1024);
if (!snap_state.file) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
-@@ -573,7 +573,7 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
+@@ -500,7 +500,8 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
blk_op_block_all(be, blocker);
/* restore the VM state */
-- f = qemu_fopen_ops(be, &loadstate_file_ops);
-+ f = qemu_fopen_ops_sized(be, &loadstate_file_ops, false, 4 * 1024 * 1024);
+- f = qemu_file_new_input(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)));
++ f = qemu_file_new_input_sized(QIO_CHANNEL(qio_channel_savevm_async_new(be, &bs_pos)),
++ 4 * 1024 * 1024);
if (!f) {
error_setg(errp, "Could not open VM state file");
goto the_end;
diff --git a/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch b/debian/patches/pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
similarity index 99%
rename from debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
rename to debian/patches/pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
index a0cc957..8f53db4 100644
--- a/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
+++ b/debian/patches/pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
@@ -13,7 +13,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
create mode 100644 block/zeroinit.c
diff --git a/block/meson.build b/block/meson.build
-index 0b2a60c99b..9451fc3ccd 100644
+index 60bc305597..ad40c10b6a 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -43,6 +43,7 @@ block_ss.add(files(
diff --git a/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch b/debian/patches/pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
similarity index 86%
rename from debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
rename to debian/patches/pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
index 488a70c..f0b18f5 100644
--- a/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
+++ b/debian/patches/pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
@@ -14,12 +14,12 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 11 insertions(+)
diff --git a/qemu-options.hx b/qemu-options.hx
-index aeade4ef80..a26f0b0400 100644
+index c2ca6e91b5..ab4734ef32 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -1075,6 +1075,9 @@ DEFHEADING()
+@@ -1118,6 +1118,9 @@ backend describes how QEMU handles the data.
- DEFHEADING(Block device options:)
+ ERST
+DEF("id", HAS_ARG, QEMU_OPTION_id,
+ "-id n set the VMID", QEMU_ARCH_ALL)
@@ -28,10 +28,10 @@ index aeade4ef80..a26f0b0400 100644
"-fda/-fdb file use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL)
DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL)
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index a3f2a3818c..4208142685 100644
+index b8637c4262..39f149924e 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -2785,6 +2785,7 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -2620,6 +2620,7 @@ void qemu_init(int argc, char **argv, char **envp)
MachineClass *machine_class;
bool userconfig = true;
FILE *vmstate_dump_file = NULL;
@@ -39,7 +39,7 @@ index a3f2a3818c..4208142685 100644
qemu_add_opts(&qemu_drive_opts);
qemu_add_drive_opts(&qemu_legacy_drive_opts);
-@@ -3420,6 +3421,13 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3245,6 +3246,13 @@ void qemu_init(int argc, char **argv, char **envp)
machine_parse_property_opt(qemu_find_opts("smp-opts"),
"smp", optarg);
break;
diff --git a/debian/patches/pve/0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch b/debian/patches/pve/0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
similarity index 100%
rename from debian/patches/pve/0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
rename to debian/patches/pve/0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
diff --git a/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch b/debian/patches/pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
similarity index 90%
rename from debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
rename to debian/patches/pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
index 99299d3..96b0193 100644
--- a/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+++ b/debian/patches/pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
@@ -13,10 +13,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index e5bf5d59bf..b013668dce 100644
+index 3d60b80286..49ee1db5f9 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -2461,6 +2461,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2475,6 +2475,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
int fd;
uint64_t perm, shared;
int result = 0;
@@ -24,7 +24,7 @@ index e5bf5d59bf..b013668dce 100644
/* Validate options and set default values */
assert(options->driver == BLOCKDEV_DRIVER_FILE);
-@@ -2501,19 +2502,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2515,19 +2516,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
perm = BLK_PERM_WRITE | BLK_PERM_RESIZE;
shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
@@ -59,7 +59,7 @@ index e5bf5d59bf..b013668dce 100644
}
/* Clear the file by truncating it to 0 */
-@@ -2567,13 +2571,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2581,13 +2585,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
}
out_unlock:
@@ -82,7 +82,7 @@ index e5bf5d59bf..b013668dce 100644
}
out_close:
-@@ -2598,6 +2604,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2612,6 +2618,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
PreallocMode prealloc;
char *buf = NULL;
Error *local_err = NULL;
@@ -90,7 +90,7 @@ index e5bf5d59bf..b013668dce 100644
/* Skip file: protocol prefix */
strstart(filename, "file:", &filename);
-@@ -2620,6 +2627,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2634,6 +2641,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
return -EINVAL;
}
@@ -109,7 +109,7 @@ index e5bf5d59bf..b013668dce 100644
options = (BlockdevCreateOptions) {
.driver = BLOCKDEV_DRIVER_FILE,
.u.file = {
-@@ -2631,6 +2650,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2645,6 +2664,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
.nocow = nocow,
.has_extent_size_hint = has_extent_size_hint,
.extent_size_hint = extent_size_hint,
@@ -119,10 +119,10 @@ index e5bf5d59bf..b013668dce 100644
};
return raw_co_create(&options, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index fb25c2b245..564b6b43f7 100644
+index e1857e7094..ddac91e8f6 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -4484,7 +4484,8 @@
+@@ -4537,7 +4537,8 @@
'size': 'size',
'*preallocation': 'PreallocMode',
'*nocow': 'bool',
diff --git a/debian/patches/pve/0022-PVE-monitor-disable-oob-capability.patch b/debian/patches/pve/0023-PVE-monitor-disable-oob-capability.patch
similarity index 100%
rename from debian/patches/pve/0022-PVE-monitor-disable-oob-capability.patch
rename to debian/patches/pve/0023-PVE-monitor-disable-oob-capability.patch
diff --git a/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch b/debian/patches/pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
similarity index 95%
rename from debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
rename to debian/patches/pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
index 61528fd..72f29ff 100644
--- a/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
+++ b/debian/patches/pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
@@ -26,10 +26,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
-index 1e23fdc14b..8a50445ee8 100644
+index a673302cce..fa424440bd 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
-@@ -118,7 +118,8 @@ GlobalProperty hw_compat_4_0[] = {
+@@ -127,7 +127,8 @@ GlobalProperty hw_compat_4_0[] = {
{ "virtio-vga", "edid", "false" },
{ "virtio-gpu-device", "edid", "false" },
{ "virtio-device", "use-started", "false" },
diff --git a/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch b/debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
similarity index 93%
rename from debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
rename to debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
index a0ca907..67fd0f6 100644
--- a/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
+++ b/debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
@@ -36,7 +36,7 @@ index 76fff60a6b..ec9201fb9a 100644
if (mc->default_cpu_type) {
diff --git a/include/hw/boards.h b/include/hw/boards.h
-index c92ac8815c..572d911ed4 100644
+index 7b416c9787..8ae15c51aa 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -230,6 +230,8 @@ struct MachineClass {
@@ -49,10 +49,10 @@ index c92ac8815c..572d911ed4 100644
void (*reset)(MachineState *state);
void (*wakeup)(MachineState *state);
diff --git a/qapi/machine.json b/qapi/machine.json
-index ca133e68ce..39ba204b52 100644
+index 555458f785..d868e4d31d 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -158,6 +158,8 @@
+@@ -157,6 +157,8 @@
#
# @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
#
@@ -61,7 +61,7 @@ index ca133e68ce..39ba204b52 100644
# Since: 1.2
##
{ 'struct': 'MachineInfo',
-@@ -165,7 +167,7 @@
+@@ -164,7 +166,7 @@
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
'deprecated': 'bool', '*default-cpu-type': 'str',
@@ -71,10 +71,10 @@ index ca133e68ce..39ba204b52 100644
##
# @query-machines:
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 4208142685..37d85f1b96 100644
+index 39f149924e..0d233d55f3 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -1659,6 +1659,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
+@@ -1580,6 +1580,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
static MachineClass *select_machine(QDict *qdict, Error **errp)
{
const char *optarg = qdict_get_try_str(qdict, "type");
@@ -82,7 +82,7 @@ index 4208142685..37d85f1b96 100644
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
MachineClass *machine_class;
Error *local_err = NULL;
-@@ -1676,6 +1677,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
+@@ -1597,6 +1598,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
}
}
@@ -94,7 +94,7 @@ index 4208142685..37d85f1b96 100644
g_slist_free(machines);
if (local_err) {
error_append_hint(&local_err, "Use -machine help to list supported machines\n");
-@@ -3362,12 +3368,31 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3187,12 +3193,31 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_machine:
{
bool help;
diff --git a/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch b/debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
similarity index 88%
rename from debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
rename to debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
index 8621cdf..a1ce276 100644
--- a/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
+++ b/debian/patches/pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
@@ -25,11 +25,11 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/backup.c b/block/backup.c
-index 5cfd0b999c..07b899035c 100644
+index b2b649e305..b6fa9e8a69 100644
--- a/block/backup.c
+++ b/block/backup.c
-@@ -239,8 +239,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
- assert(ret);
+@@ -237,8 +237,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
+ true);
} else if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
/*
- * We can't hog the coroutine to initialize this thoroughly.
@@ -39,7 +39,7 @@ index 5cfd0b999c..07b899035c 100644
*/
block_copy_set_skip_unallocated(job->bcs, true);
}
-@@ -254,8 +254,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
+@@ -252,8 +252,6 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
int ret;
@@ -48,7 +48,7 @@ index 5cfd0b999c..07b899035c 100644
if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
int64_t offset = 0;
int64_t count;
-@@ -494,6 +492,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
+@@ -492,6 +490,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
&error_abort);
diff --git a/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
similarity index 99%
rename from debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch
rename to debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
index ced8e74..cf67937 100644
--- a/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch
+++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
@@ -9,18 +9,18 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
block/meson.build | 2 +
meson.build | 5 +
- vma-reader.c | 860 ++++++++++++++++++++++++++++++++++++++++++++++
+ vma-reader.c | 859 ++++++++++++++++++++++++++++++++++++++++++++++
vma-writer.c | 791 ++++++++++++++++++++++++++++++++++++++++++
- vma.c | 850 +++++++++++++++++++++++++++++++++++++++++++++
+ vma.c | 849 +++++++++++++++++++++++++++++++++++++++++++++
vma.h | 150 ++++++++
- 6 files changed, 2658 insertions(+)
+ 6 files changed, 2656 insertions(+)
create mode 100644 vma-reader.c
create mode 100644 vma-writer.c
create mode 100644 vma.c
create mode 100644 vma.h
diff --git a/block/meson.build b/block/meson.build
-index 9451fc3ccd..819eb80951 100644
+index ad40c10b6a..3a0b84bc11 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -46,6 +46,8 @@ block_ss.add(files(
@@ -33,10 +33,10 @@ index 9451fc3ccd..819eb80951 100644
if get_option('qcow1').allowed()
diff --git a/meson.build b/meson.build
-index 861de93c4f..96a91b95e4 100644
+index d5230eadd6..ffff66c0cc 100644
--- a/meson.build
+++ b/meson.build
-@@ -1267,6 +1267,8 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1462,6 +1462,8 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
@@ -45,7 +45,7 @@ index 861de93c4f..96a91b95e4 100644
# libselinux
selinux = dependency('libselinux',
required: get_option('selinux'),
-@@ -3359,6 +3361,9 @@ if have_tools
+@@ -3607,6 +3609,9 @@ if have_tools
dependencies: [blockdev, qemuutil, gnutls, selinux],
install: true)
@@ -57,10 +57,10 @@ index 861de93c4f..96a91b95e4 100644
subdir('contrib/elf2dmp')
diff --git a/vma-reader.c b/vma-reader.c
new file mode 100644
-index 0000000000..4f4ee2b47b
+index 0000000000..e65f1e8415
--- /dev/null
+++ b/vma-reader.c
-@@ -0,0 +1,860 @@
+@@ -0,0 +1,859 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -78,7 +78,6 @@ index 0000000000..4f4ee2b47b
+#include <glib.h>
+#include <uuid/uuid.h>
+
-+#include "qemu-common.h"
+#include "qemu/timer.h"
+#include "qemu/ratelimit.h"
+#include "vma.h"
@@ -589,7 +588,7 @@ index 0000000000..4f4ee2b47b
+ }
+ }
+ } else {
-+ int res = blk_pwrite(target, sector_num * BDRV_SECTOR_SIZE, buf, nb_sectors * BDRV_SECTOR_SIZE, 0);
++ int res = blk_pwrite(target, sector_num * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE, buf, 0);
+ if (res < 0) {
+ error_setg(errp, "blk_pwrite to %s failed (%d)",
+ bdrv_get_device_name(blk_bs(target)), res);
@@ -1720,10 +1719,10 @@ index 0000000000..df4b20793d
+}
diff --git a/vma.c b/vma.c
new file mode 100644
-index 0000000000..91612d50a2
+index 0000000000..e8dffb43e0
--- /dev/null
+++ b/vma.c
-@@ -0,0 +1,850 @@
+@@ -0,0 +1,849 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -1741,7 +1740,6 @@ index 0000000000..91612d50a2
+#include <glib.h>
+
+#include "vma.h"
-+#include "qemu-common.h"
+#include "qemu/module.h"
+#include "qemu/error-report.h"
+#include "qemu/main-loop.h"
diff --git a/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch b/debian/patches/pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
similarity index 96%
rename from debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
rename to debian/patches/pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
index ea3bb84..548ce20 100644
--- a/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
+++ b/debian/patches/pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
@@ -10,20 +10,20 @@ Subject: [PATCH] PVE-Backup: add backup-dump block driver
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
- block/backup-dump.c | 168 +++++++++++++++++++++++++++++++
+ block/backup-dump.c | 167 +++++++++++++++++++++++++++++++
block/backup.c | 30 ++----
block/meson.build | 1 +
include/block/block_int-common.h | 35 +++++++
job.c | 3 +-
- 5 files changed, 214 insertions(+), 23 deletions(-)
+ 5 files changed, 213 insertions(+), 23 deletions(-)
create mode 100644 block/backup-dump.c
diff --git a/block/backup-dump.c b/block/backup-dump.c
new file mode 100644
-index 0000000000..93d7f46950
+index 0000000000..04718a94e2
--- /dev/null
+++ b/block/backup-dump.c
-@@ -0,0 +1,168 @@
+@@ -0,0 +1,167 @@
+/*
+ * BlockDriver to send backup data stream to a callback function
+ *
@@ -35,7 +35,6 @@ index 0000000000..93d7f46950
+ */
+
+#include "qemu/osdep.h"
-+#include "qemu-common.h"
+#include "qom/object_interfaces.h"
+#include "block/block_int.h"
+
@@ -193,7 +192,7 @@ index 0000000000..93d7f46950
+ return bs;
+}
diff --git a/block/backup.c b/block/backup.c
-index 07b899035c..7b5d02f580 100644
+index b6fa9e8a69..789f8b7799 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -29,28 +29,6 @@
@@ -225,7 +224,7 @@ index 07b899035c..7b5d02f580 100644
static const BlockJobDriver backup_job_driver;
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
-@@ -456,6 +434,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
+@@ -454,6 +432,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
}
cluster_size = block_copy_cluster_size(bcs);
@@ -241,7 +240,7 @@ index 07b899035c..7b5d02f580 100644
if (perf->max_chunk && perf->max_chunk < cluster_size) {
error_setg(errp, "Required max-chunk (%" PRIi64 ") is less than backup "
diff --git a/block/meson.build b/block/meson.build
-index 819eb80951..067708b7c0 100644
+index 3a0b84bc11..7f22e7f177 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -4,6 +4,7 @@ block_ss.add(files(
diff --git a/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch b/debian/patches/pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
similarity index 98%
rename from debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
rename to debian/patches/pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
index faa9483..58bc045 100644
--- a/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
+++ b/debian/patches/pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
@@ -30,7 +30,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
create mode 100644 pve-backup.c
diff --git a/block/meson.build b/block/meson.build
-index 067708b7c0..42aac96dbb 100644
+index 7f22e7f177..2783b77e9c 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -48,6 +48,11 @@ block_ss.add(files(
@@ -87,7 +87,7 @@ index bfb3c043a0..89ca64444d 100644
+ hmp_handle_error(mon, error);
+}
diff --git a/blockdev.c b/blockdev.c
-index 1af5a1fcb2..9916a72334 100644
+index ce62a9b439..1600b24eab 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -36,6 +36,7 @@
@@ -99,7 +99,7 @@ index 1af5a1fcb2..9916a72334 100644
#include "monitor/monitor.h"
#include "qemu/error-report.h"
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index 925e680e5a..d9b787d2c6 100644
+index 97b88eaaad..92a8867afb 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -484,6 +484,20 @@ SRST
@@ -124,10 +124,10 @@ index 925e680e5a..d9b787d2c6 100644
{
.name = "usernet",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 7f0ac498c4..994445f301 100644
+index bbcc73e942..97f24942b3 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
-@@ -99,6 +99,35 @@ ERST
+@@ -101,6 +101,35 @@ ERST
SRST
``block_stream``
Copy data from a backing file into a block device.
@@ -164,7 +164,7 @@ index 7f0ac498c4..994445f301 100644
{
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
-index 3a39ba41b5..d269b4c99c 100644
+index 55067beff1..5a98d2d927 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -30,6 +30,7 @@ void hmp_info_savevm(Monitor *mon, const QDict *qdict);
@@ -185,10 +185,10 @@ index 3a39ba41b5..d269b4c99c 100644
void hmp_device_add(Monitor *mon, const QDict *qdict);
void hmp_device_del(Monitor *mon, const QDict *qdict);
diff --git a/meson.build b/meson.build
-index 96a91b95e4..76fcb23299 100644
+index ffff66c0cc..0bc2fb5b10 100644
--- a/meson.build
+++ b/meson.build
-@@ -1268,6 +1268,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1463,6 +1463,7 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
libuuid = cc.find_library('uuid', required: true)
@@ -197,10 +197,10 @@ index 96a91b95e4..76fcb23299 100644
# libselinux
selinux = dependency('libselinux',
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index c64b959738..ef654221c4 100644
+index 1507180990..1168773da7 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -195,6 +195,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
+@@ -197,6 +197,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
qapi_free_MouseInfoList(mice_list);
}
@@ -1464,12 +1464,12 @@ index 0000000000..88f5ee133f
+ return info;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 564b6b43f7..ffcc25367b 100644
+index ddac91e8f6..90ad07b7ee 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -744,6 +744,115 @@
- { 'command': 'query-block', 'returns': ['BlockInfo'] }
-
+@@ -740,6 +740,115 @@
+ { 'command': 'query-block', 'returns': ['BlockInfo'],
+ 'allow-preconfig': true }
+##
+# @BackupStatus:
@@ -1584,10 +1584,10 @@ index 564b6b43f7..ffcc25367b 100644
# @BlockDeviceTimedStats:
#
diff --git a/qapi/common.json b/qapi/common.json
-index 412cc4f5ae..3e7a77ea66 100644
+index 356db3f670..aae8a3b682 100644
--- a/qapi/common.json
+++ b/qapi/common.json
-@@ -208,3 +208,16 @@
+@@ -206,3 +206,16 @@
##
{ 'struct': 'HumanReadableText',
'data': { 'human-readable-text': 'str' } }
@@ -1605,7 +1605,7 @@ index 412cc4f5ae..3e7a77ea66 100644
+##
+{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
diff --git a/qapi/machine.json b/qapi/machine.json
-index 39ba204b52..091aafeff7 100644
+index d868e4d31d..a63d9a078d 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -4,6 +4,8 @@
@@ -1617,7 +1617,7 @@ index 39ba204b52..091aafeff7 100644
##
# = Machines
##
-@@ -227,19 +229,6 @@
+@@ -226,19 +228,6 @@
##
{ 'command': 'query-target', 'returns': 'TargetInfo' }
diff --git a/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch b/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
similarity index 95%
rename from debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
rename to debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
index f1c77cb..6c61992 100644
--- a/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
+++ b/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
@@ -7,15 +7,15 @@ Subject: [PATCH] PVE-Backup: pbs-restore - new command to restore from proxmox
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
meson.build | 4 +
- pbs-restore.c | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 228 insertions(+)
+ pbs-restore.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 227 insertions(+)
create mode 100644 pbs-restore.c
diff --git a/meson.build b/meson.build
-index 76fcb23299..9476ccbe07 100644
+index 0bc2fb5b10..f48d2e0457 100644
--- a/meson.build
+++ b/meson.build
-@@ -3365,6 +3365,10 @@ if have_tools
+@@ -3613,6 +3613,10 @@ if have_tools
vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
dependencies: [authz, block, crypto, io, qom], install: true)
@@ -28,10 +28,10 @@ index 76fcb23299..9476ccbe07 100644
subdir('contrib/elf2dmp')
diff --git a/pbs-restore.c b/pbs-restore.c
new file mode 100644
-index 0000000000..4d3f925a1b
+index 0000000000..2f834cf42e
--- /dev/null
+++ b/pbs-restore.c
-@@ -0,0 +1,224 @@
+@@ -0,0 +1,223 @@
+/*
+ * Qemu image restore helper for Proxmox Backup
+ *
@@ -50,7 +50,6 @@ index 0000000000..4d3f925a1b
+#include <getopt.h>
+#include <string.h>
+
-+#include "qemu-common.h"
+#include "qemu/module.h"
+#include "qemu/error-report.h"
+#include "qemu/main-loop.h"
@@ -96,7 +95,7 @@ index 0000000000..4d3f925a1b
+ }
+ res = blk_pwrite_zeroes(callback_data->target, offset, data_len, 0);
+ } else {
-+ res = blk_pwrite(callback_data->target, offset, data, data_len, 0);
++ res = blk_pwrite(callback_data->target, offset, data_len, data, 0);
+ }
+
+ if (res < 0) {
diff --git a/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch b/debian/patches/pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
similarity index 98%
rename from debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
rename to debian/patches/pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
index 012c0b3..8d37565 100644
--- a/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
+++ b/debian/patches/pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
@@ -41,10 +41,10 @@ index 89ca64444d..45da74d7a0 100644
false, NULL, false, NULL, !!devlist,
devlist, qdict_haskey(qdict, "speed"), speed, &error);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index ef654221c4..c5c74ac1dc 100644
+index 1168773da7..4c1671e289 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -221,19 +221,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
+@@ -223,19 +223,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "End time: %s", ctime(&info->end_time));
}
@@ -405,10 +405,10 @@ index 88f5ee133f..1c49cd178d 100644
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index ffcc25367b..b332d8a8da 100644
+index 90ad07b7ee..3ad9eb5d1a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -757,8 +757,13 @@
+@@ -753,8 +753,13 @@
#
# @total: total amount of bytes involved in the backup process
#
@@ -422,7 +422,7 @@ index ffcc25367b..b332d8a8da 100644
# @zero-bytes: amount of 'zero' bytes detected.
#
# @start-time: time (epoch) when backup job started.
-@@ -771,8 +776,8 @@
+@@ -767,8 +772,8 @@
#
##
{ 'struct': 'BackupStatus',
@@ -433,7 +433,7 @@ index ffcc25367b..b332d8a8da 100644
'*start-time': 'int', '*end-time': 'int',
'*backup-file': 'str', '*uuid': 'str' } }
-@@ -815,6 +820,8 @@
+@@ -811,6 +816,8 @@
#
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
#
@@ -442,7 +442,7 @@ index ffcc25367b..b332d8a8da 100644
# Returns: the uuid of the backup job
#
##
-@@ -825,6 +832,7 @@
+@@ -821,6 +828,7 @@
'*fingerprint': 'str',
'*backup-id': 'str',
'*backup-time': 'int',
diff --git a/debian/patches/pve/0031-PVE-various-PBS-fixes.patch b/debian/patches/pve/0032-PVE-various-PBS-fixes.patch
similarity index 99%
rename from debian/patches/pve/0031-PVE-various-PBS-fixes.patch
rename to debian/patches/pve/0032-PVE-various-PBS-fixes.patch
index e5ebc18..3bd8426 100644
--- a/debian/patches/pve/0031-PVE-various-PBS-fixes.patch
+++ b/debian/patches/pve/0032-PVE-various-PBS-fixes.patch
@@ -194,10 +194,10 @@ index 1c49cd178d..c15abefdda 100644
.format = format,
.has_config_file = has_config_file,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index b332d8a8da..abef91062a 100644
+index 3ad9eb5d1a..4120052690 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -822,6 +822,10 @@
+@@ -818,6 +818,10 @@
#
# @use-dirty-bitmap: use dirty bitmap to detect incremental changes since last job (optional for format 'pbs')
#
@@ -208,7 +208,7 @@ index b332d8a8da..abef91062a 100644
# Returns: the uuid of the backup job
#
##
-@@ -833,6 +837,8 @@
+@@ -829,6 +833,8 @@
'*backup-id': 'str',
'*backup-time': 'int',
'*use-dirty-bitmap': 'bool',
diff --git a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch b/debian/patches/pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
similarity index 91%
rename from debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
rename to debian/patches/pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
index 3b08ed1..9a850c0 100644
--- a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+++ b/debian/patches/pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
@@ -13,13 +13,13 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
block/meson.build | 3 +
block/pbs.c | 276 +++++++++++++++++++++++++++++++++++++++++++
configure | 9 ++
- meson.build | 1 +
+ meson.build | 2 +-
qapi/block-core.json | 13 ++
- 5 files changed, 302 insertions(+)
+ 5 files changed, 302 insertions(+), 1 deletion(-)
create mode 100644 block/pbs.c
diff --git a/block/meson.build b/block/meson.build
-index 42aac96dbb..f94cc0cd25 100644
+index 2783b77e9c..a26a69434e 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -53,6 +53,9 @@ block_ss.add(files(
@@ -315,63 +315,64 @@ index 0000000000..0b05ea9080
+
+block_init(bdrv_pbs_init);
diff --git a/configure b/configure
-index 7c08c18358..08d164b4f5 100755
+index 72ab03f11a..7203c270ec 100755
--- a/configure
+++ b/configure
-@@ -325,6 +325,7 @@ trace_file="trace"
- opengl="$default_feature"
+@@ -309,6 +309,7 @@ linux_user=""
+ bsd_user=""
+ pie=""
coroutine=""
- tls_priority="NORMAL"
+pbs_bdrv="yes"
plugins="$default_feature"
- secret_keyring="$default_feature"
meson=""
-@@ -991,6 +992,10 @@ for opt do
- ;;
- --disable-pvrdma) pvrdma="no"
+ meson_args=""
+@@ -902,6 +903,10 @@ for opt do
+ --enable-uuid|--disable-uuid)
+ echo "$0: $opt is obsolete, UUID support is always built" >&2
;;
+ --disable-pbs-bdrv) pbs_bdrv="no"
+ ;;
+ --enable-pbs-bdrv) pbs_bdrv="yes"
+ ;;
- --disable-vhost-user) vhost_user="no"
+ --with-git=*) git="$optarg"
;;
- --enable-vhost-user) vhost_user="yes"
-@@ -1265,6 +1270,7 @@ cat << EOF
- vhost-user vhost-user backend support
- vhost-vdpa vhost-vdpa kernel backend support
- opengl opengl support
+ --with-git-submodules=*)
+@@ -1087,6 +1092,7 @@ cat << EOF
+ debug-info debugging information
+ safe-stack SafeStack Stack Smash Protection. Depends on
+ clang/llvm >= 3.7 and requires coroutine backend ucontext.
+ pbs-bdrv Proxmox backup server read-only block driver support
- gio libgio support
NOTE: The object files are built at the place where configure is launched
-@@ -2848,6 +2854,9 @@ if test "$xen" = "enabled" ; then
- echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
- echo "XEN_LIBS=$xen_libs" >> $config_host_mak
+ EOF
+@@ -2463,6 +2469,9 @@ echo "TARGET_DIRS=$target_list" >> $config_host_mak
+ if test "$modules" = "yes"; then
+ echo "CONFIG_MODULES=y" >> $config_host_mak
fi
+if test "$pbs_bdrv" = "yes" ; then
+ echo "CONFIG_PBS_BDRV=y" >> $config_host_mak
+fi
- if test "$vhost_scsi" = "yes" ; then
- echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
- fi
+
+ # XXX: suppress that
+ if [ "$bsd" = "yes" ] ; then
diff --git a/meson.build b/meson.build
-index 9476ccbe07..d3783a83e4 100644
+index f48d2e0457..be4785e2f6 100644
--- a/meson.build
+++ b/meson.build
-@@ -3743,6 +3743,7 @@ summary_info += {'bzip2 support': libbzip2}
+@@ -3986,7 +3986,7 @@ summary_info += {'bzip2 support': libbzip2}
summary_info += {'lzfse support': liblzfse}
summary_info += {'zstd support': zstd}
summary_info += {'NUMA host support': numa}
+-summary_info += {'capstone': capstone}
+summary_info += {'PBS bdrv support': config_host.has_key('CONFIG_PBS_BDRV')}
- summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
summary_info += {'libpmem support': libpmem}
summary_info += {'libdaxctl support': libdaxctl}
+ summary_info += {'libudev': libudev}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index abef91062a..68591cb343 100644
+index 4120052690..96bc696aaa 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3073,6 +3073,7 @@
+@@ -3099,6 +3099,7 @@
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
@@ -379,7 +380,7 @@ index abef91062a..68591cb343 100644
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
##
-@@ -3145,6 +3146,17 @@
+@@ -3171,6 +3172,17 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -397,7 +398,7 @@ index abef91062a..68591cb343 100644
##
# @BlockdevOptionsNVMe:
#
-@@ -4405,6 +4417,7 @@
+@@ -4455,6 +4467,7 @@
'nfs': 'BlockdevOptionsNfs',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
diff --git a/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch b/debian/patches/pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
similarity index 97%
rename from debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
rename to debian/patches/pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
index 0f1f0c6..dbcef29 100644
--- a/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
+++ b/debian/patches/pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
@@ -33,10 +33,10 @@ index c15abefdda..4684789813 100644
+ return ret;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 68591cb343..7d25aa4fa1 100644
+index 96bc696aaa..0b453c61d4 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -867,6 +867,35 @@
+@@ -863,6 +863,35 @@
##
{ 'command': 'backup-cancel' }
diff --git a/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch b/debian/patches/pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
similarity index 98%
rename from debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
rename to debian/patches/pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
index d3ba75c..29a96d1 100644
--- a/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
+++ b/debian/patches/pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
@@ -15,10 +15,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 159 insertions(+), 42 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index c5c74ac1dc..df273f41fb 100644
+index 4c1671e289..c1152f55a7 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -198,6 +198,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
+@@ -200,6 +200,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
void hmp_info_backup(Monitor *mon, const QDict *qdict)
{
BackupStatus *info;
@@ -26,7 +26,7 @@ index c5c74ac1dc..df273f41fb 100644
info = qmp_query_backup(NULL);
-@@ -228,26 +229,29 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
+@@ -230,26 +231,29 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
// this should not happen normally
monitor_printf(mon, "Total size: %d\n", 0);
} else {
@@ -359,10 +359,10 @@ index 4684789813..f90abaa50a 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 7d25aa4fa1..69571d86eb 100644
+index 0b453c61d4..16e184dd28 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -875,6 +875,8 @@
+@@ -871,6 +871,8 @@
# @pbs-dirty-bitmap: True if dirty-bitmap-incremental backups to PBS are
# supported.
#
@@ -371,7 +371,7 @@ index 7d25aa4fa1..69571d86eb 100644
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
# safely be set for savevm-async.
#
-@@ -883,6 +885,7 @@
+@@ -879,6 +881,7 @@
##
{ 'struct': 'ProxmoxSupportStatus',
'data': { 'pbs-dirty-bitmap': 'bool',
@@ -379,7 +379,7 @@ index 7d25aa4fa1..69571d86eb 100644
'pbs-dirty-bitmap-savevm': 'bool',
'pbs-library-version': 'str' } }
-@@ -896,6 +899,59 @@
+@@ -892,6 +895,59 @@
##
{ 'command': 'query-proxmox-support', 'returns': 'ProxmoxSupportStatus' }
diff --git a/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch b/debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
similarity index 86%
rename from debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
rename to debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
index 89727a4..c5be26b 100644
--- a/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
+++ b/debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
-index d3783a83e4..715245ba20 100644
+index be4785e2f6..3fc7c8d435 100644
--- a/meson.build
+++ b/meson.build
-@@ -1268,6 +1268,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1463,6 +1463,7 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
libuuid = cc.find_library('uuid', required: true)
@@ -25,7 +25,7 @@ index d3783a83e4..715245ba20 100644
libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
# libselinux
-@@ -2861,6 +2862,7 @@ if have_block
+@@ -3105,6 +3106,7 @@ if have_block
# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
# os-win32.c does not
blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
@@ -34,7 +34,7 @@ index d3783a83e4..715245ba20 100644
endif
diff --git a/os-posix.c b/os-posix.c
-index 24692c8593..d1bc5ac12d 100644
+index 321fc4bd13..b1870d2690 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -28,6 +28,8 @@
@@ -44,15 +44,15 @@ index 24692c8593..d1bc5ac12d 100644
+#include <systemd/sd-journal.h>
+#include <syslog.h>
- #include "qemu-common.h"
/* Needed early for CONFIG_BSD etc. */
-@@ -291,9 +293,10 @@ void os_setup_post(void)
+ #include "net/slirp.h"
+@@ -281,9 +283,10 @@ void os_setup_post(void)
dup2(fd, 0);
dup2(fd, 1);
- /* In case -D is given do not redirect stderr to /dev/null */
+ /* In case -D is given do not redirect stderr to journal */
- if (!qemu_logfile) {
+ if (!qemu_log_enabled()) {
- dup2(fd, 2);
+ int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0);
+ dup2(journal_fd, 2);
diff --git a/debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch b/debian/patches/pve/0037-PVE-Add-sequential-job-transaction-support.patch
similarity index 100%
rename from debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch
rename to debian/patches/pve/0037-PVE-Add-sequential-job-transaction-support.patch
diff --git a/debian/patches/pve/0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch b/debian/patches/pve/0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
similarity index 100%
rename from debian/patches/pve/0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
rename to debian/patches/pve/0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
diff --git a/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch b/debian/patches/pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
similarity index 99%
rename from debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
rename to debian/patches/pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
index 51a2b53..44c167b 100644
--- a/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
+++ b/debian/patches/pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
@@ -481,10 +481,10 @@ index 63c686463f..6f05796fad 100644
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 69571d86eb..e6c3687bea 100644
+index 16e184dd28..cb17d00fe0 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -774,12 +774,15 @@
+@@ -770,12 +770,15 @@
#
# @uuid: uuid for this backup job
#
diff --git a/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
similarity index 96%
rename from debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
rename to debian/patches/pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
index 36c6d96..e80a716 100644
--- a/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+++ b/debian/patches/pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
@@ -36,11 +36,11 @@ index 465906710d..4f0aeceb6f 100644
+
#endif
diff --git a/migration/meson.build b/migration/meson.build
-index 1e2aec8486..259e863a43 100644
+index 0842d00cd2..d012f4d8d3 100644
--- a/migration/meson.build
+++ b/migration/meson.build
-@@ -7,8 +7,10 @@ migration_files = files(
- 'qemu-file-channel.c',
+@@ -6,8 +6,10 @@ migration_files = files(
+ 'vmstate.c',
'qemu-file.c',
'yank_functions.c',
+ 'pbs-state.c',
@@ -51,10 +51,10 @@ index 1e2aec8486..259e863a43 100644
softmmu_ss.add(files(
'block-dirty-bitmap.c',
diff --git a/migration/migration.c b/migration/migration.c
-index 695f0f2900..6e17f8e91c 100644
+index bb8bbddfe4..8109e468eb 100644
--- a/migration/migration.c
+++ b/migration/migration.c
-@@ -214,6 +214,7 @@ void migration_object_init(void)
+@@ -229,6 +229,7 @@ void migration_object_init(void)
blk_mig_init();
ram_mig_init();
dirty_bitmap_mig_init();
@@ -187,10 +187,10 @@ index 6f05796fad..5fa3cc1352 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index e6c3687bea..05382a1069 100644
+index cb17d00fe0..bd978ea562 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -883,6 +883,11 @@
+@@ -879,6 +879,11 @@
# @pbs-dirty-bitmap-savevm: True if 'dirty-bitmaps' migration capability can
# safely be set for savevm-async.
#
@@ -202,7 +202,7 @@ index e6c3687bea..05382a1069 100644
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
#
##
-@@ -890,6 +895,7 @@
+@@ -886,6 +891,7 @@
'data': { 'pbs-dirty-bitmap': 'bool',
'query-bitmap-info': 'bool',
'pbs-dirty-bitmap-savevm': 'bool',
diff --git a/debian/patches/pve/0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch b/debian/patches/pve/0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
similarity index 100%
rename from debian/patches/pve/0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
rename to debian/patches/pve/0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
diff --git a/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch b/debian/patches/pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
similarity index 98%
rename from debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
rename to debian/patches/pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
index c30bb2b..bed3e62 100644
--- a/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
+++ b/debian/patches/pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
@@ -21,7 +21,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 30 insertions(+)
diff --git a/block/iscsi.c b/block/iscsi.c
-index 51f2a5eeaa..f11591ac94 100644
+index d707d0b354..da6ed52323 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1386,12 +1386,42 @@ static char *get_initiator_name(QemuOpts *opts)
diff --git a/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch b/debian/patches/pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
similarity index 99%
rename from debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
rename to debian/patches/pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
index 3de10a6..c07cdce 100644
--- a/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
+++ b/debian/patches/pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
@@ -54,10 +54,10 @@ index ea7b665aa2..ef45552e3b 100644
Error *error = NULL;
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 994445f301..aaea875970 100644
+index 97f24942b3..7a2be816da 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
-@@ -109,6 +109,7 @@ ERST
+@@ -111,6 +111,7 @@ ERST
"\n\t\t\t Use -d to dump data into a directory instead"
"\n\t\t\t of using VMA format.",
.cmd = hmp_backup,
@@ -65,7 +65,7 @@ index 994445f301..aaea875970 100644
},
SRST
-@@ -122,6 +123,7 @@ ERST
+@@ -124,6 +125,7 @@ ERST
.params = "",
.help = "cancel the current VM backup",
.cmd = hmp_backup_cancel,
@@ -575,10 +575,10 @@ index 5fa3cc1352..323014744c 100644
BackupStatus *qmp_query_backup(Error **errp)
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 05382a1069..f0399bf249 100644
+index bd978ea562..ca1966f54b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -846,7 +846,7 @@
+@@ -842,7 +842,7 @@
'*config-file': 'str',
'*firewall-file': 'str',
'*devlist': 'str', '*speed': 'int' },
@@ -587,7 +587,7 @@ index 05382a1069..f0399bf249 100644
##
# @query-backup:
-@@ -868,7 +868,7 @@
+@@ -864,7 +864,7 @@
# Notes: This command succeeds even if there is no backup process running.
#
##
diff --git a/debian/patches/pve/0043-PBS-add-master-key-support.patch b/debian/patches/pve/0044-PBS-add-master-key-support.patch
similarity index 97%
rename from debian/patches/pve/0043-PBS-add-master-key-support.patch
rename to debian/patches/pve/0044-PBS-add-master-key-support.patch
index 356cfd9..1716c05 100644
--- a/debian/patches/pve/0043-PBS-add-master-key-support.patch
+++ b/debian/patches/pve/0044-PBS-add-master-key-support.patch
@@ -58,10 +58,10 @@ index 323014744c..9f6c04a512 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index f0399bf249..13e03ca154 100644
+index ca1966f54b..fc8a125451 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -817,6 +817,8 @@
+@@ -813,6 +813,8 @@
#
# @key-password: password for keyfile (optional for format 'pbs')
#
@@ -70,7 +70,7 @@ index f0399bf249..13e03ca154 100644
# @fingerprint: server cert fingerprint (optional for format 'pbs')
#
# @backup-id: backup ID (required for format 'pbs')
-@@ -836,6 +838,7 @@
+@@ -832,6 +834,7 @@
'*password': 'str',
'*keyfile': 'str',
'*key-password': 'str',
@@ -78,7 +78,7 @@ index f0399bf249..13e03ca154 100644
'*fingerprint': 'str',
'*backup-id': 'str',
'*backup-time': 'int',
-@@ -888,6 +891,9 @@
+@@ -884,6 +887,9 @@
# migration cap if this is false/unset may lead
# to crashes on migration!
#
@@ -88,7 +88,7 @@ index f0399bf249..13e03ca154 100644
# @pbs-library-version: Running version of libproxmox-backup-qemu0 library.
#
##
-@@ -896,6 +902,7 @@
+@@ -892,6 +898,7 @@
'query-bitmap-info': 'bool',
'pbs-dirty-bitmap-savevm': 'bool',
'pbs-dirty-bitmap-migration': 'bool',
diff --git a/debian/patches/pve/0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch b/debian/patches/pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
similarity index 100%
rename from debian/patches/pve/0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
rename to debian/patches/pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
diff --git a/debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch b/debian/patches/pve/0046-PVE-block-stream-increase-chunk-size.patch
similarity index 100%
rename from debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch
rename to debian/patches/pve/0046-PVE-block-stream-increase-chunk-size.patch
diff --git a/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch b/debian/patches/pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
similarity index 90%
rename from debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
rename to debian/patches/pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
index d1d30b1..b294d43 100644
--- a/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
+++ b/debian/patches/pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
@@ -17,10 +17,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+)
diff --git a/block/io.c b/block/io.c
-index 3280144a17..cd7ba08768 100644
+index 0a8cbefe86..531b3b7a2d 100644
--- a/block/io.c
+++ b/block/io.c
-@@ -1794,6 +1794,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
+@@ -1734,6 +1734,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
{
int ret;
diff --git a/debian/patches/pve/0047-block-add-alloc-track-driver.patch b/debian/patches/pve/0048-block-add-alloc-track-driver.patch
similarity index 99%
rename from debian/patches/pve/0047-block-add-alloc-track-driver.patch
rename to debian/patches/pve/0048-block-add-alloc-track-driver.patch
index 1cf88ab..45c1c4d 100644
--- a/debian/patches/pve/0047-block-add-alloc-track-driver.patch
+++ b/debian/patches/pve/0048-block-add-alloc-track-driver.patch
@@ -389,7 +389,7 @@ index 0000000000..6b50fbe537
+
+block_init(bdrv_alloc_track_init);
diff --git a/block/meson.build b/block/meson.build
-index f94cc0cd25..1716febb1d 100644
+index a26a69434e..74e5f49758 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -2,6 +2,7 @@ block_ss.add(genh)
diff --git a/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch b/debian/patches/pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
similarity index 95%
rename from debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
rename to debian/patches/pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
index 0496b93..95f191f 100644
--- a/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
+++ b/debian/patches/pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
@@ -10,7 +10,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/qapi/pragma.json b/qapi/pragma.json
-index 41139d8645..a581acf7d4 100644
+index a2358e303a..9ff5c84ffd 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
@@ -15,6 +15,7 @@
@@ -21,7 +21,7 @@ index 41139d8645..a581acf7d4 100644
'migrate_cancel',
'netdev_add',
'netdev_del',
-@@ -63,6 +64,8 @@
+@@ -64,6 +65,8 @@
'SysEmuTarget', # query-cpu-fast, query-target
'UuidInfo', # query-uuid
'VncClientInfo', # query-vnc, query-vnc-servers, ...
diff --git a/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch b/debian/patches/pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
similarity index 90%
rename from debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
rename to debian/patches/pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
index a9413ab..68622c2 100644
--- a/debian/patches/pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
+++ b/debian/patches/pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 5 insertions(+)
diff --git a/migration/savevm-async.c b/migration/savevm-async.c
-index 0bc5799cf8..10ebefef06 100644
+index e65a5e3482..2ed2536816 100644
--- a/migration/savevm-async.c
+++ b/migration/savevm-async.c
-@@ -19,6 +19,7 @@
+@@ -20,6 +20,7 @@
#include "qemu/timer.h"
#include "qemu/main-loop.h"
#include "qemu/rcu.h"
@@ -22,7 +22,7 @@ index 0bc5799cf8..10ebefef06 100644
/* #define DEBUG_SAVEVM_STATE */
-@@ -586,6 +587,10 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
+@@ -514,6 +515,10 @@ int load_snapshot_from_blockdev(const char *filename, Error **errp)
dirty_bitmap_mig_before_vm_start();
qemu_fclose(f);
diff --git a/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch b/debian/patches/pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
similarity index 91%
rename from debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
rename to debian/patches/pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
index 9b7c51e..e5c467d 100644
--- a/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
+++ b/debian/patches/pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
@@ -12,7 +12,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index 33979b7430..68e9c80788 100644
+index 699229eef6..4189ced8bc 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -492,10 +492,10 @@ Command description:
@@ -46,10 +46,10 @@ index b5b0bb4467..36f97e1f19 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 35c2bdc95c..6e93bbd425 100644
+index c6b4a5567d..041c203fc3 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4938,6 +4938,7 @@ static int img_dd(int argc, char **argv)
+@@ -4943,6 +4943,7 @@ static int img_dd(int argc, char **argv)
BlockDriver *drv = NULL, *proto_drv = NULL;
BlockBackend *blk1 = NULL, *blk2 = NULL;
QemuOpts *opts = NULL;
@@ -57,7 +57,7 @@ index 35c2bdc95c..6e93bbd425 100644
QemuOptsList *create_opts = NULL;
Error *local_err = NULL;
bool image_opts = false;
-@@ -4947,6 +4948,7 @@ static int img_dd(int argc, char **argv)
+@@ -4952,6 +4953,7 @@ static int img_dd(int argc, char **argv)
int64_t size = 0, readsize = 0;
int64_t block_count = 0, out_pos, in_pos;
bool force_share = false, skip_create = false;
@@ -65,7 +65,7 @@ index 35c2bdc95c..6e93bbd425 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4984,7 +4986,7 @@ static int img_dd(int argc, char **argv)
+@@ -4989,7 +4991,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -74,7 +74,7 @@ index 35c2bdc95c..6e93bbd425 100644
if (c == EOF) {
break;
}
-@@ -5007,6 +5009,19 @@ static int img_dd(int argc, char **argv)
+@@ -5012,6 +5014,19 @@ static int img_dd(int argc, char **argv)
case 'n':
skip_create = true;
break;
@@ -94,7 +94,7 @@ index 35c2bdc95c..6e93bbd425 100644
case 'U':
force_share = true;
break;
-@@ -5066,11 +5081,24 @@ static int img_dd(int argc, char **argv)
+@@ -5071,11 +5086,24 @@ static int img_dd(int argc, char **argv)
if (dd.flags & C_IF) {
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
force_share);
@@ -120,7 +120,7 @@ index 35c2bdc95c..6e93bbd425 100644
}
if (dd.flags & C_OSIZE) {
-@@ -5219,6 +5247,7 @@ static int img_dd(int argc, char **argv)
+@@ -5230,6 +5258,7 @@ static int img_dd(int argc, char **argv)
out:
g_free(arg);
qemu_opts_del(opts);
diff --git a/debian/patches/pve/0051-vma-allow-partial-restore.patch b/debian/patches/pve/0052-vma-allow-partial-restore.patch
similarity index 94%
rename from debian/patches/pve/0051-vma-allow-partial-restore.patch
rename to debian/patches/pve/0052-vma-allow-partial-restore.patch
index ede4d67..f1fd7cb 100644
--- a/debian/patches/pve/0051-vma-allow-partial-restore.patch
+++ b/debian/patches/pve/0052-vma-allow-partial-restore.patch
@@ -24,10 +24,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 126 insertions(+), 97 deletions(-)
diff --git a/vma-reader.c b/vma-reader.c
-index 4f4ee2b47b..844d95a5ba 100644
+index e65f1e8415..81a891c6b1 100644
--- a/vma-reader.c
+++ b/vma-reader.c
-@@ -29,6 +29,7 @@ typedef struct VmaRestoreState {
+@@ -28,6 +28,7 @@ typedef struct VmaRestoreState {
bool write_zeroes;
unsigned long *bitmap;
int bitmap_size;
@@ -35,7 +35,7 @@ index 4f4ee2b47b..844d95a5ba 100644
} VmaRestoreState;
struct VmaReader {
-@@ -426,13 +427,14 @@ VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id)
+@@ -425,13 +426,14 @@ VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id)
}
static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
@@ -51,7 +51,7 @@ index 4f4ee2b47b..844d95a5ba 100644
int64_t size = vmar->devinfo[dev_id].size;
-@@ -447,28 +449,30 @@ static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
+@@ -446,28 +448,30 @@ static void allocate_rstate(VmaReader *vmar, guint8 dev_id,
}
int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockBackend *target,
@@ -99,7 +99,7 @@ index 4f4ee2b47b..844d95a5ba 100644
return 0;
}
-@@ -561,19 +565,23 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -560,19 +564,23 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
VmaRestoreState *rstate = &vmar->rstate[dev_id];
BlockBackend *target = NULL;
@@ -129,7 +129,7 @@ index 4f4ee2b47b..844d95a5ba 100644
max_sector = vmar->devinfo[dev_id].size/BDRV_SECTOR_SIZE;
} else {
-@@ -619,7 +627,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -618,7 +626,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
return -1;
}
@@ -138,7 +138,7 @@ index 4f4ee2b47b..844d95a5ba 100644
int nb_sectors = end_sector - sector_num;
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
buf + start, sector_num, nb_sectors,
-@@ -655,7 +663,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -654,7 +662,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
return -1;
}
@@ -147,7 +147,7 @@ index 4f4ee2b47b..844d95a5ba 100644
int nb_sectors = end_sector - sector_num;
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
buf + start, sector_num,
-@@ -680,7 +688,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
+@@ -679,7 +687,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
vmar->partial_zero_cluster_data += zero_size;
}
@@ -156,7 +156,7 @@ index 4f4ee2b47b..844d95a5ba 100644
if (restore_write_data(vmar, dev_id, target, vmstate_fd,
zero_vma_block, sector_num,
nb_sectors, errp) < 0) {
-@@ -851,7 +859,7 @@ int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp)
+@@ -850,7 +858,7 @@ int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp)
for (dev_id = 1; dev_id < 255; dev_id++) {
if (vma_reader_get_device_info(vmar, dev_id)) {
@@ -166,10 +166,10 @@ index 4f4ee2b47b..844d95a5ba 100644
}
diff --git a/vma.c b/vma.c
-index 91612d50a2..e1a750ff50 100644
+index e8dffb43e0..e6e9ffc7fe 100644
--- a/vma.c
+++ b/vma.c
-@@ -139,6 +139,7 @@ typedef struct RestoreMap {
+@@ -138,6 +138,7 @@ typedef struct RestoreMap {
char *throttling_group;
char *cache;
bool write_zero;
@@ -177,7 +177,7 @@ index 91612d50a2..e1a750ff50 100644
} RestoreMap;
static bool try_parse_option(char **line, const char *optname, char **out, const char *inbuf) {
-@@ -246,47 +247,61 @@ static int extract_content(int argc, char **argv)
+@@ -245,47 +246,61 @@ static int extract_content(int argc, char **argv)
char *bps = NULL;
char *group = NULL;
char *cache = NULL;
@@ -265,7 +265,7 @@ index 91612d50a2..e1a750ff50 100644
if (!devname) {
g_error("read map failed - no dev name specified ('%s')",
inbuf);
-@@ -300,6 +315,7 @@ static int extract_content(int argc, char **argv)
+@@ -299,6 +314,7 @@ static int extract_content(int argc, char **argv)
map->throttling_group = group;
map->cache = cache;
map->write_zero = write_zero;
@@ -273,7 +273,7 @@ index 91612d50a2..e1a750ff50 100644
g_hash_table_insert(devmap, map->devname, map);
-@@ -329,6 +345,7 @@ static int extract_content(int argc, char **argv)
+@@ -328,6 +344,7 @@ static int extract_content(int argc, char **argv)
const char *cache = NULL;
int flags = BDRV_O_RDWR;
bool write_zero = true;
@@ -281,7 +281,7 @@ index 91612d50a2..e1a750ff50 100644
BlockBackend *blk = NULL;
-@@ -344,6 +361,7 @@ static int extract_content(int argc, char **argv)
+@@ -343,6 +360,7 @@ static int extract_content(int argc, char **argv)
throttling_group = map->throttling_group;
cache = map->cache;
write_zero = map->write_zero;
@@ -289,7 +289,7 @@ index 91612d50a2..e1a750ff50 100644
} else {
devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
dirname, di->devname);
-@@ -362,57 +380,60 @@ static int extract_content(int argc, char **argv)
+@@ -361,57 +379,60 @@ static int extract_content(int argc, char **argv)
write_zero = false;
}
diff --git a/debian/patches/pve/0052-pbs-namespace-support.patch b/debian/patches/pve/0053-pbs-namespace-support.patch
similarity index 96%
rename from debian/patches/pve/0052-pbs-namespace-support.patch
rename to debian/patches/pve/0053-pbs-namespace-support.patch
index 67bda69..dce468d 100644
--- a/debian/patches/pve/0052-pbs-namespace-support.patch
+++ b/debian/patches/pve/0053-pbs-namespace-support.patch
@@ -112,10 +112,10 @@ index c5eb4d5bad..7471e2ef9d 100644
static const char *const pbs_strong_runtime_opts[] = {
diff --git a/pbs-restore.c b/pbs-restore.c
-index 4d3f925a1b..62042bdd93 100644
+index 2f834cf42e..f03d9bab8d 100644
--- a/pbs-restore.c
+++ b/pbs-restore.c
-@@ -30,7 +30,7 @@
+@@ -29,7 +29,7 @@
static void help(void)
{
const char *help_msg =
@@ -124,7 +124,7 @@ index 4d3f925a1b..62042bdd93 100644
;
printf("%s", help_msg);
-@@ -78,6 +78,7 @@ int main(int argc, char **argv)
+@@ -77,6 +77,7 @@ int main(int argc, char **argv)
Error *main_loop_err = NULL;
const char *format = "raw";
const char *repository = NULL;
@@ -132,7 +132,7 @@ index 4d3f925a1b..62042bdd93 100644
const char *keyfile = NULL;
int verbose = false;
bool skip_zero = false;
-@@ -91,6 +92,7 @@ int main(int argc, char **argv)
+@@ -90,6 +91,7 @@ int main(int argc, char **argv)
{"verbose", no_argument, 0, 'v'},
{"format", required_argument, 0, 'f'},
{"repository", required_argument, 0, 'r'},
@@ -140,7 +140,7 @@ index 4d3f925a1b..62042bdd93 100644
{"keyfile", required_argument, 0, 'k'},
{0, 0, 0, 0}
};
-@@ -111,6 +113,9 @@ int main(int argc, char **argv)
+@@ -110,6 +112,9 @@ int main(int argc, char **argv)
case 'r':
repository = g_strdup(argv[optind - 1]);
break;
@@ -150,7 +150,7 @@ index 4d3f925a1b..62042bdd93 100644
case 'k':
keyfile = g_strdup(argv[optind - 1]);
break;
-@@ -161,8 +166,16 @@ int main(int argc, char **argv)
+@@ -160,8 +165,16 @@ int main(int argc, char **argv)
fprintf(stderr, "connecting to repository '%s'\n", repository);
}
char *pbs_error = NULL;
@@ -202,10 +202,10 @@ index 9f6c04a512..f6a5f8c785 100644
backup_time,
dump_cb_block_size,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 13e03ca154..89875f309c 100644
+index fc8a125451..cc2ead0b75 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -821,6 +821,8 @@
+@@ -817,6 +817,8 @@
#
# @fingerprint: server cert fingerprint (optional for format 'pbs')
#
@@ -214,7 +214,7 @@ index 13e03ca154..89875f309c 100644
# @backup-id: backup ID (required for format 'pbs')
#
# @backup-time: backup timestamp (Unix epoch, required for format 'pbs')
-@@ -840,6 +842,7 @@
+@@ -836,6 +838,7 @@
'*key-password': 'str',
'*master-keyfile': 'str',
'*fingerprint': 'str',
@@ -222,7 +222,7 @@ index 13e03ca154..89875f309c 100644
'*backup-id': 'str',
'*backup-time': 'int',
'*use-dirty-bitmap': 'bool',
-@@ -3256,7 +3259,7 @@
+@@ -3282,7 +3285,7 @@
{ 'struct': 'BlockdevOptionsPbs',
'data': { 'repository': 'str', 'snapshot': 'str', 'archive': 'str',
'*keyfile': 'str', '*password': 'str', '*fingerprint': 'str',
diff --git a/debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch b/debian/patches/pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
similarity index 92%
rename from debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
rename to debian/patches/pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
index 4fd82ac..9827983 100644
--- a/debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
+++ b/debian/patches/pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
@@ -12,10 +12,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 2 insertions(+), 40 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
-index 0cec24c86d..0a9b97aa5e 100644
+index 64a8d7d48b..9fc6dcb957 100644
--- a/block/rbd.c
+++ b/block/rbd.c
-@@ -1324,7 +1324,6 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+@@ -1348,7 +1348,6 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
int status, r;
RBDDiffIterateReq req = { .offs = offset };
uint64_t features, flags;
@@ -23,7 +23,7 @@ index 0cec24c86d..0a9b97aa5e 100644
assert(offset + bytes <= s->image_size);
-@@ -1352,43 +1351,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+@@ -1376,43 +1375,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
return status;
}
@@ -68,7 +68,7 @@ index 0cec24c86d..0a9b97aa5e 100644
qemu_rbd_diff_iterate_cb, &req);
if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
return status;
-@@ -1407,8 +1370,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+@@ -1431,8 +1394,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
}
diff --git a/debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch b/debian/patches/pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
similarity index 90%
rename from debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
rename to debian/patches/pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
index 6624c1d..6972373 100644
--- a/debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
+++ b/debian/patches/pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
@@ -13,10 +13,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
-index 0a9b97aa5e..1c585d23e9 100644
+index 9fc6dcb957..98f4ba2620 100644
--- a/block/rbd.c
+++ b/block/rbd.c
-@@ -1283,11 +1283,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
+@@ -1307,11 +1307,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
RBDDiffIterateReq *req = opaque;
assert(req->offs + req->bytes <= offs);
diff --git a/debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch b/debian/patches/pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
similarity index 97%
rename from debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
rename to debian/patches/pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
index 13e71b7..f7025a3 100644
--- a/debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
+++ b/debian/patches/pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
@@ -23,7 +23,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 112 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
-index 1c585d23e9..1704767041 100644
+index 98f4ba2620..efcbbe5949 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -97,12 +97,6 @@ typedef struct RBDTask {
@@ -39,7 +39,7 @@ index 1c585d23e9..1704767041 100644
static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
BlockdevOptionsRbd *opts, bool cache,
const char *keypairs, const char *secretid,
-@@ -1269,111 +1263,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
+@@ -1293,111 +1287,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
return spec_info;
}
@@ -151,7 +151,7 @@ index 1c585d23e9..1704767041 100644
static int64_t qemu_rbd_getlength(BlockDriverState *bs)
{
BDRVRBDState *s = bs->opaque;
-@@ -1609,7 +1498,6 @@ static BlockDriver bdrv_rbd = {
+@@ -1633,7 +1522,6 @@ static BlockDriver bdrv_rbd = {
#ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
.bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
#endif
diff --git a/debian/patches/pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch b/debian/patches/pve/0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
similarity index 100%
rename from debian/patches/pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
rename to debian/patches/pve/0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
diff --git a/debian/patches/pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch b/debian/patches/pve/0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
similarity index 100%
rename from debian/patches/pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
rename to debian/patches/pve/0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
diff --git a/debian/patches/pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch b/debian/patches/pve/0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
similarity index 100%
rename from debian/patches/pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
rename to debian/patches/pve/0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
diff --git a/debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch b/debian/patches/pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
similarity index 92%
rename from debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
rename to debian/patches/pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
index 3097cf6..ffa8d0e 100644
--- a/debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
+++ b/debian/patches/pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
@@ -25,10 +25,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/vma.c b/vma.c
-index e1a750ff50..b1137e27a7 100644
+index e6e9ffc7fe..304f02bc84 100644
--- a/vma.c
+++ b/vma.c
-@@ -549,7 +549,7 @@ static void coroutine_fn backup_run(void *opaque)
+@@ -548,7 +548,7 @@ static void coroutine_fn backup_run(void *opaque)
struct iovec iov;
QEMUIOVector qiov;
@@ -37,7 +37,7 @@ index e1a750ff50..b1137e27a7 100644
int ret = 0;
unsigned char *buf = blk_blockalign(job->target, VMA_CLUSTER_SIZE);
-@@ -563,8 +563,16 @@ static void coroutine_fn backup_run(void *opaque)
+@@ -562,8 +562,16 @@ static void coroutine_fn backup_run(void *opaque)
iov.iov_len = VMA_CLUSTER_SIZE;
qemu_iovec_init_external(&qiov, &iov, 1);
diff --git a/debian/patches/pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch b/debian/patches/pve/0061-vma-create-avoid-triggering-assertion-in-error-case.patch
similarity index 100%
rename from debian/patches/pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
rename to debian/patches/pve/0061-vma-create-avoid-triggering-assertion-in-error-case.patch
diff --git a/debian/patches/pve/0061-block-alloc-track-avoid-premature-break.patch b/debian/patches/pve/0062-block-alloc-track-avoid-premature-break.patch
similarity index 100%
rename from debian/patches/pve/0061-block-alloc-track-avoid-premature-break.patch
rename to debian/patches/pve/0062-block-alloc-track-avoid-premature-break.patch
diff --git a/debian/patches/pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch b/debian/patches/pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
similarity index 98%
rename from debian/patches/pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch
rename to debian/patches/pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
index 08df987..a20a383 100644
--- a/debian/patches/pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch
+++ b/debian/patches/pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
@@ -109,10 +109,10 @@ index 2e22030eec..e9aa7e0f49 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 89875f309c..43281aca79 100644
+index cc2ead0b75..e3f62faa81 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -833,6 +833,8 @@
+@@ -829,6 +829,8 @@
#
# @encrypt: use encryption ((optional for format 'pbs', defaults to true if there is a keyfile)
#
@@ -121,7 +121,7 @@ index 89875f309c..43281aca79 100644
# Returns: the uuid of the backup job
#
##
-@@ -851,7 +853,9 @@
+@@ -847,7 +849,9 @@
'*format': 'BackupFormat',
'*config-file': 'str',
'*firewall-file': 'str',
@@ -132,7 +132,7 @@ index 89875f309c..43281aca79 100644
'returns': 'UuidInfo', 'coroutine': true }
##
-@@ -906,7 +910,8 @@
+@@ -902,7 +906,8 @@
'pbs-dirty-bitmap-savevm': 'bool',
'pbs-dirty-bitmap-migration': 'bool',
'pbs-masterkey': 'bool',
diff --git a/debian/patches/series b/debian/patches/series
index 8745fcc..b45710f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,24 +1,4 @@
extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
-extra/0002-block-gluster-correctly-set-max_pdiscard.patch
-extra/0003-block-vmdk-Fix-reopening-bs-file.patch
-extra/0004-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
-extra/0005-pci-fix-overflow-in-snprintf-string-formatting.patch
-extra/0006-target-i386-kvm-Fix-disabling-MPX-on-cpu-host-with-M.patch
-extra/0007-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
-extra/0008-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
-extra/0009-coroutine-Rename-qemu_coroutine_inc-dec_pool_size.patch
-extra/0010-coroutine-Revert-to-constant-batch-size.patch
-extra/0011-target-i386-do-not-consult-nonexistent-host-leaves.patch
-extra/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch
-extra/0013-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch
-extra/0014-vhost-Track-descriptor-chain-in-private-at-SVQ.patch
-extra/0015-vhost-Fix-device-s-used-descriptor-dequeue.patch
-extra/0016-vdpa-Fix-bad-index-calculus-at-vhost_vdpa_get_vring_.patch
-extra/0017-vdpa-Fix-index-calculus-at-vhost_vdpa_svqs_start.patch
-extra/0018-hw-virtio-Replace-g_memdup-by-g_memdup2.patch
-extra/0019-vhost-Fix-element-in-vhost_svq_add-failure.patch
-extra/0020-io_uring-fix-short-read-slow-path.patch
-extra/0021-e1000-set-RX-descriptor-status-in-a-separate-operati.patch
bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
@@ -40,50 +20,51 @@ pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
pve/0014-PVE-qapi-modify-query-machines.patch
pve/0015-PVE-qapi-modify-spice-query.patch
-pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
-pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
-pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
-pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
-pve/0020-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
-pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
-pve/0022-PVE-monitor-disable-oob-capability.patch
-pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
-pve/0024-PVE-Allow-version-code-in-machine-type.patch
-pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
-pve/0026-PVE-Backup-add-vma-backup-format-code.patch
-pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
-pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
-pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
-pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
-pve/0031-PVE-various-PBS-fixes.patch
-pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
-pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
-pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
-pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
-pve/0036-PVE-Add-sequential-job-transaction-support.patch
-pve/0037-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
-pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
-pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
-pve/0040-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
-pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
-pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
-pve/0043-PBS-add-master-key-support.patch
-pve/0044-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
-pve/0045-PVE-block-stream-increase-chunk-size.patch
-pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
-pve/0047-block-add-alloc-track-driver.patch
-pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
-pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
-pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
-pve/0051-vma-allow-partial-restore.patch
-pve/0052-pbs-namespace-support.patch
-pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
-pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
-pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
-pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
-pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
-pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
-pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
-pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
-pve/0061-block-alloc-track-avoid-premature-break.patch
-pve/0062-PVE-Backup-allow-passing-max-workers-performance-set.patch
+pve/0016-PVE-add-IOChannel-implementation-for-savevm-async.patch
+pve/0017-PVE-add-savevm-async-for-background-state-snapshots.patch
+pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch
+pve/0019-PVE-block-add-the-zeroinit-block-driver-filter.patch
+pve/0020-PVE-Add-dummy-id-command-line-parameter.patch
+pve/0021-PVE-Config-Revert-target-i386-disable-LINT0-after-re.patch
+pve/0022-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+pve/0023-PVE-monitor-disable-oob-capability.patch
+pve/0024-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
+pve/0025-PVE-Allow-version-code-in-machine-type.patch
+pve/0026-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
+pve/0027-PVE-Backup-add-vma-backup-format-code.patch
+pve/0028-PVE-Backup-add-backup-dump-block-driver.patch
+pve/0029-PVE-Backup-proxmox-backup-patches-for-qemu.patch
+pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
+pve/0031-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
+pve/0032-PVE-various-PBS-fixes.patch
+pve/0033-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+pve/0034-PVE-add-query_proxmox_support-QMP-command.patch
+pve/0035-PVE-add-query-pbs-bitmap-info-QMP-call.patch
+pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
+pve/0037-PVE-Add-sequential-job-transaction-support.patch
+pve/0038-PVE-Backup-Use-a-transaction-to-synchronize-job-stat.patch
+pve/0039-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
+pve/0040-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+pve/0041-migration-block-dirty-bitmap-migrate-other-bitmaps-e.patch
+pve/0042-PVE-fall-back-to-open-iscsi-initiatorname.patch
+pve/0043-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
+pve/0044-PBS-add-master-key-support.patch
+pve/0045-PVE-block-pbs-fast-path-reads-without-allocation-if-.patch
+pve/0046-PVE-block-stream-increase-chunk-size.patch
+pve/0047-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
+pve/0048-block-add-alloc-track-driver.patch
+pve/0049-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
+pve/0050-PVE-savevm-async-register-yank-before-migration_inco.patch
+pve/0051-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
+pve/0052-vma-allow-partial-restore.patch
+pve/0053-pbs-namespace-support.patch
+pve/0054-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
+pve/0055-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
+pve/0056-Revert-block-rbd-implement-bdrv_co_block_status.patch
+pve/0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
+pve/0058-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
+pve/0059-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
+pve/0060-vma-create-support-64KiB-unaligned-input-images.patch
+pve/0061-vma-create-avoid-triggering-assertion-in-error-case.patch
+pve/0062-block-alloc-track-avoid-premature-break.patch
+pve/0063-PVE-Backup-allow-passing-max-workers-performance-set.patch
diff --git a/qemu b/qemu
index 823a3f1..621da77 160000
--- a/qemu
+++ b/qemu
@@ -1 +1 @@
-Subproject commit 823a3f11fb8f04c3c3cc0f95f968fef1bfc6534f
+Subproject commit 621da7789083b80d6f1ff1c0fb499334007b4f51
--
2.30.2
^ permalink raw reply related [relevance 11%]
* [pve-devel] [PATCH qemu 1/4] update submodule and patches to 7.0.0
@ 2022-06-27 11:05 9% ` Fabian Ebner
0 siblings, 0 replies; 23+ results
From: Fabian Ebner @ 2022-06-27 11:05 UTC (permalink / raw)
To: pve-devel
Only very minor changes needed:
* Most patches in extra (or some version of them) are part of 7.0.0.
* aio_set_fd_handler got an extra parameter, but can just pass NULL
like we did for the related 'poll' parameter. See QEMU commit
826cc32423db2a99d184dbf4f507c737d7e7a4ae for more.
* Add include for qemu/memalign.h in vma.c and vma-writer.c.
* Add reverts for fixups of already reverted 0347a8fd4c ("block/rbd:
implement bdrv_co_block_status") that came in with 7.0.0. Those
fixups are not enough, see Proxmox bugzilla #4047.
* Two trivial context changes for bitmap-mirror patches.
* block_int.h got split up into multiple headers.
* Some context changes in configure and meson.build.
* Used the oppurtunity to squash fixup of bdrv_backuo_dump_create typo
in a later patch into the patch introducing the function (had to
move code to new header during rebase).
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
...d-support-for-sync-bitmap-mode-never.patch | 90 ++--
...-support-for-conditional-and-always-.patch | 14 +-
...check-for-bitmap-mode-without-bitmap.patch | 4 +-
...-to-bdrv_dirty_bitmap_merge_internal.patch | 6 +-
.../0006-mirror-move-some-checks-to-qmp.patch | 8 +-
...race-with-clients-disconnecting-earl.patch | 12 +-
...rectly-set-max_pdiscard-which-is-in.patch} | 0
...support-for-flag-argument-with-value.patch | 55 --
...-set-expire_password-and-allow-VNC-d.patch | 477 ------------------
...Update-BSC-only-if-want_zero-is-true.patch | 43 --
...lete-reconnect-delay-timer-when-done.patch | 40 --
...sert-there-are-no-timers-when-closed.patch | 34 --
...-nbd-Move-s-ioc-on-AioContext-change.patch | 90 ----
...U-crash-when-started-with-SLIC-table.patch | 89 ----
...-map-leaking-on-error-during-receive.patch | 38 --
...rrect-calls-of-log_global_start-stop.patch | 86 ----
...acpi-fix-OEM-ID-OEM-Table-ID-padding.patch | 59 ---
...ch-the-virqueue-element-in-case-of-e.patch | 55 --
...t-user-remove-VirtQ-notifier-restore.patch | 98 ----
...host-user-fix-VirtQ-notifier-cleanup.patch | 149 ------
...ondition-for-iommu_platform-not-supp.patch | 101 ----
.../0019-ui-vnc.c-Fixed-a-deadlock-bug.patch | 72 ---
...er-fix-race-condition-in-qxl_cursor-.patch | 37 --
...teger-overflow-in-cursor_alloc-CVE-2.patch | 83 ---
...k-file-change-locking-default-to-off.patch | 6 +-
...he-CPU-model-to-kvm64-32-instead-of-.patch | 4 +-
...ui-spice-default-to-pve-certificates.patch | 2 +-
...lock-rbd-disable-rbd_cache_writethro.patch | 2 +-
.../0007-PVE-Up-qmp-add-get_link_status.patch | 6 +-
...return-success-on-info-without-snaps.patch | 4 +-
...dd-add-osize-and-read-from-to-stdin-.patch | 16 +-
...E-Up-qemu-img-dd-add-isize-parameter.patch | 12 +-
...PVE-Up-qemu-img-dd-add-n-skip_create.patch | 14 +-
...virtio-balloon-improve-query-balloon.patch | 10 +-
.../0014-PVE-qapi-modify-query-machines.patch | 6 +-
.../0015-PVE-qapi-modify-spice-query.patch | 6 +-
...async-for-background-state-snapshots.patch | 30 +-
...add-optional-buffer-size-to-QEMUFile.patch | 28 +-
...add-the-zeroinit-block-driver-filter.patch | 4 +-
...-Add-dummy-id-command-line-parameter.patch | 10 +-
...le-posix-make-locking-optiono-on-cre.patch | 18 +-
...sed-balloon-qemu-4-0-config-size-fal.patch | 4 +-
...E-Allow-version-code-in-machine-type.patch | 18 +-
...e-bcs-bitmap-initialization-to-job-c.patch | 4 +-
...VE-Backup-add-vma-backup-format-code.patch | 32 +-
...-Backup-add-backup-dump-block-driver.patch | 28 +-
...ckup-proxmox-backup-patches-for-qemu.patch | 42 +-
...estore-new-command-to-restore-from-p.patch | 4 +-
...irty-bitmap-tracking-for-incremental.patch | 6 +-
.../pve/0031-PVE-various-PBS-fixes.patch | 4 +-
...k-driver-to-map-backup-archives-into.patch | 54 +-
...dd-query_proxmox_support-QMP-command.patch | 2 +-
...E-add-query-pbs-bitmap-info-QMP-call.patch | 4 +-
...ct-stderr-to-journal-when-daemonized.patch | 8 +-
...d-sequential-job-transaction-support.patch | 10 +-
...-block-on-finishing-and-cleanup-crea.patch | 2 +-
...igrate-dirty-bitmap-state-via-savevm.patch | 8 +-
...all-back-to-open-iscsi-initiatorname.patch | 2 +-
...routine-QMP-for-backup-cancel_backup.patch | 6 +-
.../pve/0043-PBS-add-master-key-support.patch | 4 +-
...PVE-block-stream-increase-chunk-size.patch | 2 +-
...accept-NULL-qiov-in-bdrv_pad_request.patch | 4 +-
.../0047-block-add-alloc-track-driver.patch | 2 +-
...valid-QAPI-names-for-backwards-compa.patch | 6 +-
...-add-l-option-for-loading-a-snapshot.patch | 18 +-
.../pve/0051-vma-allow-partial-restore.patch | 14 +-
.../pve/0052-pbs-namespace-support.patch | 6 +-
...-rbd-workaround-for-ceph-issue-53784.patch | 80 +++
...-fix-handling-of-holes-in-.bdrv_co_b.patch | 35 ++
...-rbd-implement-bdrv_co_block_status.patch} | 6 +-
...-jobs-correctly-cancel-in-error-sce.patch} | 0
...sure-jobs-in-di_list-are-referenced.patch} | 0
...-segfault-issues-upon-backup-cancel.patch} | 0
...upport-64KiB-unaligned-input-images.patch} | 6 +-
...-triggering-assertion-in-error-case.patch} | 4 +-
...k-alloc-track-avoid-premature-break.patch} | 0
debian/patches/series | 35 +-
qemu | 2 +-
78 files changed, 432 insertions(+), 1948 deletions(-)
rename debian/patches/extra/{0018-block-gluster-correctly-set-max_pdiscard-which-is-in.patch => 0002-block-gluster-correctly-set-max_pdiscard-which-is-in.patch} (100%)
delete mode 100644 debian/patches/extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
delete mode 100644 debian/patches/extra/0003-monitor-refactor-set-expire_password-and-allow-VNC-d.patch
delete mode 100644 debian/patches/extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
delete mode 100644 debian/patches/extra/0007-block-nbd-Delete-reconnect-delay-timer-when-done.patch
delete mode 100644 debian/patches/extra/0008-block-nbd-Assert-there-are-no-timers-when-closed.patch
delete mode 100644 debian/patches/extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
delete mode 100644 debian/patches/extra/0010-acpi-fix-QEMU-crash-when-started-with-SLIC-table.patch
delete mode 100644 debian/patches/extra/0011-virtio-net-fix-map-leaking-on-error-during-receive.patch
delete mode 100644 debian/patches/extra/0012-memory-Fix-incorrect-calls-of-log_global_start-stop.patch
delete mode 100644 debian/patches/extra/0013-acpi-fix-OEM-ID-OEM-Table-ID-padding.patch
delete mode 100644 debian/patches/extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
delete mode 100644 debian/patches/extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch
delete mode 100644 debian/patches/extra/0016-vhost-user-fix-VirtQ-notifier-cleanup.patch
delete mode 100644 debian/patches/extra/0017-virtio-fix-the-condition-for-iommu_platform-not-supp.patch
delete mode 100644 debian/patches/extra/0019-ui-vnc.c-Fixed-a-deadlock-bug.patch
delete mode 100644 debian/patches/extra/0020-display-qxl-render-fix-race-condition-in-qxl_cursor-.patch
delete mode 100644 debian/patches/extra/0021-ui-cursor-fix-integer-overflow-in-cursor_alloc-CVE-2.patch
create mode 100644 debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
create mode 100644 debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
rename debian/patches/pve/{0053-Revert-block-rbd-implement-bdrv_co_block_status.patch => 0055-Revert-block-rbd-implement-bdrv_co_block_status.patch} (97%)
rename debian/patches/pve/{0054-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch => 0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch} (100%)
rename debian/patches/pve/{0055-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch => 0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch} (100%)
rename debian/patches/pve/{0056-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch => 0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch} (100%)
rename debian/patches/pve/{0057-vma-create-support-64KiB-unaligned-input-images.patch => 0059-vma-create-support-64KiB-unaligned-input-images.patch} (92%)
rename debian/patches/pve/{0058-vma-create-avoid-triggering-assertion-in-error-case.patch => 0060-vma-create-avoid-triggering-assertion-in-error-case.patch} (88%)
rename debian/patches/pve/{0059-block-alloc-track-avoid-premature-break.patch => 0061-block-alloc-track-avoid-premature-break.patch} (100%)
diff --git a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
index 61ce22a..5301cf0 100644
--- a/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
+++ b/debian/patches/bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
@@ -28,18 +28,18 @@ Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
- block/mirror.c | 98 +++++++++++++++++++++++++-------
- blockdev.c | 39 ++++++++++++-
- include/block/block_int.h | 4 +-
- qapi/block-core.json | 29 ++++++++--
- tests/unit/test-block-iothread.c | 4 +-
+ block/mirror.c | 98 +++++++++++++++++++++-----
+ blockdev.c | 39 +++++++++-
+ include/block/block_int-global-state.h | 4 +-
+ qapi/block-core.json | 29 ++++++--
+ tests/unit/test-block-iothread.c | 4 +-
5 files changed, 145 insertions(+), 29 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index efec2c7674..f7804638f9 100644
+index d8ecb9efa2..d95a7d7940 100644
--- a/block/mirror.c
+++ b/block/mirror.c
-@@ -50,7 +50,7 @@ typedef struct MirrorBlockJob {
+@@ -51,7 +51,7 @@ typedef struct MirrorBlockJob {
BlockDriverState *to_replace;
/* Used to block operations on the drive-mirror-replace target */
Error *replace_blocker;
@@ -48,7 +48,7 @@ index efec2c7674..f7804638f9 100644
BlockMirrorBackingMode backing_mode;
/* Whether the target image requires explicit zero-initialization */
bool zero_target;
-@@ -64,6 +64,8 @@ typedef struct MirrorBlockJob {
+@@ -65,6 +65,8 @@ typedef struct MirrorBlockJob {
size_t buf_size;
int64_t bdev_length;
unsigned long *cow_bitmap;
@@ -57,7 +57,7 @@ index efec2c7674..f7804638f9 100644
BdrvDirtyBitmap *dirty_bitmap;
BdrvDirtyBitmapIter *dbi;
uint8_t *buf;
-@@ -695,7 +697,8 @@ static int mirror_exit_common(Job *job)
+@@ -696,7 +698,8 @@ static int mirror_exit_common(Job *job)
bdrv_child_refresh_perms(mirror_top_bs, mirror_top_bs->backing,
&error_abort);
if (!abort && s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
@@ -67,7 +67,7 @@ index efec2c7674..f7804638f9 100644
BlockDriverState *unfiltered_target = bdrv_skip_filters(target_bs);
if (bdrv_cow_bs(unfiltered_target) != backing) {
-@@ -800,6 +803,16 @@ static void mirror_abort(Job *job)
+@@ -794,6 +797,16 @@ static void mirror_abort(Job *job)
assert(ret == 0);
}
@@ -84,7 +84,7 @@ index efec2c7674..f7804638f9 100644
static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
{
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
-@@ -979,7 +992,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
+@@ -973,7 +986,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
mirror_free_init(s);
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
@@ -94,7 +94,7 @@ index efec2c7674..f7804638f9 100644
ret = mirror_dirty_init(s);
if (ret < 0 || job_is_cancelled(&s->common.job)) {
goto immediate_exit;
-@@ -1221,6 +1235,7 @@ static const BlockJobDriver mirror_job_driver = {
+@@ -1212,6 +1226,7 @@ static const BlockJobDriver mirror_job_driver = {
.run = mirror_run,
.prepare = mirror_prepare,
.abort = mirror_abort,
@@ -102,7 +102,7 @@ index efec2c7674..f7804638f9 100644
.pause = mirror_pause,
.complete = mirror_complete,
.cancel = mirror_cancel,
-@@ -1237,6 +1252,7 @@ static const BlockJobDriver commit_active_job_driver = {
+@@ -1228,6 +1243,7 @@ static const BlockJobDriver commit_active_job_driver = {
.run = mirror_run,
.prepare = mirror_prepare,
.abort = mirror_abort,
@@ -110,7 +110,7 @@ index efec2c7674..f7804638f9 100644
.pause = mirror_pause,
.complete = mirror_complete,
.cancel = commit_active_cancel,
-@@ -1602,7 +1618,10 @@ static BlockJob *mirror_start_job(
+@@ -1593,7 +1609,10 @@ static BlockJob *mirror_start_job(
BlockCompletionFunc *cb,
void *opaque,
const BlockJobDriver *driver,
@@ -122,11 +122,12 @@ index efec2c7674..f7804638f9 100644
bool auto_complete, const char *filter_node_name,
bool is_mirror, MirrorCopyMode copy_mode,
Error **errp)
-@@ -1614,10 +1633,39 @@ static BlockJob *mirror_start_job(
+@@ -1605,10 +1624,39 @@ static BlockJob *mirror_start_job(
uint64_t target_perms, target_shared_perms;
int ret;
- if (granularity == 0) {
+- granularity = bdrv_get_default_bitmap_granularity(target);
+ if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
+ error_setg(errp, "Sync mode '%s' not supported",
+ MirrorSyncMode_str(sync_mode));
@@ -147,8 +148,8 @@ index efec2c7674..f7804638f9 100644
+ "sync mode '%s' is not compatible with bitmaps",
+ MirrorSyncMode_str(sync_mode));
+ return NULL;
-+ }
-+
+ }
+
+ if (bitmap) {
+ if (granularity) {
+ error_setg(errp, "granularity (%d)"
@@ -158,13 +159,12 @@ index efec2c7674..f7804638f9 100644
+ }
+ granularity = bdrv_dirty_bitmap_granularity(bitmap);
+ } else if (granularity == 0) {
- granularity = bdrv_get_default_bitmap_granularity(target);
- }
--
++ granularity = bdrv_get_default_bitmap_granularity(target);
++ }
assert(is_power_of_2(granularity));
if (buf_size < 0) {
-@@ -1755,7 +1803,9 @@ static BlockJob *mirror_start_job(
+@@ -1740,7 +1788,9 @@ static BlockJob *mirror_start_job(
s->replaces = g_strdup(replaces);
s->on_source_error = on_source_error;
s->on_target_error = on_target_error;
@@ -175,7 +175,7 @@ index efec2c7674..f7804638f9 100644
s->backing_mode = backing_mode;
s->zero_target = zero_target;
s->copy_mode = copy_mode;
-@@ -1776,6 +1826,18 @@ static BlockJob *mirror_start_job(
+@@ -1761,6 +1811,18 @@ static BlockJob *mirror_start_job(
bdrv_disable_dirty_bitmap(s->dirty_bitmap);
}
@@ -194,7 +194,7 @@ index efec2c7674..f7804638f9 100644
ret = block_job_add_bdrv(&s->common, "source", bs, 0,
BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE |
BLK_PERM_CONSISTENT_READ,
-@@ -1853,6 +1915,9 @@ fail:
+@@ -1838,6 +1900,9 @@ fail:
if (s->dirty_bitmap) {
bdrv_release_dirty_bitmap(s->dirty_bitmap);
}
@@ -204,7 +204,7 @@ index efec2c7674..f7804638f9 100644
job_early_fail(&s->common.job);
}
-@@ -1870,29 +1935,23 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
+@@ -1855,31 +1920,25 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, const char *replaces,
int creation_flags, int64_t speed,
uint32_t granularity, int64_t buf_size,
@@ -221,6 +221,8 @@ index efec2c7674..f7804638f9 100644
- bool is_none_mode;
BlockDriverState *base;
+ GLOBAL_STATE_CODE();
+
- if ((mode == MIRROR_SYNC_MODE_INCREMENTAL) ||
- (mode == MIRROR_SYNC_MODE_BITMAP)) {
- error_setg(errp, "Sync mode '%s' not supported",
@@ -239,7 +241,7 @@ index efec2c7674..f7804638f9 100644
}
BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
-@@ -1917,7 +1976,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
+@@ -1906,7 +1965,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
job_id, bs, creation_flags, base, NULL, speed, 0, 0,
MIRROR_LEAVE_BACKING_CHAIN, false,
on_error, on_error, true, cb, opaque,
@@ -250,10 +252,10 @@ index efec2c7674..f7804638f9 100644
errp);
if (!job) {
diff --git a/blockdev.c b/blockdev.c
-index b35072644e..9940116fe0 100644
+index e46e831212..fa601838a3 100644
--- a/blockdev.c
+++ b/blockdev.c
-@@ -2956,6 +2956,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -2951,6 +2951,10 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
BlockDriverState *target,
bool has_replaces, const char *replaces,
enum MirrorSyncMode sync,
@@ -264,7 +266,7 @@ index b35072644e..9940116fe0 100644
BlockMirrorBackingMode backing_mode,
bool zero_target,
bool has_speed, int64_t speed,
-@@ -2975,6 +2979,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -2970,6 +2974,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
{
BlockDriverState *unfiltered_bs;
int job_flags = JOB_DEFAULT;
@@ -272,7 +274,7 @@ index b35072644e..9940116fe0 100644
if (!has_speed) {
speed = 0;
-@@ -3029,6 +3034,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3024,6 +3029,29 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
sync = MIRROR_SYNC_MODE_FULL;
}
@@ -302,7 +304,7 @@ index b35072644e..9940116fe0 100644
if (!has_replaces) {
/* We want to mirror from @bs, but keep implicit filters on top */
unfiltered_bs = bdrv_skip_implicit_filters(bs);
-@@ -3075,8 +3103,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3070,8 +3098,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
* and will allow to check whether the node still exist at mirror completion
*/
mirror_start(job_id, bs, target,
@@ -313,7 +315,7 @@ index b35072644e..9940116fe0 100644
on_source_error, on_target_error, unmap, filter_node_name,
copy_mode, errp);
}
-@@ -3221,6 +3249,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
+@@ -3216,6 +3244,8 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs,
arg->has_replaces, arg->replaces, arg->sync,
@@ -322,7 +324,7 @@ index b35072644e..9940116fe0 100644
backing_mode, zero_target,
arg->has_speed, arg->speed,
arg->has_granularity, arg->granularity,
-@@ -3242,6 +3272,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
+@@ -3237,6 +3267,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
const char *device, const char *target,
bool has_replaces, const char *replaces,
MirrorSyncMode sync,
@@ -331,7 +333,7 @@ index b35072644e..9940116fe0 100644
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
-@@ -3291,7 +3323,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
+@@ -3286,7 +3318,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
}
blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs,
@@ -341,11 +343,11 @@ index b35072644e..9940116fe0 100644
zero_target, has_speed, speed,
has_granularity, granularity,
has_buf_size, buf_size,
-diff --git a/include/block/block_int.h b/include/block/block_int.h
-index f4c75e8ba9..ee0aeb1414 100644
---- a/include/block/block_int.h
-+++ b/include/block/block_int.h
-@@ -1287,7 +1287,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
+diff --git a/include/block/block_int-global-state.h b/include/block/block_int-global-state.h
+index 0f21b0570b..e7f901d048 100644
+--- a/include/block/block_int-global-state.h
++++ b/include/block/block_int-global-state.h
+@@ -148,7 +148,9 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, const char *replaces,
int creation_flags, int64_t speed,
uint32_t granularity, int64_t buf_size,
@@ -357,10 +359,10 @@ index f4c75e8ba9..ee0aeb1414 100644
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 1d3dd9cb48..da5dca1e3b 100644
+index beeb91952a..fb25c2b245 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -1995,10 +1995,19 @@
+@@ -1993,10 +1993,19 @@
# (all the disk, only the sectors allocated in the topmost image, or
# only new I/O).
#
@@ -381,7 +383,7 @@ index 1d3dd9cb48..da5dca1e3b 100644
#
# @buf-size: maximum amount of data in flight from source to
# target (since 1.4).
-@@ -2036,7 +2045,9 @@
+@@ -2034,7 +2043,9 @@
{ 'struct': 'DriveMirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*format': 'str', '*node-name': 'str', '*replaces': 'str',
@@ -392,7 +394,7 @@ index 1d3dd9cb48..da5dca1e3b 100644
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
-@@ -2308,10 +2319,19 @@
+@@ -2306,10 +2317,19 @@
# (all the disk, only the sectors allocated in the topmost image, or
# only new I/O).
#
@@ -413,7 +415,7 @@ index 1d3dd9cb48..da5dca1e3b 100644
#
# @buf-size: maximum amount of data in flight from source to
# target
-@@ -2360,7 +2380,8 @@
+@@ -2358,7 +2378,8 @@
{ 'command': 'blockdev-mirror',
'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
'*replaces': 'str',
@@ -424,7 +426,7 @@ index 1d3dd9cb48..da5dca1e3b 100644
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
-index aea660aeed..22b9770a3e 100644
+index 94718c9319..7977ac14f4 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
@@ -626,8 +626,8 @@ static void test_propagate_mirror(void)
diff --git a/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch b/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
index 441198e..d30b46d 100644
--- a/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
+++ b/debian/patches/bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
@@ -24,10 +24,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index f7804638f9..4f5f74e2cf 100644
+index d95a7d7940..2c79ee41af 100644
--- a/block/mirror.c
+++ b/block/mirror.c
-@@ -672,8 +672,6 @@ static int mirror_exit_common(Job *job)
+@@ -673,8 +673,6 @@ static int mirror_exit_common(Job *job)
bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
}
@@ -36,9 +36,9 @@ index f7804638f9..4f5f74e2cf 100644
/* Make sure that the source BDS doesn't go away during bdrv_replace_node,
* before we can call bdrv_drained_end */
bdrv_ref(src);
-@@ -781,6 +779,18 @@ static int mirror_exit_common(Job *job)
- blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
- blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
+@@ -775,6 +773,18 @@ static int mirror_exit_common(Job *job)
+ block_job_remove_all_bdrv(bjob);
+ bdrv_replace_node(mirror_top_bs, mirror_top_bs->backing->bs, &error_abort);
+ if (s->sync_bitmap) {
+ if (s->bitmap_mode == BITMAP_SYNC_MODE_ALWAYS ||
@@ -55,7 +55,7 @@ index f7804638f9..4f5f74e2cf 100644
bs_opaque->job = NULL;
bdrv_drained_end(src);
-@@ -1643,10 +1653,6 @@ static BlockJob *mirror_start_job(
+@@ -1634,10 +1644,6 @@ static BlockJob *mirror_start_job(
" sync mode",
MirrorSyncMode_str(sync_mode));
return NULL;
@@ -66,7 +66,7 @@ index f7804638f9..4f5f74e2cf 100644
}
} else if (bitmap) {
error_setg(errp,
-@@ -1663,6 +1669,12 @@ static BlockJob *mirror_start_job(
+@@ -1654,6 +1660,12 @@ static BlockJob *mirror_start_job(
return NULL;
}
granularity = bdrv_dirty_bitmap_granularity(bitmap);
diff --git a/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch b/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
index de15507..ffd3efe 100644
--- a/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
+++ b/debian/patches/bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 3 insertions(+)
diff --git a/blockdev.c b/blockdev.c
-index 9940116fe0..b113e57d68 100644
+index fa601838a3..93fd0a61a4 100644
--- a/blockdev.c
+++ b/blockdev.c
-@@ -3055,6 +3055,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3050,6 +3050,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
return;
}
diff --git a/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch b/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
index 872496a..c86ceca 100644
--- a/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
+++ b/debian/patches/bitmap-mirror/0004-mirror-switch-to-bdrv_dirty_bitmap_merge_internal.patch
@@ -16,10 +16,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index 4f5f74e2cf..7024f3bbf0 100644
+index 2c79ee41af..e04a3ea6f4 100644
--- a/block/mirror.c
+++ b/block/mirror.c
-@@ -785,8 +785,8 @@ static int mirror_exit_common(Job *job)
+@@ -779,8 +779,8 @@ static int mirror_exit_common(Job *job)
job->ret == 0 && ret == 0)) {
/* Success; synchronize copy back to sync. */
bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL);
@@ -30,7 +30,7 @@ index 4f5f74e2cf..7024f3bbf0 100644
}
}
bdrv_release_dirty_bitmap(s->dirty_bitmap);
-@@ -1843,11 +1843,8 @@ static BlockJob *mirror_start_job(
+@@ -1828,11 +1828,8 @@ static BlockJob *mirror_start_job(
}
if (s->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
diff --git a/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch b/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
index ca9d5ee..4d4747b 100644
--- a/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
+++ b/debian/patches/bitmap-mirror/0006-mirror-move-some-checks-to-qmp.patch
@@ -19,10 +19,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 70 insertions(+), 59 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
-index 7024f3bbf0..6211ff22fc 100644
+index e04a3ea6f4..4feec2a002 100644
--- a/block/mirror.c
+++ b/block/mirror.c
-@@ -1643,31 +1643,13 @@ static BlockJob *mirror_start_job(
+@@ -1634,31 +1634,13 @@ static BlockJob *mirror_start_job(
uint64_t target_perms, target_shared_perms;
int ret;
@@ -60,10 +60,10 @@ index 7024f3bbf0..6211ff22fc 100644
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
diff --git a/blockdev.c b/blockdev.c
-index b113e57d68..4be0863050 100644
+index 93fd0a61a4..1af5a1fcb2 100644
--- a/blockdev.c
+++ b/blockdev.c
-@@ -3034,7 +3034,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
+@@ -3029,7 +3029,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
sync = MIRROR_SYNC_MODE_FULL;
}
diff --git a/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch b/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
index 1836dff..9d8322c 100644
--- a/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
+++ b/debian/patches/extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
@@ -48,7 +48,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
-index 12d395d62d..b182943324 100644
+index cc4cc6c6ad..82f649d9ab 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts;
@@ -60,10 +60,10 @@ index 12d395d62d..b182943324 100644
void monitor_init_globals(void);
void monitor_init_globals_core(void);
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
-index 3da3f86c6a..9953e0cd2d 100644
+index caa2e90ef2..e1596f79ab 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
-@@ -151,6 +151,13 @@ typedef struct {
+@@ -152,6 +152,13 @@ typedef struct {
QemuMutex qmp_queue_lock;
/* Input queue that holds all the parsed QMP requests */
GQueue *qmp_requests;
@@ -144,10 +144,10 @@ index 092c527b6f..6b8cfcf6d8 100644
monitor_qmp_caps_reset(mon);
data = qmp_greeting(mon);
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
-index d378bccac7..fb8936e7cd 100644
+index 0990873ec8..e605003771 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
-@@ -118,16 +118,28 @@ typedef struct QmpDispatchBH {
+@@ -117,16 +117,28 @@ typedef struct QmpDispatchBH {
QObject **ret;
Error **errp;
Coroutine *co;
@@ -180,7 +180,7 @@ index d378bccac7..fb8936e7cd 100644
aio_co_wake(data->co);
}
-@@ -232,6 +244,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
+@@ -231,6 +243,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
.ret = &ret,
.errp = &err,
.co = qemu_coroutine_self(),
diff --git a/debian/patches/extra/0018-block-gluster-correctly-set-max_pdiscard-which-is-in.patch b/debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard-which-is-in.patch
similarity index 100%
rename from debian/patches/extra/0018-block-gluster-correctly-set-max_pdiscard-which-is-in.patch
rename to debian/patches/extra/0002-block-gluster-correctly-set-max_pdiscard-which-is-in.patch
diff --git a/debian/patches/extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch b/debian/patches/extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
deleted file mode 100644
index 4606c6a..0000000
--- a/debian/patches/extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Reiter <s.reiter@proxmox.com>
-Date: Wed, 1 Sep 2021 16:51:04 +0200
-Subject: [PATCH] monitor/hmp: add support for flag argument with value
-
-Adds support for the "-xS" parameter type, where "-x" denotes a flag
-name and the "S" suffix indicates that this flag is supposed to take an
-arbitrary string parameter.
-
-These parameters are always optional, the entry in the qdict will be
-omitted if the flag is not given.
-
-Reviewed-by: Eric Blake <eblake@redhat.com>
-Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- monitor/hmp.c | 17 ++++++++++++++++-
- 1 file changed, 16 insertions(+), 1 deletion(-)
-
-diff --git a/monitor/hmp.c b/monitor/hmp.c
-index b20737e63c..b29dbb1833 100644
---- a/monitor/hmp.c
-+++ b/monitor/hmp.c
-@@ -981,6 +981,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
- {
- const char *tmp = p;
- int skip_key = 0;
-+ int ret;
- /* option */
-
- c = *typestr++;
-@@ -1003,8 +1004,22 @@ static QDict *monitor_parse_arguments(Monitor *mon,
- }
- if (skip_key) {
- p = tmp;
-+ } else if (*typestr == 'S') {
-+ /* has option with string value */
-+ typestr++;
-+ tmp = p++;
-+ while (qemu_isspace(*p)) {
-+ p++;
-+ }
-+ ret = get_str(buf, sizeof(buf), &p);
-+ if (ret < 0) {
-+ monitor_printf(mon, "%s: value expected for -%c\n",
-+ cmd->name, *tmp);
-+ goto fail;
-+ }
-+ qdict_put_str(qdict, key, buf);
- } else {
-- /* has option */
-+ /* has boolean option */
- p++;
- qdict_put_bool(qdict, key, true);
- }
diff --git a/debian/patches/extra/0003-monitor-refactor-set-expire_password-and-allow-VNC-d.patch b/debian/patches/extra/0003-monitor-refactor-set-expire_password-and-allow-VNC-d.patch
deleted file mode 100644
index 6ea0549..0000000
--- a/debian/patches/extra/0003-monitor-refactor-set-expire_password-and-allow-VNC-d.patch
+++ /dev/null
@@ -1,477 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefan Reiter <s.reiter@proxmox.com>
-Date: Wed, 25 Aug 2021 11:14:13 +0200
-Subject: [PATCH] monitor: refactor set/expire_password and allow VNC display
- id
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-It is possible to specify more than one VNC server on the command line,
-either with an explicit ID or the auto-generated ones à la "default",
-"vnc2", "vnc3", ...
-
-It is not possible to change the password on one of these extra VNC
-displays though. Fix this by adding a "display" parameter to the
-"set_password" and "expire_password" QMP and HMP commands.
-
-For HMP, the display is specified using the "-d" value flag.
-
-For QMP, the schema is updated to explicitly express the supported
-variants of the commands with protocol-discriminated unions.
-
-Suggested-by: Eric Blake <eblake@redhat.com>
-Suggested-by: Markus Armbruster <armbru@redhat.com>
-Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- hmp-commands.hx | 24 ++++---
- monitor/hmp-cmds.c | 57 +++++++++++++++-
- monitor/qmp-cmds.c | 62 ++++++-----------
- qapi/ui.json | 165 ++++++++++++++++++++++++++++++++++++++-------
- 4 files changed, 231 insertions(+), 77 deletions(-)
-
-diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 70a9136ac2..5efb47fc32 100644
---- a/hmp-commands.hx
-+++ b/hmp-commands.hx
-@@ -1514,33 +1514,35 @@ ERST
-
- {
- .name = "set_password",
-- .args_type = "protocol:s,password:s,connected:s?",
-- .params = "protocol password action-if-connected",
-+ .args_type = "protocol:s,password:s,display:-dS,connected:s?",
-+ .params = "protocol password [-d display] [action-if-connected]",
- .help = "set spice/vnc password",
- .cmd = hmp_set_password,
- },
-
- SRST
--``set_password [ vnc | spice ] password [ action-if-connected ]``
-- Change spice/vnc password. *action-if-connected* specifies what
-- should happen in case a connection is established: *fail* makes the
-- password change fail. *disconnect* changes the password and
-+``set_password [ vnc | spice ] password [ -d display ] [ action-if-connected ]``
-+ Change spice/vnc password. *display* can be used with 'vnc' to specify
-+ which display to set the password on. *action-if-connected* specifies
-+ what should happen in case a connection is established: *fail* makes
-+ the password change fail. *disconnect* changes the password and
- disconnects the client. *keep* changes the password and keeps the
- connection up. *keep* is the default.
- ERST
-
- {
- .name = "expire_password",
-- .args_type = "protocol:s,time:s",
-- .params = "protocol time",
-+ .args_type = "protocol:s,time:s,display:-dS",
-+ .params = "protocol time [-d display]",
- .help = "set spice/vnc password expire-time",
- .cmd = hmp_expire_password,
- },
-
- SRST
--``expire_password [ vnc | spice ]`` *expire-time*
-- Specify when a password for spice/vnc becomes
-- invalid. *expire-time* accepts:
-+``expire_password [ vnc | spice ] expire-time [ -d display ]``
-+ Specify when a password for spice/vnc becomes invalid.
-+ *display* behaves the same as in ``set_password``.
-+ *expire-time* accepts:
-
- ``now``
- Invalidate password instantly.
-diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 9c91bf93e9..2e91ccb738 100644
---- a/monitor/hmp-cmds.c
-+++ b/monitor/hmp-cmds.c
-@@ -1384,10 +1384,41 @@ void hmp_set_password(Monitor *mon, const QDict *qdict)
- {
- const char *protocol = qdict_get_str(qdict, "protocol");
- const char *password = qdict_get_str(qdict, "password");
-+ const char *display = qdict_get_try_str(qdict, "display");
- const char *connected = qdict_get_try_str(qdict, "connected");
- Error *err = NULL;
-+ DisplayProtocol proto;
-
-- qmp_set_password(protocol, password, !!connected, connected, &err);
-+ SetPasswordOptions opts = {
-+ .password = g_strdup(password),
-+ .u.vnc.display = NULL,
-+ };
-+
-+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
-+ DISPLAY_PROTOCOL_VNC, &err);
-+ if (err) {
-+ hmp_handle_error(mon, err);
-+ return;
-+ }
-+ opts.protocol = proto;
-+
-+ if (proto == DISPLAY_PROTOCOL_VNC) {
-+ opts.u.vnc.has_display = !!display;
-+ opts.u.vnc.display = g_strdup(display);
-+ } else if (proto == DISPLAY_PROTOCOL_SPICE) {
-+ opts.u.spice.has_connected = !!connected;
-+ opts.u.spice.connected =
-+ qapi_enum_parse(&SetPasswordAction_lookup, connected,
-+ SET_PASSWORD_ACTION_KEEP, &err);
-+ if (err) {
-+ hmp_handle_error(mon, err);
-+ return;
-+ }
-+ }
-+
-+ qmp_set_password(&opts, &err);
-+ g_free(opts.password);
-+ g_free(opts.u.vnc.display);
- hmp_handle_error(mon, err);
- }
-
-@@ -1395,9 +1426,31 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
- {
- const char *protocol = qdict_get_str(qdict, "protocol");
- const char *whenstr = qdict_get_str(qdict, "time");
-+ const char *display = qdict_get_try_str(qdict, "display");
- Error *err = NULL;
-+ DisplayProtocol proto;
-
-- qmp_expire_password(protocol, whenstr, &err);
-+ ExpirePasswordOptions opts = {
-+ .time = g_strdup(whenstr),
-+ .u.vnc.display = NULL,
-+ };
-+
-+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
-+ DISPLAY_PROTOCOL_VNC, &err);
-+ if (err) {
-+ hmp_handle_error(mon, err);
-+ return;
-+ }
-+ opts.protocol = proto;
-+
-+ if (proto == DISPLAY_PROTOCOL_VNC) {
-+ opts.u.vnc.has_display = !!display;
-+ opts.u.vnc.display = g_strdup(display);
-+ }
-+
-+ qmp_expire_password(&opts, &err);
-+ g_free(opts.time);
-+ g_free(opts.u.vnc.display);
- hmp_handle_error(mon, err);
- }
-
-diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
-index 343353e27a..729ca7cceb 100644
---- a/monitor/qmp-cmds.c
-+++ b/monitor/qmp-cmds.c
-@@ -167,45 +167,30 @@ void qmp_system_wakeup(Error **errp)
- qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp);
- }
-
--void qmp_set_password(const char *protocol, const char *password,
-- bool has_connected, const char *connected, Error **errp)
-+void qmp_set_password(SetPasswordOptions *opts, Error **errp)
- {
-- int disconnect_if_connected = 0;
-- int fail_if_connected = 0;
-- int rc;
-+ bool disconnect_if_connected = false;
-+ bool fail_if_connected = false;
-+ int rc = 0;
-
-- if (has_connected) {
-- if (strcmp(connected, "fail") == 0) {
-- fail_if_connected = 1;
-- } else if (strcmp(connected, "disconnect") == 0) {
-- disconnect_if_connected = 1;
-- } else if (strcmp(connected, "keep") == 0) {
-- /* nothing */
-- } else {
-- error_setg(errp, QERR_INVALID_PARAMETER, "connected");
-- return;
-- }
-- }
--
-- if (strcmp(protocol, "spice") == 0) {
-+ if (opts->protocol == DISPLAY_PROTOCOL_SPICE) {
- if (!qemu_using_spice(errp)) {
- return;
- }
-- rc = qemu_spice.set_passwd(password, fail_if_connected,
-+ if (opts->u.spice.has_connected) {
-+ fail_if_connected =
-+ opts->u.spice.connected == SET_PASSWORD_ACTION_FAIL;
-+ disconnect_if_connected =
-+ opts->u.spice.connected == SET_PASSWORD_ACTION_DISCONNECT;
-+ }
-+ rc = qemu_spice.set_passwd(opts->password, fail_if_connected,
- disconnect_if_connected);
-- } else if (strcmp(protocol, "vnc") == 0) {
-- if (fail_if_connected || disconnect_if_connected) {
-- /* vnc supports "connected=keep" only */
-- error_setg(errp, QERR_INVALID_PARAMETER, "connected");
-- return;
-- }
-+ } else if (opts->protocol == DISPLAY_PROTOCOL_VNC) {
- /* Note that setting an empty password will not disable login through
- * this interface. */
-- rc = vnc_display_password(NULL, password);
-- } else {
-- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
-- "'vnc' or 'spice'");
-- return;
-+ rc = vnc_display_password(
-+ opts->u.vnc.has_display ? opts->u.vnc.display : NULL,
-+ opts->password);
- }
-
- if (rc != 0) {
-@@ -213,11 +198,11 @@ void qmp_set_password(const char *protocol, const char *password,
- }
- }
-
--void qmp_expire_password(const char *protocol, const char *whenstr,
-- Error **errp)
-+void qmp_expire_password(ExpirePasswordOptions *opts, Error **errp)
- {
- time_t when;
- int rc;
-+ const char* whenstr = opts->time;
-
- if (strcmp(whenstr, "now") == 0) {
- when = 0;
-@@ -229,17 +214,14 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
- when = strtoull(whenstr, NULL, 10);
- }
-
-- if (strcmp(protocol, "spice") == 0) {
-+ if (opts->protocol == DISPLAY_PROTOCOL_SPICE) {
- if (!qemu_using_spice(errp)) {
- return;
- }
- rc = qemu_spice.set_pw_expire(when);
-- } else if (strcmp(protocol, "vnc") == 0) {
-- rc = vnc_display_pw_expire(NULL, when);
-- } else {
-- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
-- "'vnc' or 'spice'");
-- return;
-+ } else if (opts->protocol == DISPLAY_PROTOCOL_VNC) {
-+ rc = vnc_display_pw_expire(
-+ opts->u.vnc.has_display ? opts->u.vnc.display : NULL, when);
- }
-
- if (rc != 0) {
-diff --git a/qapi/ui.json b/qapi/ui.json
-index d7567ac866..4244c62c30 100644
---- a/qapi/ui.json
-+++ b/qapi/ui.json
-@@ -9,22 +9,23 @@
- { 'include': 'common.json' }
- { 'include': 'sockets.json' }
-
-+##
-+# @DisplayProtocol:
-+#
-+# Display protocols which support changing password options.
-+#
-+# Since: 6.2
-+#
-+##
-+{ 'enum': 'DisplayProtocol',
-+ 'data': [ { 'name': 'vnc', 'if': 'CONFIG_VNC' },
-+ { 'name': 'spice', 'if': 'CONFIG_SPICE' } ] }
-+
- ##
- # @set_password:
- #
- # Sets the password of a remote display session.
- #
--# @protocol: - 'vnc' to modify the VNC server password
--# - 'spice' to modify the Spice server password
--#
--# @password: the new password
--#
--# @connected: how to handle existing clients when changing the
--# password. If nothing is specified, defaults to 'keep'
--# 'fail' to fail the command if clients are connected
--# 'disconnect' to disconnect existing clients
--# 'keep' to maintain existing clients
--#
- # Returns: - Nothing on success
- # - If Spice is not enabled, DeviceNotFound
- #
-@@ -37,16 +38,123 @@
- # <- { "return": {} }
- #
- ##
--{ 'command': 'set_password',
-- 'data': {'protocol': 'str', 'password': 'str', '*connected': 'str'} }
-+{ 'command': 'set_password', 'boxed': true, 'data': 'SetPasswordOptions' }
-+
-+##
-+# @SetPasswordOptions:
-+#
-+# Data required to set a new password on a display server protocol.
-+#
-+# @protocol: - 'vnc' to modify the VNC server password
-+# - 'spice' to modify the Spice server password
-+#
-+# @password: the new password
-+#
-+# Since: 6.2
-+#
-+##
-+{ 'union': 'SetPasswordOptions',
-+ 'base': { 'protocol': 'DisplayProtocol',
-+ 'password': 'str' },
-+ 'discriminator': 'protocol',
-+ 'data': { 'vnc': 'SetPasswordOptionsVnc',
-+ 'spice': 'SetPasswordOptionsSpice' } }
-+
-+##
-+# @SetPasswordAction:
-+#
-+# An action to take on changing a password on a connection with active clients.
-+#
-+# @fail: fail the command if clients are connected
-+#
-+# @disconnect: disconnect existing clients
-+#
-+# @keep: maintain existing clients
-+#
-+# Since: 6.2
-+#
-+##
-+{ 'enum': 'SetPasswordAction',
-+ 'data': [ 'fail', 'disconnect', 'keep' ] }
-+
-+##
-+# @SetPasswordActionVnc:
-+#
-+# See @SetPasswordAction. VNC only supports the keep action. 'connection'
-+# should just be omitted for VNC, this is kept for backwards compatibility.
-+#
-+# @keep: maintain existing clients
-+#
-+# Since: 6.2
-+#
-+##
-+{ 'enum': 'SetPasswordActionVnc',
-+ 'data': [ 'keep' ] }
-+
-+##
-+# @SetPasswordOptionsSpice:
-+#
-+# Options for set_password specific to the VNC procotol.
-+#
-+# @connected: How to handle existing clients when changing the
-+# password. If nothing is specified, defaults to 'keep'.
-+#
-+# Since: 6.2
-+#
-+##
-+{ 'struct': 'SetPasswordOptionsSpice',
-+ 'data': { '*connected': 'SetPasswordAction' } }
-+
-+##
-+# @SetPasswordOptionsVnc:
-+#
-+# Options for set_password specific to the VNC procotol.
-+#
-+# @display: The id of the display where the password should be changed.
-+# Defaults to the first.
-+#
-+# @connected: How to handle existing clients when changing the
-+# password.
-+#
-+# Features:
-+# @deprecated: For VNC, @connected will always be 'keep', parameter should be
-+# omitted.
-+#
-+# Since: 6.2
-+#
-+##
-+{ 'struct': 'SetPasswordOptionsVnc',
-+ 'data': { '*display': 'str',
-+ '*connected': { 'type': 'SetPasswordActionVnc',
-+ 'features': ['deprecated'] } } }
-
- ##
- # @expire_password:
- #
- # Expire the password of a remote display server.
- #
--# @protocol: the name of the remote display protocol 'vnc' or 'spice'
-+# Returns: - Nothing on success
-+# - If @protocol is 'spice' and Spice is not active, DeviceNotFound
- #
-+# Since: 0.14
-+#
-+# Example:
-+#
-+# -> { "execute": "expire_password", "arguments": { "protocol": "vnc",
-+# "time": "+60" } }
-+# <- { "return": {} }
-+#
-+##
-+{ 'command': 'expire_password', 'boxed': true, 'data': 'ExpirePasswordOptions' }
-+
-+##
-+# @ExpirePasswordOptions:
-+#
-+# Data required to set password expiration on a display server protocol.
-+#
-+# @protocol: - 'vnc' to modify the VNC server expiration
-+# - 'spice' to modify the Spice server expiration
-+
- # @time: when to expire the password.
- #
- # - 'now' to expire the password immediately
-@@ -54,24 +162,33 @@
- # - '+INT' where INT is the number of seconds from now (integer)
- # - 'INT' where INT is the absolute time in seconds
- #
--# Returns: - Nothing on success
--# - If @protocol is 'spice' and Spice is not active, DeviceNotFound
--#
--# Since: 0.14
--#
- # Notes: Time is relative to the server and currently there is no way to
- # coordinate server time with client time. It is not recommended to
- # use the absolute time version of the @time parameter unless you're
- # sure you are on the same machine as the QEMU instance.
- #
--# Example:
-+# Since: 6.2
- #
--# -> { "execute": "expire_password", "arguments": { "protocol": "vnc",
--# "time": "+60" } }
--# <- { "return": {} }
-+##
-+{ 'union': 'ExpirePasswordOptions',
-+ 'base': { 'protocol': 'DisplayProtocol',
-+ 'time': 'str' },
-+ 'discriminator': 'protocol',
-+ 'data': { 'vnc': 'ExpirePasswordOptionsVnc' } }
-+
-+##
-+# @ExpirePasswordOptionsVnc:
-+#
-+# Options for expire_password specific to the VNC procotol.
-+#
-+# @display: The id of the display where the expiration should be changed.
-+# Defaults to the first.
-+#
-+# Since: 6.2
- #
- ##
--{ 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'} }
-+{ 'struct': 'ExpirePasswordOptionsVnc',
-+ 'data': { '*display': 'str' } }
-
- ##
- # @screendump:
diff --git a/debian/patches/extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch b/debian/patches/extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
deleted file mode 100644
index 99abfc3..0000000
--- a/debian/patches/extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Hanna Reitz <hreitz@redhat.com>
-Date: Tue, 18 Jan 2022 17:59:59 +0100
-Subject: [PATCH] block/io: Update BSC only if want_zero is true
-
-We update the block-status cache whenever we get new information from a
-bdrv_co_block_status() call to the block driver. However, if we have
-passed want_zero=false to that call, it may flag areas containing zeroes
-as data, and so we would update the block-status cache with wrong
-information.
-
-Therefore, we should not update the cache with want_zero=false.
-
-Reported-by: Nir Soffer <nsoffer@redhat.com>
-Fixes: 0bc329fbb00 ("block: block-status cache for data regions")
-Reviewed-by: Nir Soffer <nsoffer@redhat.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Hanna Reitz <hreitz@redhat.com>
-Message-Id: <20220118170000.49423-2-hreitz@redhat.com>
-Reviewed-by: Eric Blake <eblake@redhat.com>
-Signed-off-by: Eric Blake <eblake@redhat.com>
----
- block/io.c | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/block/io.c b/block/io.c
-index bb0a254def..4e4cb556c5 100644
---- a/block/io.c
-+++ b/block/io.c
-@@ -2497,8 +2497,12 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
- * non-protocol nodes, and then it is never used. However, filling
- * the cache requires an RCU update, so double check here to avoid
- * such an update if possible.
-+ *
-+ * Check want_zero, because we only want to update the cache when we
-+ * have accurate information about what is zero and what is data.
- */
-- if (ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
-+ if (want_zero &&
-+ ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
- QLIST_EMPTY(&bs->children))
- {
- /*
diff --git a/debian/patches/extra/0007-block-nbd-Delete-reconnect-delay-timer-when-done.patch b/debian/patches/extra/0007-block-nbd-Delete-reconnect-delay-timer-when-done.patch
deleted file mode 100644
index ade6a06..0000000
--- a/debian/patches/extra/0007-block-nbd-Delete-reconnect-delay-timer-when-done.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Hanna Reitz <hreitz@redhat.com>
-Date: Wed, 9 Feb 2022 15:02:52 +0100
-Subject: [PATCH] block/nbd: Delete reconnect delay timer when done
-
-We start the reconnect delay timer to cancel the reconnection attempt
-after a while. Once nbd_co_do_establish_connection() has returned, this
-attempt is over, and we no longer need the timer.
-
-Delete it before returning from nbd_reconnect_attempt(), so that it does
-not persist beyond the I/O request that was paused for reconnecting; we
-do not want it to fire in a drained section, because all sort of things
-can happen in such a section (e.g. the AioContext might be changed, and
-we do not want the timer to fire in the wrong context; or the BDS might
-even be deleted, and so the timer CB would access already-freed data).
-
-Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
-Signed-off-by: Hanna Reitz <hreitz@redhat.com>
----
- block/nbd.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/block/nbd.c b/block/nbd.c
-index 5ef462db1b..b8e5a9b4cc 100644
---- a/block/nbd.c
-+++ b/block/nbd.c
-@@ -353,6 +353,13 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
- }
-
- nbd_co_do_establish_connection(s->bs, NULL);
-+
-+ /*
-+ * The reconnect attempt is done (maybe successfully, maybe not), so
-+ * we no longer need this timer. Delete it so it will not outlive
-+ * this I/O request (so draining removes all timers).
-+ */
-+ reconnect_delay_timer_del(s);
- }
-
- static coroutine_fn int nbd_receive_replies(BDRVNBDState *s, uint64_t handle)
diff --git a/debian/patches/extra/0008-block-nbd-Assert-there-are-no-timers-when-closed.patch b/debian/patches/extra/0008-block-nbd-Assert-there-are-no-timers-when-closed.patch
deleted file mode 100644
index 07550c3..0000000
--- a/debian/patches/extra/0008-block-nbd-Assert-there-are-no-timers-when-closed.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Hanna Reitz <hreitz@redhat.com>
-Date: Wed, 9 Feb 2022 15:02:54 +0100
-Subject: [PATCH] block/nbd: Assert there are no timers when closed
-
-Our two timers must not remain armed beyond nbd_clear_bdrvstate(), or
-they will access freed data when they fire.
-
-This patch is separate from the patches that actually fix the issue
-(HEAD^^ and HEAD^) so that you can run the associated regression iotest
-(281) on a configuration that reproducibly exposes the bug.
-
-Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
-Signed-off-by: Hanna Reitz <hreitz@redhat.com>
-[FE: backport (open_timer doesn't exist yet in 6.2.0)]
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/nbd.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/block/nbd.c b/block/nbd.c
-index b8e5a9b4cc..aab20125d8 100644
---- a/block/nbd.c
-+++ b/block/nbd.c
-@@ -108,6 +108,9 @@ static void nbd_clear_bdrvstate(BlockDriverState *bs)
-
- yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name));
-
-+ /* Must not leave timers behind that would access freed data */
-+ assert(!s->reconnect_delay_timer);
-+
- object_unref(OBJECT(s->tlscreds));
- qapi_free_SocketAddress(s->saddr);
- s->saddr = NULL;
diff --git a/debian/patches/extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch b/debian/patches/extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
deleted file mode 100644
index 6b431c6..0000000
--- a/debian/patches/extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Hanna Reitz <hreitz@redhat.com>
-Date: Wed, 9 Feb 2022 15:02:57 +0100
-Subject: [PATCH] block/nbd: Move s->ioc on AioContext change
-
-s->ioc must always be attached to the NBD node's AioContext. If that
-context changes, s->ioc must be attached to the new context.
-
-Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2033626
-Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
-Signed-off-by: Hanna Reitz <hreitz@redhat.com>
-[FE: backport (open_timer doesn't exist yet in 6.2.0)]
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
----
- block/nbd.c | 41 +++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 41 insertions(+)
-
-diff --git a/block/nbd.c b/block/nbd.c
-index aab20125d8..a3896c7f5f 100644
---- a/block/nbd.c
-+++ b/block/nbd.c
-@@ -2003,6 +2003,38 @@ static void nbd_cancel_in_flight(BlockDriverState *bs)
- nbd_co_establish_connection_cancel(s->conn);
- }
-
-+static void nbd_attach_aio_context(BlockDriverState *bs,
-+ AioContext *new_context)
-+{
-+ BDRVNBDState *s = bs->opaque;
-+
-+ /*
-+ * The reconnect_delay_timer is scheduled in I/O paths when the
-+ * connection is lost, to cancel the reconnection attempt after a
-+ * given time. Once this attempt is done (successfully or not),
-+ * nbd_reconnect_attempt() ensures the timer is deleted before the
-+ * respective I/O request is resumed.
-+ * Since the AioContext can only be changed when a node is drained,
-+ * the reconnect_delay_timer cannot be active here.
-+ */
-+ assert(!s->reconnect_delay_timer);
-+
-+ if (s->ioc) {
-+ qio_channel_attach_aio_context(s->ioc, new_context);
-+ }
-+}
-+
-+static void nbd_detach_aio_context(BlockDriverState *bs)
-+{
-+ BDRVNBDState *s = bs->opaque;
-+
-+ assert(!s->reconnect_delay_timer);
-+
-+ if (s->ioc) {
-+ qio_channel_detach_aio_context(s->ioc);
-+ }
-+}
-+
- static BlockDriver bdrv_nbd = {
- .format_name = "nbd",
- .protocol_name = "nbd",
-@@ -2026,6 +2058,9 @@ static BlockDriver bdrv_nbd = {
- .bdrv_dirname = nbd_dirname,
- .strong_runtime_opts = nbd_strong_runtime_opts,
- .bdrv_cancel_in_flight = nbd_cancel_in_flight,
-+
-+ .bdrv_attach_aio_context = nbd_attach_aio_context,
-+ .bdrv_detach_aio_context = nbd_detach_aio_context,
- };
-
- static BlockDriver bdrv_nbd_tcp = {
-@@ -2051,6 +2086,9 @@ static BlockDriver bdrv_nbd_tcp = {
- .bdrv_dirname = nbd_dirname,
- .strong_runtime_opts = nbd_strong_runtime_opts,
- .bdrv_cancel_in_flight = nbd_cancel_in_flight,
-+
-+ .bdrv_attach_aio_context = nbd_attach_aio_context,
-+ .bdrv_detach_aio_context = nbd_detach_aio_context,
- };
-
- static BlockDriver bdrv_nbd_unix = {
-@@ -2076,6 +2114,9 @@ static BlockDriver bdrv_nbd_unix = {
- .bdrv_dirname = nbd_dirname,
- .strong_runtime_opts = nbd_strong_runtime_opts,
- .bdrv_cancel_in_flight = nbd_cancel_in_flight,
-+
-+ .bdrv_attach_aio_context = nbd_attach_aio_context,
-+ .bdrv_detach_aio_context = nbd_detach_aio_context,
- };
-
- static void bdrv_nbd_init(void)
diff --git a/debian/patches/extra/0010-acpi-fix-QEMU-crash-when-started-with-SLIC-table.patch b/debian/patches/extra/0010-acpi-fix-QEMU-crash-when-started-with-SLIC-table.patch
deleted file mode 100644
index bb8cf86..0000000
--- a/debian/patches/extra/0010-acpi-fix-QEMU-crash-when-started-with-SLIC-table.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Igor Mammedov <imammedo@redhat.com>
-Date: Mon, 27 Dec 2021 14:31:17 -0500
-Subject: [PATCH] acpi: fix QEMU crash when started with SLIC table
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-if QEMU is started with used provided SLIC table blob,
-
- -acpitable sig=SLIC,oem_id='CRASH ',oem_table_id="ME",oem_rev=00002210,asl_compiler_id="",asl_compiler_rev=00000000,data=/dev/null
-it will assert with:
-
- hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= maxlen)
-
-and following backtrace:
-
- ...
- build_append_padded_str (array=0x555556afe320, str=0x555556afdb2e "CRASH ME", maxlen=0x6, pad=0x20) at hw/acpi/aml-build.c:61
- acpi_table_begin (desc=0x7fffffffd1b0, array=0x555556afe320) at hw/acpi/aml-build.c:1727
- build_fadt (tbl=0x555556afe320, linker=0x555557ca3830, f=0x7fffffffd318, oem_id=0x555556afdb2e "CRASH ME", oem_table_id=0x555556afdb34 "ME") at hw/acpi/aml-build.c:2064
- ...
-
-which happens due to acpi_table_begin() expecting NULL terminated
-oem_id and oem_table_id strings, which is normally the case, but
-in case of user provided SLIC table, oem_id points to table's blob
-directly and as result oem_id became longer than expected.
-
-Fix issue by handling oem_id consistently and make acpi_get_slic_oem()
-return NULL terminated strings.
-
-PS:
-After [1] refactoring, oem_id semantics became inconsistent, where
-NULL terminated string was coming from machine and old way pointer
-into byte array coming from -acpitable option. That used to work
-since build_header() wasn't expecting NULL terminated string and
-blindly copied the 1st 6 bytes only.
-
-However commit [2] broke that by replacing build_header() with
-acpi_table_begin(), which was expecting NULL terminated string
-and was checking oem_id size.
-
-1) 602b45820 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
-2)
-Fixes: 4b56e1e4eb08 ("acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header()")
-Resolves: https://gitlab.com/qemu-project/qemu/-/issues/786
-Signed-off-by: Igor Mammedov <imammedo@redhat.com>
-Message-Id: <20211227193120.1084176-2-imammedo@redhat.com>
-Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
-Tested-by: Denis Lisov <dennis.lissov@gmail.com>
-Tested-by: Alexander Tsoy <alexander@tsoy.me>
-Cc: qemu-stable@nongnu.org
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry picked from commit 8cdb99af45365727ac17f45239a9b8c1d5155c6d)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/acpi/core.c | 4 ++--
- hw/i386/acpi-build.c | 2 ++
- 2 files changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/hw/acpi/core.c b/hw/acpi/core.c
-index 1e004d0078..3e811bf03c 100644
---- a/hw/acpi/core.c
-+++ b/hw/acpi/core.c
-@@ -345,8 +345,8 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
- struct acpi_table_header *hdr = (void *)(u - sizeof(hdr->_length));
-
- if (memcmp(hdr->sig, "SLIC", 4) == 0) {
-- oem->id = hdr->oem_id;
-- oem->table_id = hdr->oem_table_id;
-+ oem->id = g_strndup(hdr->oem_id, 6);
-+ oem->table_id = g_strndup(hdr->oem_table_id, 8);
- return 0;
- }
- }
-diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
-index a99c6e4fe3..570f82997b 100644
---- a/hw/i386/acpi-build.c
-+++ b/hw/i386/acpi-build.c
-@@ -2721,6 +2721,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
-
- /* Cleanup memory that's no longer used. */
- g_array_free(table_offsets, true);
-+ g_free(slic_oem.id);
-+ g_free(slic_oem.table_id);
- }
-
- static void acpi_ram_update(MemoryRegion *mr, GArray *data)
diff --git a/debian/patches/extra/0011-virtio-net-fix-map-leaking-on-error-during-receive.patch b/debian/patches/extra/0011-virtio-net-fix-map-leaking-on-error-during-receive.patch
deleted file mode 100644
index 02e7bab..0000000
--- a/debian/patches/extra/0011-virtio-net-fix-map-leaking-on-error-during-receive.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Jason Wang <jasowang@redhat.com>
-Date: Tue, 8 Mar 2022 10:42:51 +0800
-Subject: [PATCH] virtio-net: fix map leaking on error during receive
-
-Commit bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
-tries to fix the use after free of the sg by caching the virtqueue
-elements in an array and unmap them at once after receiving the
-packets, But it forgot to unmap the cached elements on error which
-will lead to leaking of mapping and other unexpected results.
-
-Fixing this by detaching the cached elements on error. This addresses
-CVE-2022-26353.
-
-Reported-by: Victor Tom <vv474172261@gmail.com>
-Cc: qemu-stable@nongnu.org
-Fixes: CVE-2022-26353
-Fixes: bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg")
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Jason Wang <jasowang@redhat.com>
-(cherry picked from commit abe300d9d894f7138e1af7c8e9c88c04bfe98b37)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/net/virtio-net.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
-index f2014d5ea0..e1f4748831 100644
---- a/hw/net/virtio-net.c
-+++ b/hw/net/virtio-net.c
-@@ -1862,6 +1862,7 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
-
- err:
- for (j = 0; j < i; j++) {
-+ virtqueue_detach_element(q->rx_vq, elems[j], lens[j]);
- g_free(elems[j]);
- }
-
diff --git a/debian/patches/extra/0012-memory-Fix-incorrect-calls-of-log_global_start-stop.patch b/debian/patches/extra/0012-memory-Fix-incorrect-calls-of-log_global_start-stop.patch
deleted file mode 100644
index b1e97e5..0000000
--- a/debian/patches/extra/0012-memory-Fix-incorrect-calls-of-log_global_start-stop.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Peter Xu <peterx@redhat.com>
-Date: Tue, 30 Nov 2021 16:00:28 +0800
-Subject: [PATCH] memory: Fix incorrect calls of log_global_start/stop
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-We should only call the log_global_start/stop when the global dirty track
-bitmask changes from zero<->non-zero.
-
-No real issue reported for this yet probably because no immediate user to
-enable both dirty rate measurement and migration at the same time. However
-it'll be good to be prepared for it.
-
-Fixes: 63b41db4bc ("memory: make global_dirty_tracking a bitmask")
-Cc: qemu-stable@nongnu.org
-Cc: Hyman Huang <huangy81@chinatelecom.cn>
-Cc: Paolo Bonzini <pbonzini@redhat.com>
-Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
-Cc: Juan Quintela <quintela@redhat.com>
-Cc: David Hildenbrand <david@redhat.com>
-Signed-off-by: Peter Xu <peterx@redhat.com>
-Reviewed-by: David Hildenbrand <david@redhat.com>
-Message-Id: <20211130080028.6474-1-peterx@redhat.com>
-Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-(cherry picked from commit 7b0538ed3a22ce30817f818449d10701fb0821f9)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- softmmu/memory.c | 27 ++++++++++++++-------------
- 1 file changed, 14 insertions(+), 13 deletions(-)
-
-diff --git a/softmmu/memory.c b/softmmu/memory.c
-index 7340e19ff5..81d4bf1454 100644
---- a/softmmu/memory.c
-+++ b/softmmu/memory.c
-@@ -2773,6 +2773,8 @@ static VMChangeStateEntry *vmstate_change;
-
- void memory_global_dirty_log_start(unsigned int flags)
- {
-+ unsigned int old_flags = global_dirty_tracking;
-+
- if (vmstate_change) {
- qemu_del_vm_change_state_handler(vmstate_change);
- vmstate_change = NULL;
-@@ -2781,15 +2783,14 @@ void memory_global_dirty_log_start(unsigned int flags)
- assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
- assert(!(global_dirty_tracking & flags));
- global_dirty_tracking |= flags;
--
- trace_global_dirty_changed(global_dirty_tracking);
-
-- MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
--
-- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
-- memory_region_transaction_begin();
-- memory_region_update_pending = true;
-- memory_region_transaction_commit();
-+ if (!old_flags) {
-+ MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
-+ memory_region_transaction_begin();
-+ memory_region_update_pending = true;
-+ memory_region_transaction_commit();
-+ }
- }
-
- static void memory_global_dirty_log_do_stop(unsigned int flags)
-@@ -2800,12 +2801,12 @@ static void memory_global_dirty_log_do_stop(unsigned int flags)
-
- trace_global_dirty_changed(global_dirty_tracking);
-
-- /* Refresh DIRTY_MEMORY_MIGRATION bit. */
-- memory_region_transaction_begin();
-- memory_region_update_pending = true;
-- memory_region_transaction_commit();
--
-- MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
-+ if (!global_dirty_tracking) {
-+ memory_region_transaction_begin();
-+ memory_region_update_pending = true;
-+ memory_region_transaction_commit();
-+ MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
-+ }
- }
-
- static void memory_vm_change_state_handler(void *opaque, bool running,
diff --git a/debian/patches/extra/0013-acpi-fix-OEM-ID-OEM-Table-ID-padding.patch b/debian/patches/extra/0013-acpi-fix-OEM-ID-OEM-Table-ID-padding.patch
deleted file mode 100644
index 3696302..0000000
--- a/debian/patches/extra/0013-acpi-fix-OEM-ID-OEM-Table-ID-padding.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Igor Mammedov <imammedo@redhat.com>
-Date: Wed, 12 Jan 2022 08:03:31 -0500
-Subject: [PATCH] acpi: fix OEM ID/OEM Table ID padding
-
-Commit [2] broke original '\0' padding of OEM ID and OEM Table ID
-fields in headers of ACPI tables. While it doesn't have impact on
-default values since QEMU uses 6 and 8 characters long values
-respectively, it broke usecase where IDs are provided on QEMU CLI.
-It shouldn't affect guest (but may cause licensing verification
-issues in guest OS).
-One of the broken usecases is user supplied SLIC table with IDs
-shorter than max possible length, where [2] mangles IDs with extra
-spaces in RSDT and FADT tables whereas guest OS expects those to
-mirror the respective values of the used SLIC table.
-
-Fix it by replacing whitespace padding with '\0' padding in
-accordance with [1] and expectations of guest OS
-
-1) ACPI spec, v2.0b
- 17.2 AML Grammar Definition
- ...
- //OEM ID of up to 6 characters. If the OEM ID is
- //shorter than 6 characters, it can be terminated
- //with a NULL character.
-
-2)
-Fixes: 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
-Resolves: https://gitlab.com/qemu-project/qemu/-/issues/707
-Reported-by: Dmitry V. Orekhov <dima.orekhov@gmail.com>
-Signed-off-by: Igor Mammedov <imammedo@redhat.com>
-Cc: qemu-stable@nongnu.org
-Message-Id: <20220112130332.1648664-4-imammedo@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-Reviewed-by: Ani Sinha <ani@anisinha.ca>
-Tested-by: Dmitry V. Orekhov dima.orekhov@gmail.com
-(cherry picked from commit 748c030f360a940fe0c9382c8ca1649096c3a80d)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/acpi/aml-build.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
-index b3b3310df3..65148d5b9d 100644
---- a/hw/acpi/aml-build.c
-+++ b/hw/acpi/aml-build.c
-@@ -1724,9 +1724,9 @@ void acpi_table_begin(AcpiTable *desc, GArray *array)
- build_append_int_noprefix(array, 0, 4); /* Length */
- build_append_int_noprefix(array, desc->rev, 1); /* Revision */
- build_append_int_noprefix(array, 0, 1); /* Checksum */
-- build_append_padded_str(array, desc->oem_id, 6, ' '); /* OEMID */
-+ build_append_padded_str(array, desc->oem_id, 6, '\0'); /* OEMID */
- /* OEM Table ID */
-- build_append_padded_str(array, desc->oem_table_id, 8, ' ');
-+ build_append_padded_str(array, desc->oem_table_id, 8, '\0');
- build_append_int_noprefix(array, 1, 4); /* OEM Revision */
- g_array_append_vals(array, ACPI_BUILD_APPNAME8, 4); /* Creator ID */
- build_append_int_noprefix(array, 1, 4); /* Creator Revision */
diff --git a/debian/patches/extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch b/debian/patches/extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
deleted file mode 100644
index 35482c8..0000000
--- a/debian/patches/extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Stefano Garzarella <sgarzare@redhat.com>
-Date: Mon, 28 Feb 2022 10:50:58 +0100
-Subject: [PATCH] vhost-vsock: detach the virqueue element in case of error
-
-In vhost_vsock_common_send_transport_reset(), if an element popped from
-the virtqueue is invalid, we should call virtqueue_detach_element() to
-detach it from the virtqueue before freeing its memory.
-
-Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device")
-Fixes: CVE-2022-26354
-Cc: qemu-stable@nongnu.org
-Reported-by: VictorV <vv474172261@gmail.com>
-Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
-Message-Id: <20220228095058.27899-1-sgarzare@redhat.com>
-Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry picked from commit 8d1b247f3748ac4078524130c6d7ae42b6140aaf)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/virtio/vhost-vsock-common.c | 10 +++++++---
- 1 file changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
-index 3f3771274e..ed706681ac 100644
---- a/hw/virtio/vhost-vsock-common.c
-+++ b/hw/virtio/vhost-vsock-common.c
-@@ -153,19 +153,23 @@ static void vhost_vsock_common_send_transport_reset(VHostVSockCommon *vvc)
- if (elem->out_num) {
- error_report("invalid vhost-vsock event virtqueue element with "
- "out buffers");
-- goto out;
-+ goto err;
- }
-
- if (iov_from_buf(elem->in_sg, elem->in_num, 0,
- &event, sizeof(event)) != sizeof(event)) {
- error_report("vhost-vsock event virtqueue element is too short");
-- goto out;
-+ goto err;
- }
-
- virtqueue_push(vq, elem, sizeof(event));
- virtio_notify(VIRTIO_DEVICE(vvc), vq);
-
--out:
-+ g_free(elem);
-+ return;
-+
-+err:
-+ virtqueue_detach_element(vq, elem, 0);
- g_free(elem);
- }
-
diff --git a/debian/patches/extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch b/debian/patches/extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch
deleted file mode 100644
index d6d0877..0000000
--- a/debian/patches/extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch
+++ /dev/null
@@ -1,98 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Xueming Li <xuemingl@nvidia.com>
-Date: Mon, 7 Feb 2022 15:19:28 +0800
-Subject: [PATCH] vhost-user: remove VirtQ notifier restore
-
-Notifier set when vhost-user backend asks qemu to mmap an FD and
-offset. When vhost-user backend restart or getting killed, VQ notifier
-FD and mmap addresses become invalid. After backend restart, MR contains
-the invalid address will be restored and fail on notifier access.
-
-On the other hand, qemu should munmap the notifier, release underlying
-hardware resources to enable backend restart and allocate hardware
-notifier resources correctly.
-
-Qemu shouldn't reference and use resources of disconnected backend.
-
-This patch removes VQ notifier restore, uses the default vhost-user
-notifier to avoid invalid address access.
-
-After backend restart, the backend should ask qemu to install a hardware
-notifier if needed.
-
-Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Xueming Li <xuemingl@nvidia.com>
-Message-Id: <20220207071929.527149-2-xuemingl@nvidia.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry picked from commit e867144b73b3c5009266b6df07d5ff44acfb82c3)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/virtio/vhost-user.c | 19 +------------------
- include/hw/virtio/vhost-user.h | 1 -
- 2 files changed, 1 insertion(+), 19 deletions(-)
-
-diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
-index bf6e50223c..c671719e9b 100644
---- a/hw/virtio/vhost-user.c
-+++ b/hw/virtio/vhost-user.c
-@@ -1143,19 +1143,6 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
- return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring);
- }
-
--static void vhost_user_host_notifier_restore(struct vhost_dev *dev,
-- int queue_idx)
--{
-- struct vhost_user *u = dev->opaque;
-- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
-- VirtIODevice *vdev = dev->vdev;
--
-- if (n->addr && !n->set) {
-- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true);
-- n->set = true;
-- }
--}
--
- static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
- int queue_idx)
- {
-@@ -1163,17 +1150,14 @@ static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
- VirtIODevice *vdev = dev->vdev;
-
-- if (n->addr && n->set) {
-+ if (n->addr) {
- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
-- n->set = false;
- }
- }
-
- static int vhost_user_set_vring_base(struct vhost_dev *dev,
- struct vhost_vring_state *ring)
- {
-- vhost_user_host_notifier_restore(dev, ring->index);
--
- return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring);
- }
-
-@@ -1538,7 +1522,6 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
- }
-
- n->addr = addr;
-- n->set = true;
-
- return 0;
- }
-diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
-index a9abca3288..f6012b2078 100644
---- a/include/hw/virtio/vhost-user.h
-+++ b/include/hw/virtio/vhost-user.h
-@@ -14,7 +14,6 @@
- typedef struct VhostUserHostNotifier {
- MemoryRegion mr;
- void *addr;
-- bool set;
- } VhostUserHostNotifier;
-
- typedef struct VhostUserState {
diff --git a/debian/patches/extra/0016-vhost-user-fix-VirtQ-notifier-cleanup.patch b/debian/patches/extra/0016-vhost-user-fix-VirtQ-notifier-cleanup.patch
deleted file mode 100644
index 25a9644..0000000
--- a/debian/patches/extra/0016-vhost-user-fix-VirtQ-notifier-cleanup.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Xueming Li <xuemingl@nvidia.com>
-Date: Mon, 7 Feb 2022 15:19:29 +0800
-Subject: [PATCH] vhost-user: fix VirtQ notifier cleanup
-
-When vhost-user device cleanup, remove notifier MR and munmaps notifier
-address in the event-handling thread, VM CPU thread writing the notifier
-in concurrent fails with an error of accessing invalid address. It
-happens because MR is still being referenced and accessed in another
-thread while the underlying notifier mmap address is being freed and
-becomes invalid.
-
-This patch calls RCU and munmap notifiers in the callback after the
-memory flatview update finish.
-
-Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Xueming Li <xuemingl@nvidia.com>
-Message-Id: <20220207071929.527149-3-xuemingl@nvidia.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-(cherry picked from commit 0b0af4d62f7002b31cd7b2762b26d2fcb76bb2ba)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/virtio/vhost-user.c | 48 ++++++++++++++++++++--------------
- include/hw/virtio/vhost-user.h | 2 ++
- 2 files changed, 31 insertions(+), 19 deletions(-)
-
-diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
-index c671719e9b..ed5f9a5471 100644
---- a/hw/virtio/vhost-user.c
-+++ b/hw/virtio/vhost-user.c
-@@ -25,6 +25,7 @@
- #include "migration/migration.h"
- #include "migration/postcopy-ram.h"
- #include "trace.h"
-+#include "exec/ramblock.h"
-
- #include <sys/ioctl.h>
- #include <sys/socket.h>
-@@ -1143,15 +1144,26 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev,
- return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring);
- }
-
--static void vhost_user_host_notifier_remove(struct vhost_dev *dev,
-- int queue_idx)
-+static void vhost_user_host_notifier_free(VhostUserHostNotifier *n)
- {
-- struct vhost_user *u = dev->opaque;
-- VhostUserHostNotifier *n = &u->user->notifier[queue_idx];
-- VirtIODevice *vdev = dev->vdev;
-+ assert(n && n->unmap_addr);
-+ munmap(n->unmap_addr, qemu_real_host_page_size);
-+ n->unmap_addr = NULL;
-+}
-+
-+static void vhost_user_host_notifier_remove(VhostUserState *user,
-+ VirtIODevice *vdev, int queue_idx)
-+{
-+ VhostUserHostNotifier *n = &user->notifier[queue_idx];
-
- if (n->addr) {
-- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
-+ if (vdev) {
-+ virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
-+ }
-+ assert(!n->unmap_addr);
-+ n->unmap_addr = n->addr;
-+ n->addr = NULL;
-+ call_rcu(n, vhost_user_host_notifier_free, rcu);
- }
- }
-
-@@ -1190,8 +1202,9 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev,
- .payload.state = *ring,
- .hdr.size = sizeof(msg.payload.state),
- };
-+ struct vhost_user *u = dev->opaque;
-
-- vhost_user_host_notifier_remove(dev, ring->index);
-+ vhost_user_host_notifier_remove(u->user, dev->vdev, ring->index);
-
- if (vhost_user_write(dev, &msg, NULL, 0) < 0) {
- return -1;
-@@ -1486,12 +1499,7 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
-
- n = &user->notifier[queue_idx];
-
-- if (n->addr) {
-- virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false);
-- object_unparent(OBJECT(&n->mr));
-- munmap(n->addr, page_size);
-- n->addr = NULL;
-- }
-+ vhost_user_host_notifier_remove(user, vdev, queue_idx);
-
- if (area->u64 & VHOST_USER_VRING_NOFD_MASK) {
- return 0;
-@@ -1510,9 +1518,12 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
-
- name = g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]",
- user, queue_idx);
-- if (!n->mr.ram) /* Don't init again after suspend. */
-+ if (!n->mr.ram) { /* Don't init again after suspend. */
- memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
- page_size, addr);
-+ } else {
-+ n->mr.ram_block->host = addr;
-+ }
- g_free(name);
-
- if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) {
-@@ -2460,17 +2471,16 @@ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp)
- void vhost_user_cleanup(VhostUserState *user)
- {
- int i;
-+ VhostUserHostNotifier *n;
-
- if (!user->chr) {
- return;
- }
- memory_region_transaction_begin();
- for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
-- if (user->notifier[i].addr) {
-- object_unparent(OBJECT(&user->notifier[i].mr));
-- munmap(user->notifier[i].addr, qemu_real_host_page_size);
-- user->notifier[i].addr = NULL;
-- }
-+ n = &user->notifier[i];
-+ vhost_user_host_notifier_remove(user, NULL, i);
-+ object_unparent(OBJECT(&n->mr));
- }
- memory_region_transaction_commit();
- user->chr = NULL;
-diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
-index f6012b2078..e44a41bb70 100644
---- a/include/hw/virtio/vhost-user.h
-+++ b/include/hw/virtio/vhost-user.h
-@@ -12,8 +12,10 @@
- #include "hw/virtio/virtio.h"
-
- typedef struct VhostUserHostNotifier {
-+ struct rcu_head rcu;
- MemoryRegion mr;
- void *addr;
-+ void *unmap_addr;
- } VhostUserHostNotifier;
-
- typedef struct VhostUserState {
diff --git a/debian/patches/extra/0017-virtio-fix-the-condition-for-iommu_platform-not-supp.patch b/debian/patches/extra/0017-virtio-fix-the-condition-for-iommu_platform-not-supp.patch
deleted file mode 100644
index a1b56e1..0000000
--- a/debian/patches/extra/0017-virtio-fix-the-condition-for-iommu_platform-not-supp.patch
+++ /dev/null
@@ -1,101 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Halil Pasic <pasic@linux.ibm.com>
-Date: Mon, 7 Feb 2022 12:28:57 +0100
-Subject: [PATCH] virtio: fix the condition for iommu_platform not supported
-
-The commit 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but
-unsupported") claims to fail the device hotplug when iommu_platform
-is requested, but not supported by the (vhost) device. On the first
-glance the condition for detecting that situation looks perfect, but
-because a certain peculiarity of virtio_platform it ain't.
-
-In fact the aforementioned commit introduces a regression. It breaks
-virtio-fs support for Secure Execution, and most likely also for AMD SEV
-or any other confidential guest scenario that relies encrypted guest
-memory. The same also applies to any other vhost device that does not
-support _F_ACCESS_PLATFORM.
-
-The peculiarity is that iommu_platform and _F_ACCESS_PLATFORM collates
-"device can not access all of the guest RAM" and "iova != gpa, thus
-device needs to translate iova".
-
-Confidential guest technologies currently rely on the device/hypervisor
-offering _F_ACCESS_PLATFORM, so that, after the feature has been
-negotiated, the guest grants access to the portions of memory the
-device needs to see. So in for confidential guests, generally,
-_F_ACCESS_PLATFORM is about the restricted access to memory, but not
-about the addresses used being something else than guest physical
-addresses.
-
-This is the very reason for which commit f7ef7e6e3b ("vhost: correctly
-turn on VIRTIO_F_IOMMU_PLATFORM") fences _F_ACCESS_PLATFORM from the
-vhost device that does not need it, because on the vhost interface it
-only means "I/O address translation is needed".
-
-This patch takes inspiration from f7ef7e6e3b ("vhost: correctly turn on
-VIRTIO_F_IOMMU_PLATFORM"), and uses the same condition for detecting the
-situation when _F_ACCESS_PLATFORM is requested, but no I/O translation
-by the device, and thus no device capability is needed. In this
-situation claiming that the device does not support iommu_plattform=on
-is counter-productive. So let us stop doing that!
-
-Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
-Reported-by: Jakob Naucke <Jakob.Naucke@ibm.com>
-Fixes: 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but
-unsupported")
-Acked-by: Cornelia Huck <cohuck@redhat.com>
-Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
-Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
-Cc: Kevin Wolf <kwolf@redhat.com>
-Cc: qemu-stable@nongnu.org
-
-Message-Id: <20220207112857.607829-1-pasic@linux.ibm.com>
-Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-Acked-by: Jason Wang <jasowang@redhat.com>
-(cherry picked from commit e65902a913bf31ba79a83a3bd3621108b85cf645)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/virtio/virtio-bus.c | 12 +++++++-----
- 1 file changed, 7 insertions(+), 5 deletions(-)
-
-diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
-index d23db98c56..0f69d1c742 100644
---- a/hw/virtio/virtio-bus.c
-+++ b/hw/virtio/virtio-bus.c
-@@ -48,6 +48,7 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
- VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
- VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
- bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
-+ bool vdev_has_iommu;
- Error *local_err = NULL;
-
- DPRINTF("%s: plug device.\n", qbus->name);
-@@ -69,11 +70,6 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
- return;
- }
-
-- if (has_iommu && !virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
-- error_setg(errp, "iommu_platform=true is not supported by the device");
-- return;
-- }
--
- if (klass->device_plugged != NULL) {
- klass->device_plugged(qbus->parent, &local_err);
- }
-@@ -82,9 +78,15 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
- return;
- }
-
-+ vdev_has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
- if (klass->get_dma_as != NULL && has_iommu) {
- virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM);
- vdev->dma_as = klass->get_dma_as(qbus->parent);
-+ if (!vdev_has_iommu && vdev->dma_as != &address_space_memory) {
-+ error_setg(errp,
-+ "iommu_platform=true is not supported by the device");
-+ return;
-+ }
- } else {
- vdev->dma_as = &address_space_memory;
- }
diff --git a/debian/patches/extra/0019-ui-vnc.c-Fixed-a-deadlock-bug.patch b/debian/patches/extra/0019-ui-vnc.c-Fixed-a-deadlock-bug.patch
deleted file mode 100644
index 722ab2c..0000000
--- a/debian/patches/extra/0019-ui-vnc.c-Fixed-a-deadlock-bug.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Rao Lei <lei.rao@intel.com>
-Date: Fri, 6 May 2022 14:38:36 +0200
-Subject: [PATCH] ui/vnc.c: Fixed a deadlock bug.
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The GDB statck is as follows:
-(gdb) bt
-0 __lll_lock_wait (futex=futex@entry=0x56211df20360, private=0) at lowlevellock.c:52
-1 0x00007f263caf20a3 in __GI___pthread_mutex_lock (mutex=0x56211df20360) at ../nptl/pthread_mutex_lock.c:80
-2 0x000056211a757364 in qemu_mutex_lock_impl (mutex=0x56211df20360, file=0x56211a804857 "../ui/vnc-jobs.h", line=60)
- at ../util/qemu-thread-posix.c:80
-3 0x000056211a0ef8c7 in vnc_lock_output (vs=0x56211df14200) at ../ui/vnc-jobs.h:60
-4 0x000056211a0efcb7 in vnc_clipboard_send (vs=0x56211df14200, count=1, dwords=0x7ffdf1701338) at ../ui/vnc-clipboard.c:138
-5 0x000056211a0f0129 in vnc_clipboard_notify (notifier=0x56211df244c8, data=0x56211dd1bbf0) at ../ui/vnc-clipboard.c:209
-6 0x000056211a75dde8 in notifier_list_notify (list=0x56211afa17d0 <clipboard_notifiers>, data=0x56211dd1bbf0) at ../util/notify.c:39
-7 0x000056211a0bf0e6 in qemu_clipboard_update (info=0x56211dd1bbf0) at ../ui/clipboard.c:50
-8 0x000056211a0bf05d in qemu_clipboard_peer_release (peer=0x56211df244c0, selection=QEMU_CLIPBOARD_SELECTION_CLIPBOARD)
- at ../ui/clipboard.c:41
-9 0x000056211a0bef9b in qemu_clipboard_peer_unregister (peer=0x56211df244c0) at ../ui/clipboard.c:19
-10 0x000056211a0d45f3 in vnc_disconnect_finish (vs=0x56211df14200) at ../ui/vnc.c:1358
-11 0x000056211a0d4c9d in vnc_client_read (vs=0x56211df14200) at ../ui/vnc.c:1611
-12 0x000056211a0d4df8 in vnc_client_io (ioc=0x56211ce70690, condition=G_IO_IN, opaque=0x56211df14200) at ../ui/vnc.c:1649
-13 0x000056211a5b976c in qio_channel_fd_source_dispatch
- (source=0x56211ce50a00, callback=0x56211a0d4d71 <vnc_client_io>, user_data=0x56211df14200) at ../io/channel-watch.c:84
-14 0x00007f263ccede8e in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
-15 0x000056211a77d4a1 in glib_pollfds_poll () at ../util/main-loop.c:232
-16 0x000056211a77d51f in os_host_main_loop_wait (timeout=958545) at ../util/main-loop.c:255
-17 0x000056211a77d630 in main_loop_wait (nonblocking=0) at ../util/main-loop.c:531
-18 0x000056211a45bc8e in qemu_main_loop () at ../softmmu/runstate.c:726
-19 0x000056211a0b45fa in main (argc=69, argv=0x7ffdf1701778, envp=0x7ffdf17019a8) at ../softmmu/main.c:50
-
-From the call trace, we can see it is a deadlock bug.
-vnc_disconnect_finish will acquire the output_mutex.
-But, the output_mutex will be acquired again in vnc_clipboard_send.
-Repeated locking will cause deadlock. So, I move
-qemu_clipboard_peer_unregister() behind vnc_unlock_output();
-
-Fixes: 0bf41cab93e ("ui/vnc: clipboard support")
-Signed-off-by: Lei Rao <lei.rao@intel.com>
-Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-Message-Id: <20220105020808.597325-1-lei.rao@intel.com>
-Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-(cherry-picked from commit 1dbbe6f172810026c51dc84ed927a3cc23017949)
-[FE: trivial backport for 6.2]
-Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- ui/vnc.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/ui/vnc.c b/ui/vnc.c
-index af02522e84..b253e85c65 100644
---- a/ui/vnc.c
-+++ b/ui/vnc.c
-@@ -1354,12 +1354,12 @@ void vnc_disconnect_finish(VncState *vs)
- /* last client gone */
- vnc_update_server_surface(vs->vd);
- }
-+ vnc_unlock_output(vs);
-+
- if (vs->cbpeer.update.notify) {
- qemu_clipboard_peer_unregister(&vs->cbpeer);
- }
-
-- vnc_unlock_output(vs);
--
- qemu_mutex_destroy(&vs->output_mutex);
- if (vs->bh != NULL) {
- qemu_bh_delete(vs->bh);
diff --git a/debian/patches/extra/0020-display-qxl-render-fix-race-condition-in-qxl_cursor-.patch b/debian/patches/extra/0020-display-qxl-render-fix-race-condition-in-qxl_cursor-.patch
deleted file mode 100644
index cac949b..0000000
--- a/debian/patches/extra/0020-display-qxl-render-fix-race-condition-in-qxl_cursor-.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Mauro Matteo Cascella <mcascell@redhat.com>
-Date: Thu, 7 Apr 2022 10:11:06 +0200
-Subject: [PATCH] display/qxl-render: fix race condition in qxl_cursor
- (CVE-2021-4207)
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Avoid fetching 'width' and 'height' a second time to prevent possible
-race condition. Refer to security advisory
-https://starlabs.sg/advisories/22-4207/ for more information.
-
-Fixes: CVE-2021-4207
-Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
-Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-Message-Id: <20220407081106.343235-1-mcascell@redhat.com>
-Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-(cherry picked from commit 9569f5cb5b4bffa9d3ebc8ba7da1e03830a9a895)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/display/qxl-render.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
-index d28849b121..237ed293ba 100644
---- a/hw/display/qxl-render.c
-+++ b/hw/display/qxl-render.c
-@@ -266,7 +266,7 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
- }
- break;
- case SPICE_CURSOR_TYPE_ALPHA:
-- size = sizeof(uint32_t) * cursor->header.width * cursor->header.height;
-+ size = sizeof(uint32_t) * c->width * c->height;
- qxl_unpack_chunks(c->data, size, qxl, &cursor->chunk, group_id);
- if (qxl->debug > 2) {
- cursor_print_ascii_art(c, "qxl/alpha");
diff --git a/debian/patches/extra/0021-ui-cursor-fix-integer-overflow-in-cursor_alloc-CVE-2.patch b/debian/patches/extra/0021-ui-cursor-fix-integer-overflow-in-cursor_alloc-CVE-2.patch
deleted file mode 100644
index 7c295f9..0000000
--- a/debian/patches/extra/0021-ui-cursor-fix-integer-overflow-in-cursor_alloc-CVE-2.patch
+++ /dev/null
@@ -1,83 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Mauro Matteo Cascella <mcascell@redhat.com>
-Date: Thu, 7 Apr 2022 10:17:12 +0200
-Subject: [PATCH] ui/cursor: fix integer overflow in cursor_alloc
- (CVE-2021-4206)
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Prevent potential integer overflow by limiting 'width' and 'height' to
-512x512. Also change 'datasize' type to size_t. Refer to security
-advisory https://starlabs.sg/advisories/22-4206/ for more information.
-
-Fixes: CVE-2021-4206
-Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
-Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-Message-Id: <20220407081712.345609-1-mcascell@redhat.com>
-Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-(cherry picked from commit fa892e9abb728e76afcf27323ab29c57fb0fe7aa)
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
----
- hw/display/qxl-render.c | 7 +++++++
- hw/display/vmware_vga.c | 2 ++
- ui/cursor.c | 8 +++++++-
- 3 files changed, 16 insertions(+), 1 deletion(-)
-
-diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
-index 237ed293ba..ca217004bf 100644
---- a/hw/display/qxl-render.c
-+++ b/hw/display/qxl-render.c
-@@ -247,6 +247,13 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
- size_t size;
-
- c = cursor_alloc(cursor->header.width, cursor->header.height);
-+
-+ if (!c) {
-+ qxl_set_guest_bug(qxl, "%s: cursor %ux%u alloc error", __func__,
-+ cursor->header.width, cursor->header.height);
-+ goto fail;
-+ }
-+
- c->hot_x = cursor->header.hot_spot_x;
- c->hot_y = cursor->header.hot_spot_y;
- switch (cursor->header.type) {
-diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
-index e2969a6c81..2b81d6122f 100644
---- a/hw/display/vmware_vga.c
-+++ b/hw/display/vmware_vga.c
-@@ -509,6 +509,8 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
- int i, pixels;
-
- qc = cursor_alloc(c->width, c->height);
-+ assert(qc != NULL);
-+
- qc->hot_x = c->hot_x;
- qc->hot_y = c->hot_y;
- switch (c->bpp) {
-diff --git a/ui/cursor.c b/ui/cursor.c
-index 1d62ddd4d0..835f0802f9 100644
---- a/ui/cursor.c
-+++ b/ui/cursor.c
-@@ -46,6 +46,8 @@ static QEMUCursor *cursor_parse_xpm(const char *xpm[])
-
- /* parse pixel data */
- c = cursor_alloc(width, height);
-+ assert(c != NULL);
-+
- for (pixel = 0, y = 0; y < height; y++, line++) {
- for (x = 0; x < height; x++, pixel++) {
- idx = xpm[line][x];
-@@ -91,7 +93,11 @@ QEMUCursor *cursor_builtin_left_ptr(void)
- QEMUCursor *cursor_alloc(int width, int height)
- {
- QEMUCursor *c;
-- int datasize = width * height * sizeof(uint32_t);
-+ size_t datasize = width * height * sizeof(uint32_t);
-+
-+ if (width > 512 || height > 512) {
-+ return NULL;
-+ }
-
- c = g_malloc0(sizeof(QEMUCursor) + datasize);
- c->width = width;
diff --git a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
index ae9a483..700afed 100644
--- a/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
+++ b/debian/patches/pve/0001-PVE-Config-block-file-change-locking-default-to-off.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index b283093e5b..821405fd02 100644
+index 39a3d6dbe6..e5bf5d59bf 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -552,7 +552,7 @@ static QemuOptsList raw_runtime_opts = {
+@@ -554,7 +554,7 @@ static QemuOptsList raw_runtime_opts = {
{
.name = "locking",
.type = QEMU_OPT_STRING,
@@ -26,7 +26,7 @@ index b283093e5b..821405fd02 100644
},
{
.name = "pr-manager",
-@@ -652,7 +652,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
+@@ -654,7 +654,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
s->use_lock = false;
break;
case ON_OFF_AUTO_AUTO:
diff --git a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
index 051e997..6a19ef0 100644
--- a/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
+++ b/debian/patches/pve/0003-PVE-Config-set-the-CPU-model-to-kvm64-32-instead-of-.patch
@@ -10,10 +10,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
-index 04f2b790c9..19fdbb981c 100644
+index 982c532353..5395e7e471 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
-@@ -2039,9 +2039,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
+@@ -2087,9 +2087,9 @@ uint64_t cpu_get_tsc(CPUX86State *env);
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
#ifdef TARGET_X86_64
diff --git a/debian/patches/pve/0004-PVE-Config-ui-spice-default-to-pve-certificates.patch b/debian/patches/pve/0004-PVE-Config-ui-spice-default-to-pve-certificates.patch
index 0e41fd1..39aedf0 100644
--- a/debian/patches/pve/0004-PVE-Config-ui-spice-default-to-pve-certificates.patch
+++ b/debian/patches/pve/0004-PVE-Config-ui-spice-default-to-pve-certificates.patch
@@ -9,7 +9,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/ui/spice-core.c b/ui/spice-core.c
-index 31974b8d6c..a3acdbd682 100644
+index c3ac20ad43..37774f1c0a 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -689,32 +689,35 @@ static void qemu_spice_init(void)
diff --git a/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch b/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
index e378405..ce4366d 100644
--- a/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
+++ b/debian/patches/pve/0006-PVE-Config-rbd-block-rbd-disable-rbd_cache_writethro.patch
@@ -18,7 +18,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+)
diff --git a/block/rbd.c b/block/rbd.c
-index def96292e0..a4b8fb482c 100644
+index 6caf35cbba..0cec24c86d 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -820,6 +820,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
diff --git a/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch b/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
index ac54142..d6b5440 100644
--- a/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
+++ b/debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
@@ -49,7 +49,7 @@ index f0d14dbfc1..6d476c47ef 100644
{
NetClientState *nc;
diff --git a/qapi/net.json b/qapi/net.json
-index 7fab2e7cd8..74c9a6109e 100644
+index b92f3f5fb4..52c7e1f82b 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -35,6 +35,21 @@
@@ -75,10 +75,10 @@ index 7fab2e7cd8..74c9a6109e 100644
# @netdev_add:
#
diff --git a/qapi/pragma.json b/qapi/pragma.json
-index 3bc0335d1f..7c91ea3685 100644
+index e6a021c19c..41139d8645 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
-@@ -22,6 +22,7 @@
+@@ -25,6 +25,7 @@
'system_reset',
'system_wakeup' ],
'command-returns-exceptions': [
diff --git a/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch b/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
index 58f04c8..0d67cd2 100644
--- a/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
+++ b/debian/patches/pve/0009-PVE-Up-qemu-img-return-success-on-info-without-snaps.patch
@@ -9,10 +9,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
-index f036a1d428..080ad9bca7 100644
+index 1caddfb23a..2782e181c0 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -2989,7 +2989,8 @@ static int img_info(int argc, char **argv)
+@@ -3005,7 +3005,8 @@ static int img_info(int argc, char **argv)
list = collect_image_info_list(image_opts, filename, fmt, chain,
force_share);
if (!list) {
diff --git a/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch b/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
index 26ccf4f..7163f0f 100644
--- a/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
+++ b/debian/patches/pve/0010-PVE-Up-qemu-img-dd-add-osize-and-read-from-to-stdin-.patch
@@ -37,7 +37,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 119 insertions(+), 72 deletions(-)
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
-index 72bcdcfbfa..0b2999f3ab 100644
+index 1b1dab5b17..d1616c045a 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -58,9 +58,9 @@ SRST
@@ -53,10 +53,10 @@ index 72bcdcfbfa..0b2999f3ab 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 080ad9bca7..1f457d9e80 100644
+index 2782e181c0..8cd43b3601 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4805,10 +4805,12 @@ static int img_bitmap(int argc, char **argv)
+@@ -4821,10 +4821,12 @@ static int img_bitmap(int argc, char **argv)
#define C_IF 04
#define C_OF 010
#define C_SKIP 020
@@ -69,7 +69,7 @@ index 080ad9bca7..1f457d9e80 100644
};
struct DdIo {
-@@ -4884,6 +4886,19 @@ static int img_dd_skip(const char *arg,
+@@ -4900,6 +4902,19 @@ static int img_dd_skip(const char *arg,
return 0;
}
@@ -89,7 +89,7 @@ index 080ad9bca7..1f457d9e80 100644
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4924,6 +4939,7 @@ static int img_dd(int argc, char **argv)
+@@ -4940,6 +4955,7 @@ static int img_dd(int argc, char **argv)
{ "if", img_dd_if, C_IF },
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
@@ -97,7 +97,7 @@ index 080ad9bca7..1f457d9e80 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -4999,91 +5015,112 @@ static int img_dd(int argc, char **argv)
+@@ -5015,91 +5031,112 @@ static int img_dd(int argc, char **argv)
arg = NULL;
}
@@ -274,7 +274,7 @@ index 080ad9bca7..1f457d9e80 100644
}
if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
-@@ -5101,11 +5138,17 @@ static int img_dd(int argc, char **argv)
+@@ -5117,11 +5154,17 @@ static int img_dd(int argc, char **argv)
for (out_pos = 0; in_pos < size; block_count++) {
int in_ret, out_ret;
@@ -296,7 +296,7 @@ index 080ad9bca7..1f457d9e80 100644
}
if (in_ret < 0) {
error_report("error while reading from input image file: %s",
-@@ -5115,9 +5158,13 @@ static int img_dd(int argc, char **argv)
+@@ -5131,9 +5174,13 @@ static int img_dd(int argc, char **argv)
}
in_pos += in_ret;
diff --git a/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch b/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
index 3e4434f..29df3de 100644
--- a/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
+++ b/debian/patches/pve/0011-PVE-Up-qemu-img-dd-add-isize-parameter.patch
@@ -15,10 +15,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
-index 1f457d9e80..d9e8a8c4d4 100644
+index 8cd43b3601..67033b2d2c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4806,11 +4806,13 @@ static int img_bitmap(int argc, char **argv)
+@@ -4822,11 +4822,13 @@ static int img_bitmap(int argc, char **argv)
#define C_OF 010
#define C_SKIP 020
#define C_OSIZE 040
@@ -32,7 +32,7 @@ index 1f457d9e80..d9e8a8c4d4 100644
};
struct DdIo {
-@@ -4899,6 +4901,19 @@ static int img_dd_osize(const char *arg,
+@@ -4915,6 +4917,19 @@ static int img_dd_osize(const char *arg,
return 0;
}
@@ -52,7 +52,7 @@ index 1f457d9e80..d9e8a8c4d4 100644
static int img_dd(int argc, char **argv)
{
int ret = 0;
-@@ -4913,12 +4928,14 @@ static int img_dd(int argc, char **argv)
+@@ -4929,12 +4944,14 @@ static int img_dd(int argc, char **argv)
int c, i;
const char *out_fmt = "raw";
const char *fmt = NULL;
@@ -68,7 +68,7 @@ index 1f457d9e80..d9e8a8c4d4 100644
};
struct DdIo in = {
.bsz = 512, /* Block size is by default 512 bytes */
-@@ -4940,6 +4957,7 @@ static int img_dd(int argc, char **argv)
+@@ -4956,6 +4973,7 @@ static int img_dd(int argc, char **argv)
{ "of", img_dd_of, C_OF },
{ "skip", img_dd_skip, C_SKIP },
{ "osize", img_dd_osize, C_OSIZE },
@@ -76,7 +76,7 @@ index 1f457d9e80..d9e8a8c4d4 100644
{ NULL, NULL, 0 }
};
const struct option long_options[] = {
-@@ -5136,14 +5154,18 @@ static int img_dd(int argc, char **argv)
+@@ -5152,14 +5170,18 @@ static int img_dd(int argc, char **argv)
in.buf = g_new(uint8_t, in.bsz);
diff --git a/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch b/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
index f086107..39991dd 100644
--- a/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
+++ b/debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
@@ -13,7 +13,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index d663dd92bd..a49badb158 100644
+index 8885ea11cf..33979b7430 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -208,6 +208,10 @@ Parameters to convert subcommand:
@@ -49,7 +49,7 @@ index d663dd92bd..a49badb158 100644
Give information about the disk image *FILENAME*. Use it in
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
-index 0b2999f3ab..f3b2b1b4de 100644
+index d1616c045a..b5b0bb4467 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -58,9 +58,9 @@ SRST
@@ -65,10 +65,10 @@ index 0b2999f3ab..f3b2b1b4de 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index d9e8a8c4d4..015d6d2ce4 100644
+index 67033b2d2c..35c2bdc95c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4930,7 +4930,7 @@ static int img_dd(int argc, char **argv)
+@@ -4946,7 +4946,7 @@ static int img_dd(int argc, char **argv)
const char *fmt = NULL;
int64_t size = 0, readsize = 0;
int64_t block_count = 0, out_pos, in_pos;
@@ -77,7 +77,7 @@ index d9e8a8c4d4..015d6d2ce4 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4968,7 +4968,7 @@ static int img_dd(int argc, char **argv)
+@@ -4984,7 +4984,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -86,7 +86,7 @@ index d9e8a8c4d4..015d6d2ce4 100644
if (c == EOF) {
break;
}
-@@ -4988,6 +4988,9 @@ static int img_dd(int argc, char **argv)
+@@ -5004,6 +5004,9 @@ static int img_dd(int argc, char **argv)
case 'h':
help();
break;
@@ -96,7 +96,7 @@ index d9e8a8c4d4..015d6d2ce4 100644
case 'U':
force_share = true;
break;
-@@ -5118,13 +5121,15 @@ static int img_dd(int argc, char **argv)
+@@ -5134,13 +5137,15 @@ static int img_dd(int argc, char **argv)
size - in.bsz * in.offset, &error_abort);
}
diff --git a/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch b/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
index 88a9785..a52235f 100644
--- a/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
+++ b/debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
-index 9a4f491b54..1faa16234e 100644
+index 163d244eb4..389907f1f8 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
-@@ -812,8 +812,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+@@ -813,8 +813,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
@@ -58,10 +58,10 @@ index 9a4f491b54..1faa16234e 100644
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 2e91ccb738..e9fa9af6bd 100644
+index 634968498b..5482dd0569 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -696,7 +696,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
+@@ -708,7 +708,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
return;
}
@@ -99,7 +99,7 @@ index 2e91ccb738..e9fa9af6bd 100644
qapi_free_BalloonInfo(info);
}
diff --git a/qapi/machine.json b/qapi/machine.json
-index 067e3f5378..91f3be6f44 100644
+index d25a481ce4..3627172aed 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1018,10 +1018,30 @@
diff --git a/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch b/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
index a7dfb1d..8c7d776 100644
--- a/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
+++ b/debian/patches/pve/0014-PVE-qapi-modify-query-machines.patch
@@ -30,10 +30,10 @@ index 4f4ab30f8c..76fff60a6b 100644
info->default_cpu_type = g_strdup(mc->default_cpu_type);
info->has_default_cpu_type = true;
diff --git a/qapi/machine.json b/qapi/machine.json
-index 91f3be6f44..0905618e25 100644
+index 3627172aed..ca133e68ce 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -141,6 +141,8 @@
+@@ -139,6 +139,8 @@
#
# @is-default: whether the machine is default
#
@@ -42,7 +42,7 @@ index 91f3be6f44..0905618e25 100644
# @cpu-max: maximum number of CPUs supported by the machine type
# (since 1.5)
#
-@@ -162,7 +164,7 @@
+@@ -160,7 +162,7 @@
##
{ 'struct': 'MachineInfo',
'data': { 'name': 'str', '*alias': 'str',
diff --git a/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch b/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
index 538a0c0..3f7fd62 100644
--- a/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
+++ b/debian/patches/pve/0015-PVE-qapi-modify-spice-query.patch
@@ -12,10 +12,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 8 insertions(+)
diff --git a/qapi/ui.json b/qapi/ui.json
-index 4244c62c30..f946fbd8c1 100644
+index 13a8bb82aa..4c34436ba7 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
-@@ -333,11 +333,14 @@
+@@ -300,11 +300,14 @@
#
# @channels: a list of @SpiceChannel for each active spice channel
#
@@ -31,7 +31,7 @@ index 4244c62c30..f946fbd8c1 100644
'if': 'CONFIG_SPICE' }
diff --git a/ui/spice-core.c b/ui/spice-core.c
-index a3acdbd682..756776778d 100644
+index 37774f1c0a..367f77f2b4 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -534,6 +534,11 @@ static SpiceInfo *qmp_query_spice_real(Error **errp)
diff --git a/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch b/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
index 365e481..0197289 100644
--- a/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
+++ b/debian/patches/pve/0016-PVE-add-savevm-async-for-background-state-snapshots.patch
@@ -39,10 +39,10 @@ Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
create mode 100644 migration/savevm-async.c
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index 407a1da800..245f8acc55 100644
+index adfa085a9b..925e680e5a 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
-@@ -536,6 +536,19 @@ SRST
+@@ -538,6 +538,19 @@ SRST
Show current migration parameters.
ERST
@@ -63,7 +63,7 @@ index 407a1da800..245f8acc55 100644
.name = "balloon",
.args_type = "",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 5efb47fc32..1ad13b668b 100644
+index 8476277aa9..7f0ac498c4 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1746,3 +1746,36 @@ ERST
@@ -138,7 +138,7 @@ index 96d014826a..3a39ba41b5 100644
void hmp_screendump(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
diff --git a/migration/meson.build b/migration/meson.build
-index f8714dcb15..ea9aedeefc 100644
+index 8b5ca5c047..1e2aec8486 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -23,6 +23,7 @@ softmmu_ss.add(files(
@@ -754,10 +754,10 @@ index 0000000000..79a0cda906
+ return ret;
+}
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index e9fa9af6bd..5000ce39d1 100644
+index 5482dd0569..c64b959738 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
-@@ -1903,6 +1903,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
+@@ -1906,6 +1906,63 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, err);
}
@@ -822,10 +822,10 @@ index e9fa9af6bd..5000ce39d1 100644
{
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
diff --git a/qapi/migration.json b/qapi/migration.json
-index bbfd48cf0b..45686390a2 100644
+index 27d7b28158..31d6cc902e 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
-@@ -247,6 +247,40 @@
+@@ -258,6 +258,40 @@
'*compression': 'CompressionStats',
'*socket-address': ['SocketAddress'] } }
@@ -867,7 +867,7 @@ index bbfd48cf0b..45686390a2 100644
# @query-migrate:
#
diff --git a/qapi/misc.json b/qapi/misc.json
-index 358548abe1..25b3febc52 100644
+index b83cc39029..1e5dd7db29 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -435,6 +435,38 @@
@@ -910,10 +910,10 @@ index 358548abe1..25b3febc52 100644
# @CommandLineParameterType:
#
diff --git a/qemu-options.hx b/qemu-options.hx
-index ae2c6dbbfc..423144abeb 100644
+index 34e9b32a5c..aeade4ef80 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -4171,6 +4171,18 @@ SRST
+@@ -4254,6 +4254,18 @@ SRST
Start right away with a saved state (``loadvm`` in monitor)
ERST
@@ -933,10 +933,10 @@ index ae2c6dbbfc..423144abeb 100644
DEF("daemonize", 0, QEMU_OPTION_daemonize, \
"-daemonize daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 620a1f1367..fd82efb8b3 100644
+index 6f646531a0..a3f2a3818c 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -156,6 +156,7 @@ static const char *incoming;
+@@ -157,6 +157,7 @@ static const char *incoming;
static const char *loadvm;
static const char *accelerators;
static QDict *machine_opts_dict;
@@ -944,7 +944,7 @@ index 620a1f1367..fd82efb8b3 100644
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
static ram_addr_t maxram_size;
-@@ -2743,6 +2744,12 @@ void qmp_x_exit_preconfig(Error **errp)
+@@ -2749,6 +2750,12 @@ void qmp_x_exit_preconfig(Error **errp)
if (loadvm) {
load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
@@ -957,7 +957,7 @@ index 620a1f1367..fd82efb8b3 100644
}
if (replay_mode != REPLAY_MODE_NONE) {
replay_vmstate_init();
-@@ -3284,6 +3291,9 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3289,6 +3296,9 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_loadvm:
loadvm = optarg;
break;
diff --git a/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch b/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
index 0bbaed4..e64ebbe 100644
--- a/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
+++ b/debian/patches/pve/0017-PVE-add-optional-buffer-size-to-QEMUFile.patch
@@ -17,10 +17,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
-index 6338d8e2ff..6697a93a7e 100644
+index 1479cddad9..21a3355ae2 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
-@@ -30,8 +30,8 @@
+@@ -31,8 +31,8 @@
#include "trace.h"
#include "qapi/error.h"
@@ -31,7 +31,7 @@ index 6338d8e2ff..6697a93a7e 100644
struct QEMUFile {
const QEMUFileOps *ops;
-@@ -45,7 +45,8 @@ struct QEMUFile {
+@@ -46,7 +46,8 @@ struct QEMUFile {
when reading */
int buf_index;
int buf_size; /* 0 when writing */
@@ -41,7 +41,7 @@ index 6338d8e2ff..6697a93a7e 100644
DECLARE_BITMAP(may_free, MAX_IOV_SIZE);
struct iovec iov[MAX_IOV_SIZE];
-@@ -103,7 +104,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
+@@ -104,7 +105,7 @@ bool qemu_file_mode_is_not_valid(const char *mode)
return false;
}
@@ -50,7 +50,7 @@ index 6338d8e2ff..6697a93a7e 100644
{
QEMUFile *f;
-@@ -112,9 +113,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
+@@ -113,9 +114,17 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_ioc)
f->opaque = opaque;
f->ops = ops;
f->has_ioc = has_ioc;
@@ -68,7 +68,7 @@ index 6338d8e2ff..6697a93a7e 100644
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
{
-@@ -349,7 +358,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
+@@ -350,7 +359,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
}
len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
@@ -77,7 +77,7 @@ index 6338d8e2ff..6697a93a7e 100644
if (len > 0) {
f->buf_size += len;
f->pos += len;
-@@ -389,6 +398,9 @@ int qemu_fclose(QEMUFile *f)
+@@ -390,6 +399,9 @@ int qemu_fclose(QEMUFile *f)
ret = ret2;
}
}
@@ -87,7 +87,7 @@ index 6338d8e2ff..6697a93a7e 100644
/* If any error was spotted before closing, we should report it
* instead of the close() return value.
*/
-@@ -443,7 +455,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
+@@ -444,7 +456,7 @@ static void add_buf_to_iovec(QEMUFile *f, size_t len)
{
if (!add_to_iovec(f, f->buf + f->buf_index, len, false)) {
f->buf_index += len;
@@ -96,7 +96,7 @@ index 6338d8e2ff..6697a93a7e 100644
qemu_fflush(f);
}
}
-@@ -469,7 +481,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
+@@ -470,7 +482,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
}
while (size > 0) {
@@ -105,7 +105,7 @@ index 6338d8e2ff..6697a93a7e 100644
if (l > size) {
l = size;
}
-@@ -516,8 +528,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
+@@ -517,8 +529,8 @@ size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset)
size_t index;
assert(!qemu_file_is_writable(f));
@@ -116,7 +116,7 @@ index 6338d8e2ff..6697a93a7e 100644
/* The 1st byte to read from */
index = f->buf_index + offset;
-@@ -567,7 +579,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -568,7 +580,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
size_t res;
uint8_t *src;
@@ -125,7 +125,7 @@ index 6338d8e2ff..6697a93a7e 100644
if (res == 0) {
return done;
}
-@@ -601,7 +613,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
+@@ -602,7 +614,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size)
*/
size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size)
{
@@ -134,7 +134,7 @@ index 6338d8e2ff..6697a93a7e 100644
size_t res;
uint8_t *src = NULL;
-@@ -626,7 +638,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
+@@ -627,7 +639,7 @@ int qemu_peek_byte(QEMUFile *f, int offset)
int index = f->buf_index + offset;
assert(!qemu_file_is_writable(f));
@@ -143,7 +143,7 @@ index 6338d8e2ff..6697a93a7e 100644
if (index >= f->buf_size) {
qemu_fill_buffer(f);
-@@ -778,7 +790,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
+@@ -779,7 +791,7 @@ static int qemu_compress_data(z_stream *stream, uint8_t *dest, size_t dest_len,
ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream,
const uint8_t *p, size_t size)
{
diff --git a/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch b/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
index 9a17710..a0cc957 100644
--- a/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
+++ b/debian/patches/pve/0018-PVE-block-add-the-zeroinit-block-driver-filter.patch
@@ -13,10 +13,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
create mode 100644 block/zeroinit.c
diff --git a/block/meson.build b/block/meson.build
-index deb73ca389..c9d1fdca7d 100644
+index 0b2a60c99b..9451fc3ccd 100644
--- a/block/meson.build
+++ b/block/meson.build
-@@ -41,6 +41,7 @@ block_ss.add(files(
+@@ -43,6 +43,7 @@ block_ss.add(files(
'vmdk.c',
'vpc.c',
'write-threshold.c',
diff --git a/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch b/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
index be8407b..488a70c 100644
--- a/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
+++ b/debian/patches/pve/0019-PVE-Add-dummy-id-command-line-parameter.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 11 insertions(+)
diff --git a/qemu-options.hx b/qemu-options.hx
-index 423144abeb..4879471aeb 100644
+index aeade4ef80..a26f0b0400 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
-@@ -1019,6 +1019,9 @@ DEFHEADING()
+@@ -1075,6 +1075,9 @@ DEFHEADING()
DEFHEADING(Block device options:)
@@ -28,10 +28,10 @@ index 423144abeb..4879471aeb 100644
"-fda/-fdb file use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL)
DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL)
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index fd82efb8b3..eb05e5a000 100644
+index a3f2a3818c..4208142685 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -2779,6 +2779,7 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -2785,6 +2785,7 @@ void qemu_init(int argc, char **argv, char **envp)
MachineClass *machine_class;
bool userconfig = true;
FILE *vmstate_dump_file = NULL;
@@ -39,7 +39,7 @@ index fd82efb8b3..eb05e5a000 100644
qemu_add_opts(&qemu_drive_opts);
qemu_add_drive_opts(&qemu_legacy_drive_opts);
-@@ -3421,6 +3422,13 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3420,6 +3421,13 @@ void qemu_init(int argc, char **argv, char **envp)
machine_parse_property_opt(qemu_find_opts("smp-opts"),
"smp", optarg);
break;
diff --git a/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch b/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
index 1d758aa..99299d3 100644
--- a/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
+++ b/debian/patches/pve/0021-PVE-Up-Config-file-posix-make-locking-optiono-on-cre.patch
@@ -13,10 +13,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
-index 821405fd02..e3b6c3c524 100644
+index e5bf5d59bf..b013668dce 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
-@@ -2465,6 +2465,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2461,6 +2461,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
int fd;
uint64_t perm, shared;
int result = 0;
@@ -24,7 +24,7 @@ index 821405fd02..e3b6c3c524 100644
/* Validate options and set default values */
assert(options->driver == BLOCKDEV_DRIVER_FILE);
-@@ -2505,19 +2506,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2501,19 +2502,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
perm = BLK_PERM_WRITE | BLK_PERM_RESIZE;
shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
@@ -59,7 +59,7 @@ index 821405fd02..e3b6c3c524 100644
}
/* Clear the file by truncating it to 0 */
-@@ -2571,13 +2575,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
+@@ -2567,13 +2571,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
}
out_unlock:
@@ -82,7 +82,7 @@ index 821405fd02..e3b6c3c524 100644
}
out_close:
-@@ -2602,6 +2608,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2598,6 +2604,7 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
PreallocMode prealloc;
char *buf = NULL;
Error *local_err = NULL;
@@ -90,7 +90,7 @@ index 821405fd02..e3b6c3c524 100644
/* Skip file: protocol prefix */
strstart(filename, "file:", &filename);
-@@ -2624,6 +2631,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2620,6 +2627,18 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
return -EINVAL;
}
@@ -109,7 +109,7 @@ index 821405fd02..e3b6c3c524 100644
options = (BlockdevCreateOptions) {
.driver = BLOCKDEV_DRIVER_FILE,
.u.file = {
-@@ -2635,6 +2654,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
+@@ -2631,6 +2650,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
.nocow = nocow,
.has_extent_size_hint = has_extent_size_hint,
.extent_size_hint = extent_size_hint,
@@ -119,10 +119,10 @@ index 821405fd02..e3b6c3c524 100644
};
return raw_co_create(&options, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 1d3dd9cb48..3f81d6a5c0 100644
+index fb25c2b245..564b6b43f7 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -4445,7 +4445,8 @@
+@@ -4484,7 +4484,8 @@
'size': 'size',
'*preallocation': 'PreallocMode',
'*nocow': 'bool',
diff --git a/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch b/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
index 867084d..61528fd 100644
--- a/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
+++ b/debian/patches/pve/0023-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
@@ -26,10 +26,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
-index 53a99abc56..ad2cb2592e 100644
+index 1e23fdc14b..8a50445ee8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
-@@ -113,7 +113,8 @@ GlobalProperty hw_compat_4_0[] = {
+@@ -118,7 +118,8 @@ GlobalProperty hw_compat_4_0[] = {
{ "virtio-vga", "edid", "false" },
{ "virtio-gpu-device", "edid", "false" },
{ "virtio-device", "use-started", "false" },
diff --git a/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch b/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
index 5656e1f..a0ca907 100644
--- a/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
+++ b/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
@@ -36,10 +36,10 @@ index 76fff60a6b..ec9201fb9a 100644
if (mc->default_cpu_type) {
diff --git a/include/hw/boards.h b/include/hw/boards.h
-index 9c1c190104..51e04bde62 100644
+index c92ac8815c..572d911ed4 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
-@@ -227,6 +227,8 @@ struct MachineClass {
+@@ -230,6 +230,8 @@ struct MachineClass {
const char *desc;
const char *deprecation_reason;
@@ -49,10 +49,10 @@ index 9c1c190104..51e04bde62 100644
void (*reset)(MachineState *state);
void (*wakeup)(MachineState *state);
diff --git a/qapi/machine.json b/qapi/machine.json
-index 0905618e25..a05c46e253 100644
+index ca133e68ce..39ba204b52 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
-@@ -160,6 +160,8 @@
+@@ -158,6 +158,8 @@
#
# @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
#
@@ -61,7 +61,7 @@ index 0905618e25..a05c46e253 100644
# Since: 1.2
##
{ 'struct': 'MachineInfo',
-@@ -167,7 +169,7 @@
+@@ -165,7 +167,7 @@
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
'deprecated': 'bool', '*default-cpu-type': 'str',
@@ -71,10 +71,10 @@ index 0905618e25..a05c46e253 100644
##
# @query-machines:
diff --git a/softmmu/vl.c b/softmmu/vl.c
-index eb05e5a000..f306d21d63 100644
+index 4208142685..37d85f1b96 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
-@@ -1655,6 +1655,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
+@@ -1659,6 +1659,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
static MachineClass *select_machine(QDict *qdict, Error **errp)
{
const char *optarg = qdict_get_try_str(qdict, "type");
@@ -82,7 +82,7 @@ index eb05e5a000..f306d21d63 100644
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
MachineClass *machine_class;
Error *local_err = NULL;
-@@ -1672,6 +1673,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
+@@ -1676,6 +1677,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
}
}
@@ -94,7 +94,7 @@ index eb05e5a000..f306d21d63 100644
g_slist_free(machines);
if (local_err) {
error_append_hint(&local_err, "Use -machine help to list supported machines\n");
-@@ -3363,12 +3369,31 @@ void qemu_init(int argc, char **argv, char **envp)
+@@ -3362,12 +3368,31 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_machine:
{
bool help;
diff --git a/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch b/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
index 5d2679c..8621cdf 100644
--- a/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
+++ b/debian/patches/pve/0025-block-backup-move-bcs-bitmap-initialization-to-job-c.patch
@@ -25,7 +25,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/backup.c b/block/backup.c
-index 21d5983779..47e218857d 100644
+index 5cfd0b999c..07b899035c 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -239,8 +239,8 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
@@ -48,7 +48,7 @@ index 21d5983779..47e218857d 100644
if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
int64_t offset = 0;
int64_t count;
-@@ -493,6 +491,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
+@@ -494,6 +492,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
&error_abort);
diff --git a/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch
index b37b17c..ced8e74 100644
--- a/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch
+++ b/debian/patches/pve/0026-PVE-Backup-add-vma-backup-format-code.patch
@@ -10,20 +10,20 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
block/meson.build | 2 +
meson.build | 5 +
vma-reader.c | 860 ++++++++++++++++++++++++++++++++++++++++++++++
- vma-writer.c | 790 ++++++++++++++++++++++++++++++++++++++++++
- vma.c | 849 +++++++++++++++++++++++++++++++++++++++++++++
+ vma-writer.c | 791 ++++++++++++++++++++++++++++++++++++++++++
+ vma.c | 850 +++++++++++++++++++++++++++++++++++++++++++++
vma.h | 150 ++++++++
- 6 files changed, 2656 insertions(+)
+ 6 files changed, 2658 insertions(+)
create mode 100644 vma-reader.c
create mode 100644 vma-writer.c
create mode 100644 vma.c
create mode 100644 vma.h
diff --git a/block/meson.build b/block/meson.build
-index c9d1fdca7d..72081a9974 100644
+index 9451fc3ccd..819eb80951 100644
--- a/block/meson.build
+++ b/block/meson.build
-@@ -44,6 +44,8 @@ block_ss.add(files(
+@@ -46,6 +46,8 @@ block_ss.add(files(
'zeroinit.c',
), zstd, zlib, gnutls)
@@ -31,12 +31,12 @@ index c9d1fdca7d..72081a9974 100644
+
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
- block_ss.add(when: 'CONFIG_QCOW1', if_true: files('qcow.c'))
+ if get_option('qcow1').allowed()
diff --git a/meson.build b/meson.build
-index 96de1a6ef9..54c23b9567 100644
+index 861de93c4f..96a91b95e4 100644
--- a/meson.build
+++ b/meson.build
-@@ -1202,6 +1202,8 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1267,6 +1267,8 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
@@ -45,7 +45,7 @@ index 96de1a6ef9..54c23b9567 100644
# libselinux
selinux = dependency('libselinux',
required: get_option('selinux'),
-@@ -3070,6 +3072,9 @@ if have_tools
+@@ -3359,6 +3361,9 @@ if have_tools
dependencies: [blockdev, qemuutil, gnutls, selinux],
install: true)
@@ -923,10 +923,10 @@ index 0000000000..4f4ee2b47b
+
diff --git a/vma-writer.c b/vma-writer.c
new file mode 100644
-index 0000000000..11d8321ffd
+index 0000000000..df4b20793d
--- /dev/null
+++ b/vma-writer.c
-@@ -0,0 +1,790 @@
+@@ -0,0 +1,791 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -950,6 +950,7 @@ index 0000000000..11d8321ffd
+#include "qemu/main-loop.h"
+#include "qemu/coroutine.h"
+#include "qemu/cutils.h"
++#include "qemu/memalign.h"
+
+#define DEBUG_VMA 0
+
@@ -1133,9 +1134,9 @@ index 0000000000..11d8321ffd
+ assert(qemu_in_coroutine());
+ AioContext *ctx = qemu_get_current_aio_context();
+ aio_set_fd_handler(ctx, fd, false, NULL, (IOHandler *)qemu_coroutine_enter,
-+ NULL, qemu_coroutine_self());
++ NULL, NULL, qemu_coroutine_self());
+ qemu_coroutine_yield();
-+ aio_set_fd_handler(ctx, fd, false, NULL, NULL, NULL, NULL);
++ aio_set_fd_handler(ctx, fd, false, NULL, NULL, NULL, NULL, NULL);
+}
+
+static ssize_t coroutine_fn
@@ -1719,10 +1720,10 @@ index 0000000000..11d8321ffd
+}
diff --git a/vma.c b/vma.c
new file mode 100644
-index 0000000000..89440733b1
+index 0000000000..91612d50a2
--- /dev/null
+++ b/vma.c
-@@ -0,0 +1,849 @@
+@@ -0,0 +1,850 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -1745,6 +1746,7 @@ index 0000000000..89440733b1
+#include "qemu/error-report.h"
+#include "qemu/main-loop.h"
+#include "qemu/cutils.h"
++#include "qemu/memalign.h"
+#include "qapi/qmp/qdict.h"
+#include "sysemu/block-backend.h"
+
diff --git a/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch b/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
index 4b57124..ea3bb84 100644
--- a/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
+++ b/debian/patches/pve/0027-PVE-Backup-add-backup-dump-block-driver.patch
@@ -10,11 +10,11 @@ Subject: [PATCH] PVE-Backup: add backup-dump block driver
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
- block/backup-dump.c | 168 ++++++++++++++++++++++++++++++++++++++
- block/backup.c | 30 ++-----
- block/meson.build | 1 +
- include/block/block_int.h | 35 ++++++++
- job.c | 3 +-
+ block/backup-dump.c | 168 +++++++++++++++++++++++++++++++
+ block/backup.c | 30 ++----
+ block/meson.build | 1 +
+ include/block/block_int-common.h | 35 +++++++
+ job.c | 3 +-
5 files changed, 214 insertions(+), 23 deletions(-)
create mode 100644 block/backup-dump.c
@@ -193,7 +193,7 @@ index 0000000000..93d7f46950
+ return bs;
+}
diff --git a/block/backup.c b/block/backup.c
-index 47e218857d..4d8fad70c4 100644
+index 07b899035c..7b5d02f580 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -29,28 +29,6 @@
@@ -225,7 +225,7 @@ index 47e218857d..4d8fad70c4 100644
static const BlockJobDriver backup_job_driver;
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
-@@ -455,6 +433,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
+@@ -456,6 +434,14 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
}
cluster_size = block_copy_cluster_size(bcs);
@@ -241,7 +241,7 @@ index 47e218857d..4d8fad70c4 100644
if (perf->max_chunk && perf->max_chunk < cluster_size) {
error_setg(errp, "Required max-chunk (%" PRIi64 ") is less than backup "
diff --git a/block/meson.build b/block/meson.build
-index 72081a9974..7883df047c 100644
+index 819eb80951..067708b7c0 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -4,6 +4,7 @@ block_ss.add(files(
@@ -252,10 +252,10 @@ index 72081a9974..7883df047c 100644
'copy-before-write.c',
'blkdebug.c',
'blklogwrites.c',
-diff --git a/include/block/block_int.h b/include/block/block_int.h
-index f4c75e8ba9..169dc43d59 100644
---- a/include/block/block_int.h
-+++ b/include/block/block_int.h
+diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
+index 8947abab76..f272d0d8dc 100644
+--- a/include/block/block_int-common.h
++++ b/include/block/block_int-common.h
@@ -26,6 +26,7 @@
#include "block/accounting.h"
@@ -270,7 +270,7 @@ index f4c75e8ba9..169dc43d59 100644
+typedef int BackupDumpFunc(void *opaque, uint64_t offset, uint64_t bytes, const void *buf);
+
-+BlockDriverState *bdrv_backuo_dump_create(
++BlockDriverState *bdrv_backup_dump_create(
+ int dump_cb_block_size,
+ uint64_t byte_size,
+ BackupDumpFunc *dump_cb,
@@ -306,7 +306,7 @@ index f4c75e8ba9..169dc43d59 100644
BDRV_TRACKED_READ,
BDRV_TRACKED_WRITE,
diff --git a/job.c b/job.c
-index dbfa67bb0a..af25dd5b98 100644
+index 075c6f3a20..e5699ad200 100644
--- a/job.c
+++ b/job.c
@@ -276,7 +276,8 @@ static bool job_started(Job *job)
diff --git a/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch b/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
index c081345..faa9483 100644
--- a/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
+++ b/debian/patches/pve/0028-PVE-Backup-proxmox-backup-patches-for-qemu.patch
@@ -15,7 +15,6 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
blockdev.c | 1 +
hmp-commands-info.hx | 14 +
hmp-commands.hx | 29 +
- include/block/block_int.h | 2 +-
include/monitor/hmp.h | 3 +
meson.build | 1 +
monitor/hmp-cmds.c | 44 ++
@@ -25,16 +24,16 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
qapi/block-core.json | 109 ++++
qapi/common.json | 13 +
qapi/machine.json | 15 +-
- 15 files changed, 1449 insertions(+), 14 deletions(-)
+ 14 files changed, 1448 insertions(+), 13 deletions(-)
create mode 100644 proxmox-backup-client.c
create mode 100644 proxmox-backup-client.h
create mode 100644 pve-backup.c
diff --git a/block/meson.build b/block/meson.build
-index 7883df047c..9d3dd5b7c3 100644
+index 067708b7c0..42aac96dbb 100644
--- a/block/meson.build
+++ b/block/meson.build
-@@ -46,6 +46,11 @@ block_ss.add(files(
+@@ -48,6 +48,11 @@ block_ss.add(files(
), zstd, zlib, gnutls)
block_ss.add(files('../vma-writer.c'), libuuid)
@@ -47,7 +46,7 @@ index 7883df047c..9d3dd5b7c3 100644
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 2ac4aedfff..f6668ab01d 100644
+index bfb3c043a0..89ca64444d 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1015,3 +1015,36 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
@@ -88,7 +87,7 @@ index 2ac4aedfff..f6668ab01d 100644
+ hmp_handle_error(mon, error);
+}
diff --git a/blockdev.c b/blockdev.c
-index b35072644e..c0bc3db33e 100644
+index 1af5a1fcb2..9916a72334 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -36,6 +36,7 @@
@@ -100,10 +99,10 @@ index b35072644e..c0bc3db33e 100644
#include "monitor/monitor.h"
#include "qemu/error-report.h"
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
-index 245f8acc55..3e7f2421eb 100644
+index 925e680e5a..d9b787d2c6 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
-@@ -482,6 +482,20 @@ SRST
+@@ -484,6 +484,20 @@ SRST
Show the current VM UUID.
ERST
@@ -125,7 +124,7 @@ index 245f8acc55..3e7f2421eb 100644
{
.name = "usernet",
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 1ad13b668b..d4bb00216e 100644
+index 7f0ac498c4..994445f301 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -99,6 +99,35 @@ ERST
@@ -164,19 +163,6 @@ index 1ad13b668b..d4bb00216e 100644
ERST
{
-diff --git a/include/block/block_int.h b/include/block/block_int.h
-index 169dc43d59..92f90c43eb 100644
---- a/include/block/block_int.h
-+++ b/include/block/block_int.h
-@@ -67,7 +67,7 @@
-
- typedef int BackupDumpFunc(void *opaque, uint64_t offset, uint64_t bytes, const void *buf);
-
--BlockDriverState *bdrv_backuo_dump_create(
-+BlockDriverState *bdrv_backup_dump_create(
- int dump_cb_block_size,
- uint64_t byte_size,
- BackupDumpFunc *dump_cb,
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 3a39ba41b5..d269b4c99c 100644
--- a/include/monitor/hmp.h
@@ -199,10 +185,10 @@ index 3a39ba41b5..d269b4c99c 100644
void hmp_device_add(Monitor *mon, const QDict *qdict);
void hmp_device_del(Monitor *mon, const QDict *qdict);
diff --git a/meson.build b/meson.build
-index 54c23b9567..37dab249cc 100644
+index 96a91b95e4..76fcb23299 100644
--- a/meson.build
+++ b/meson.build
-@@ -1203,6 +1203,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1268,6 +1268,7 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
libuuid = cc.find_library('uuid', required: true)
@@ -211,7 +197,7 @@ index 54c23b9567..37dab249cc 100644
# libselinux
selinux = dependency('libselinux',
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index 5000ce39d1..b2687eae3a 100644
+index c64b959738..ef654221c4 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -195,6 +195,50 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
@@ -1478,7 +1464,7 @@ index 0000000000..88f5ee133f
+ return info;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 3f81d6a5c0..551ee28275 100644
+index 564b6b43f7..ffcc25367b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -744,6 +744,115 @@
@@ -1619,7 +1605,7 @@ index 412cc4f5ae..3e7a77ea66 100644
+##
+{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
diff --git a/qapi/machine.json b/qapi/machine.json
-index a05c46e253..e2cec7922f 100644
+index 39ba204b52..091aafeff7 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -4,6 +4,8 @@
@@ -1631,7 +1617,7 @@ index a05c46e253..e2cec7922f 100644
##
# = Machines
##
-@@ -229,19 +231,6 @@
+@@ -227,19 +229,6 @@
##
{ 'command': 'query-target', 'returns': 'TargetInfo' }
diff --git a/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch b/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
index 132d390..f1c77cb 100644
--- a/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
+++ b/debian/patches/pve/0029-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
@@ -12,10 +12,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
create mode 100644 pbs-restore.c
diff --git a/meson.build b/meson.build
-index 37dab249cc..1a4dfab4e2 100644
+index 76fcb23299..9476ccbe07 100644
--- a/meson.build
+++ b/meson.build
-@@ -3076,6 +3076,10 @@ if have_tools
+@@ -3365,6 +3365,10 @@ if have_tools
vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
dependencies: [authz, block, crypto, io, qom], install: true)
diff --git a/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch b/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
index 4c45d91..012c0b3 100644
--- a/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
+++ b/debian/patches/pve/0030-PVE-Backup-Add-dirty-bitmap-tracking-for-incremental.patch
@@ -29,7 +29,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 files changed, 142 insertions(+), 23 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index f6668ab01d..3c06734e6d 100644
+index 89ca64444d..45da74d7a0 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1042,6 +1042,7 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
@@ -41,7 +41,7 @@ index f6668ab01d..3c06734e6d 100644
false, NULL, false, NULL, !!devlist,
devlist, qdict_haskey(qdict, "speed"), speed, &error);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index b2687eae3a..cfd7a60f32 100644
+index ef654221c4..c5c74ac1dc 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -221,19 +221,42 @@ void hmp_info_backup(Monitor *mon, const QDict *qdict)
@@ -405,7 +405,7 @@ index 88f5ee133f..1c49cd178d 100644
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 551ee28275..b9d6f52f0c 100644
+index ffcc25367b..b332d8a8da 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -757,8 +757,13 @@
diff --git a/debian/patches/pve/0031-PVE-various-PBS-fixes.patch b/debian/patches/pve/0031-PVE-various-PBS-fixes.patch
index d3a7334..e5ebc18 100644
--- a/debian/patches/pve/0031-PVE-various-PBS-fixes.patch
+++ b/debian/patches/pve/0031-PVE-various-PBS-fixes.patch
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 54 insertions(+), 13 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 3c06734e6d..4481b60a5c 100644
+index 45da74d7a0..ea7b665aa2 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1042,7 +1042,9 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
@@ -194,7 +194,7 @@ index 1c49cd178d..c15abefdda 100644
.format = format,
.has_config_file = has_config_file,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index b9d6f52f0c..5d8e2eb303 100644
+index b332d8a8da..abef91062a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -822,6 +822,10 @@
diff --git a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch b/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
index b3ea6b5..3b08ed1 100644
--- a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+++ b/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
@@ -19,10 +19,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
create mode 100644 block/pbs.c
diff --git a/block/meson.build b/block/meson.build
-index 9d3dd5b7c3..8c758c0218 100644
+index 42aac96dbb..f94cc0cd25 100644
--- a/block/meson.build
+++ b/block/meson.build
-@@ -51,6 +51,9 @@ block_ss.add(files(
+@@ -53,6 +53,9 @@ block_ss.add(files(
'../pve-backup.c',
), libproxmox_backup_qemu)
@@ -315,20 +315,20 @@ index 0000000000..0b05ea9080
+
+block_init(bdrv_pbs_init);
diff --git a/configure b/configure
-index 48c21775f3..eda4e9225a 100755
+index 7c08c18358..08d164b4f5 100755
--- a/configure
+++ b/configure
-@@ -356,6 +356,7 @@ vdi=${default_feature:-yes}
- vvfat=${default_feature:-yes}
- qed=${default_feature:-yes}
- parallels=${default_feature:-yes}
+@@ -325,6 +325,7 @@ trace_file="trace"
+ opengl="$default_feature"
+ coroutine=""
+ tls_priority="NORMAL"
+pbs_bdrv="yes"
- debug_mutex="no"
plugins="$default_feature"
- rng_none="no"
-@@ -1126,6 +1127,10 @@ for opt do
+ secret_keyring="$default_feature"
+ meson=""
+@@ -991,6 +992,10 @@ for opt do
;;
- --enable-parallels) parallels="yes"
+ --disable-pvrdma) pvrdma="no"
;;
+ --disable-pbs-bdrv) pbs_bdrv="no"
+ ;;
@@ -337,15 +337,15 @@ index 48c21775f3..eda4e9225a 100755
--disable-vhost-user) vhost_user="no"
;;
--enable-vhost-user) vhost_user="yes"
-@@ -1465,6 +1470,7 @@ cat << EOF
- vvfat vvfat image format support
- qed qed image format support
- parallels parallels image format support
+@@ -1265,6 +1270,7 @@ cat << EOF
+ vhost-user vhost-user backend support
+ vhost-vdpa vhost-vdpa kernel backend support
+ opengl opengl support
+ pbs-bdrv Proxmox backup server read-only block driver support
- crypto-afalg Linux AF_ALG crypto backend driver
- debug-mutex mutex debugging support
- rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
-@@ -3534,6 +3540,9 @@ if test "$xen" = "enabled" ; then
+ gio libgio support
+
+ NOTE: The object files are built at the place where configure is launched
+@@ -2848,6 +2854,9 @@ if test "$xen" = "enabled" ; then
echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
echo "XEN_LIBS=$xen_libs" >> $config_host_mak
fi
@@ -356,22 +356,22 @@ index 48c21775f3..eda4e9225a 100755
echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
fi
diff --git a/meson.build b/meson.build
-index 1a4dfab4e2..85b3c63199 100644
+index 9476ccbe07..d3783a83e4 100644
--- a/meson.build
+++ b/meson.build
-@@ -3448,6 +3448,7 @@ summary_info += {'lzfse support': liblzfse}
+@@ -3743,6 +3743,7 @@ summary_info += {'bzip2 support': libbzip2}
+ summary_info += {'lzfse support': liblzfse}
summary_info += {'zstd support': zstd}
- summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
- summary_info += {'libxml2': libxml2}
+ summary_info += {'NUMA host support': numa}
+summary_info += {'PBS bdrv support': config_host.has_key('CONFIG_PBS_BDRV')}
summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
summary_info += {'libpmem support': libpmem}
summary_info += {'libdaxctl support': libdaxctl}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 5d8e2eb303..777863e33b 100644
+index abef91062a..68591cb343 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
-@@ -3053,6 +3053,7 @@
+@@ -3073,6 +3073,7 @@
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
@@ -379,7 +379,7 @@ index 5d8e2eb303..777863e33b 100644
'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
##
-@@ -3125,6 +3126,17 @@
+@@ -3145,6 +3146,17 @@
{ 'struct': 'BlockdevOptionsNull',
'data': { '*size': 'int', '*latency-ns': 'uint64', '*read-zeroes': 'bool' } }
@@ -397,7 +397,7 @@ index 5d8e2eb303..777863e33b 100644
##
# @BlockdevOptionsNVMe:
#
-@@ -4367,6 +4379,7 @@
+@@ -4405,6 +4417,7 @@
'nfs': 'BlockdevOptionsNfs',
'null-aio': 'BlockdevOptionsNull',
'null-co': 'BlockdevOptionsNull',
diff --git a/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch b/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
index 3df9eb6..0f1f0c6 100644
--- a/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
+++ b/debian/patches/pve/0033-PVE-add-query_proxmox_support-QMP-command.patch
@@ -33,7 +33,7 @@ index c15abefdda..4684789813 100644
+ return ret;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 777863e33b..cfd980b70f 100644
+index 68591cb343..7d25aa4fa1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -867,6 +867,35 @@
diff --git a/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch b/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
index 54b268f..d3ba75c 100644
--- a/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
+++ b/debian/patches/pve/0034-PVE-add-query-pbs-bitmap-info-QMP-call.patch
@@ -15,7 +15,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 159 insertions(+), 42 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
-index cfd7a60f32..b613190a3c 100644
+index c5c74ac1dc..df273f41fb 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -198,6 +198,7 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
@@ -359,7 +359,7 @@ index 4684789813..f90abaa50a 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index cfd980b70f..8833060385 100644
+index 7d25aa4fa1..69571d86eb 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -875,6 +875,8 @@
diff --git a/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch b/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
index 9085387..89727a4 100644
--- a/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
+++ b/debian/patches/pve/0035-PVE-redirect-stderr-to-journal-when-daemonized.patch
@@ -14,10 +14,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
-index 85b3c63199..31ba7d70d6 100644
+index d3783a83e4..715245ba20 100644
--- a/meson.build
+++ b/meson.build
-@@ -1203,6 +1203,7 @@ keyutils = dependency('libkeyutils', required: false,
+@@ -1268,6 +1268,7 @@ keyutils = dependency('libkeyutils', required: false,
has_gettid = cc.has_function('gettid')
libuuid = cc.find_library('uuid', required: true)
@@ -25,7 +25,7 @@ index 85b3c63199..31ba7d70d6 100644
libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
# libselinux
-@@ -2571,6 +2572,7 @@ if have_block
+@@ -2861,6 +2862,7 @@ if have_block
# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
# os-win32.c does not
blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
@@ -34,7 +34,7 @@ index 85b3c63199..31ba7d70d6 100644
endif
diff --git a/os-posix.c b/os-posix.c
-index ae6c9f2a5e..36807806bf 100644
+index 24692c8593..d1bc5ac12d 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -28,6 +28,8 @@
diff --git a/debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch b/debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch
index 3a56d3c..b85b914 100644
--- a/debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch
+++ b/debian/patches/pve/0036-PVE-Add-sequential-job-transaction-support.patch
@@ -11,10 +11,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 files changed, 43 insertions(+)
diff --git a/include/qemu/job.h b/include/qemu/job.h
-index 6e67b6977f..60376c99ee 100644
+index c105b31076..5096679571 100644
--- a/include/qemu/job.h
+++ b/include/qemu/job.h
-@@ -294,6 +294,18 @@ typedef enum JobCreateFlags {
+@@ -316,6 +316,18 @@ typedef enum JobCreateFlags {
*/
JobTxn *job_txn_new(void);
@@ -34,7 +34,7 @@ index 6e67b6977f..60376c99ee 100644
* Release a reference that was previously acquired with job_txn_add_job or
* job_txn_new. If it's the last reference to the object, it will be freed.
diff --git a/job.c b/job.c
-index af25dd5b98..d0d152e697 100644
+index e5699ad200..34c9758349 100644
--- a/job.c
+++ b/job.c
@@ -72,6 +72,8 @@ struct JobTxn {
@@ -72,7 +72,7 @@ index af25dd5b98..d0d152e697 100644
static void job_txn_ref(JobTxn *txn)
{
txn->refcnt++;
-@@ -888,6 +909,9 @@ static void job_completed_txn_success(Job *job)
+@@ -897,6 +918,9 @@ static void job_completed_txn_success(Job *job)
*/
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
if (!job_is_completed(other_job)) {
@@ -82,7 +82,7 @@ index af25dd5b98..d0d152e697 100644
return;
}
assert(other_job->ret == 0);
-@@ -1082,6 +1106,13 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
+@@ -1093,6 +1117,13 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
return -EBUSY;
}
diff --git a/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch b/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
index 0367445..51a2b53 100644
--- a/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
+++ b/debian/patches/pve/0038-PVE-Backup-Don-t-block-on-finishing-and-cleanup-crea.patch
@@ -481,7 +481,7 @@ index 63c686463f..6f05796fad 100644
qemu_mutex_unlock(&backup_state.stat.lock);
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 8833060385..6a67adf923 100644
+index 69571d86eb..e6c3687bea 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -774,12 +774,15 @@
diff --git a/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
index 2463eb6..36c6d96 100644
--- a/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+++ b/debian/patches/pve/0039-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
@@ -36,7 +36,7 @@ index 465906710d..4f0aeceb6f 100644
+
#endif
diff --git a/migration/meson.build b/migration/meson.build
-index ea9aedeefc..c27dc9bd97 100644
+index 1e2aec8486..259e863a43 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -7,8 +7,10 @@ migration_files = files(
@@ -51,10 +51,10 @@ index ea9aedeefc..c27dc9bd97 100644
softmmu_ss.add(files(
'block-dirty-bitmap.c',
diff --git a/migration/migration.c b/migration/migration.c
-index abaf6f9e3d..d925fd7488 100644
+index 695f0f2900..6e17f8e91c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
-@@ -213,6 +213,7 @@ void migration_object_init(void)
+@@ -214,6 +214,7 @@ void migration_object_init(void)
blk_mig_init();
ram_mig_init();
dirty_bitmap_mig_init();
@@ -187,7 +187,7 @@ index 6f05796fad..5fa3cc1352 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 6a67adf923..c99ddf8628 100644
+index e6c3687bea..05382a1069 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -883,6 +883,11 @@
diff --git a/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch b/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
index ae11626..c30bb2b 100644
--- a/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
+++ b/debian/patches/pve/0041-PVE-fall-back-to-open-iscsi-initiatorname.patch
@@ -21,7 +21,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 30 insertions(+)
diff --git a/block/iscsi.c b/block/iscsi.c
-index 57aa07a40d..a8902b84d5 100644
+index 51f2a5eeaa..f11591ac94 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1386,12 +1386,42 @@ static char *get_initiator_name(QemuOpts *opts)
diff --git a/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch b/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
index fc78bfb..3de10a6 100644
--- a/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
+++ b/debian/patches/pve/0042-PVE-Use-coroutine-QMP-for-backup-cancel_backup.patch
@@ -32,7 +32,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 files changed, 77 insertions(+), 196 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 4481b60a5c..c9849a5b29 100644
+index ea7b665aa2..ef45552e3b 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1016,7 +1016,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
@@ -54,7 +54,7 @@ index 4481b60a5c..c9849a5b29 100644
Error *error = NULL;
diff --git a/hmp-commands.hx b/hmp-commands.hx
-index d4bb00216e..4e21911fa6 100644
+index 994445f301..aaea875970 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -109,6 +109,7 @@ ERST
@@ -575,7 +575,7 @@ index 5fa3cc1352..323014744c 100644
BackupStatus *qmp_query_backup(Error **errp)
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index c99ddf8628..829dc7b8e9 100644
+index 05382a1069..f0399bf249 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -846,7 +846,7 @@
diff --git a/debian/patches/pve/0043-PBS-add-master-key-support.patch b/debian/patches/pve/0043-PBS-add-master-key-support.patch
index eeaf6ba..356cfd9 100644
--- a/debian/patches/pve/0043-PBS-add-master-key-support.patch
+++ b/debian/patches/pve/0043-PBS-add-master-key-support.patch
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 11 insertions(+)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index c9849a5b29..52ddbf95ad 100644
+index ef45552e3b..4c799f00d9 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1039,6 +1039,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
@@ -58,7 +58,7 @@ index 323014744c..9f6c04a512 100644
return ret;
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index 829dc7b8e9..d089328a1f 100644
+index f0399bf249..13e03ca154 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -817,6 +817,8 @@
diff --git a/debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch b/debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch
index fe0ec25..09e8d31 100644
--- a/debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch
+++ b/debian/patches/pve/0045-PVE-block-stream-increase-chunk-size.patch
@@ -11,7 +11,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/stream.c b/block/stream.c
-index e45113aed6..c3c0c5febe 100644
+index 694709bd25..e09bd5c4ef 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -28,7 +28,7 @@ enum {
diff --git a/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch b/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
index 49f0f9d..d1d30b1 100644
--- a/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
+++ b/debian/patches/pve/0046-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch
@@ -17,10 +17,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+)
diff --git a/block/io.c b/block/io.c
-index 4e4cb556c5..04061f1e68 100644
+index 3280144a17..cd7ba08768 100644
--- a/block/io.c
+++ b/block/io.c
-@@ -1765,6 +1765,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
+@@ -1794,6 +1794,10 @@ static int bdrv_pad_request(BlockDriverState *bs,
{
int ret;
diff --git a/debian/patches/pve/0047-block-add-alloc-track-driver.patch b/debian/patches/pve/0047-block-add-alloc-track-driver.patch
index 71790d8..1cf88ab 100644
--- a/debian/patches/pve/0047-block-add-alloc-track-driver.patch
+++ b/debian/patches/pve/0047-block-add-alloc-track-driver.patch
@@ -389,7 +389,7 @@ index 0000000000..6b50fbe537
+
+block_init(bdrv_alloc_track_init);
diff --git a/block/meson.build b/block/meson.build
-index 8c758c0218..45b72e10f1 100644
+index f94cc0cd25..1716febb1d 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -2,6 +2,7 @@ block_ss.add(genh)
diff --git a/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch b/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
index ced1323..0496b93 100644
--- a/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
+++ b/debian/patches/pve/0048-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch
@@ -10,10 +10,10 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/qapi/pragma.json b/qapi/pragma.json
-index 7c91ea3685..c3888d654c 100644
+index 41139d8645..a581acf7d4 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
-@@ -12,6 +12,7 @@
+@@ -15,6 +15,7 @@
'device_add',
'device_del',
'expire_password',
@@ -21,7 +21,7 @@ index 7c91ea3685..c3888d654c 100644
'migrate_cancel',
'netdev_add',
'netdev_del',
-@@ -60,6 +61,8 @@
+@@ -63,6 +64,8 @@
'SysEmuTarget', # query-cpu-fast, query-target
'UuidInfo', # query-uuid
'VncClientInfo', # query-vnc, query-vnc-servers, ...
diff --git a/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch b/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
index 62c1711..9b7c51e 100644
--- a/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
+++ b/debian/patches/pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
@@ -12,7 +12,7 @@ Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
-index a49badb158..1039aec01c 100644
+index 33979b7430..68e9c80788 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -492,10 +492,10 @@ Command description:
@@ -30,7 +30,7 @@ index a49badb158..1039aec01c 100644
The data is by default read and written using blocks of 512 bytes but can be
modified by specifying *BLOCK_SIZE*. If count=\ *BLOCKS* is specified
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
-index f3b2b1b4de..e77ed9347f 100644
+index b5b0bb4467..36f97e1f19 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -58,9 +58,9 @@ SRST
@@ -46,10 +46,10 @@ index f3b2b1b4de..e77ed9347f 100644
DEF("info", img_info,
diff --git a/qemu-img.c b/qemu-img.c
-index 015d6d2ce4..7031195e32 100644
+index 35c2bdc95c..6e93bbd425 100644
--- a/qemu-img.c
+++ b/qemu-img.c
-@@ -4922,6 +4922,7 @@ static int img_dd(int argc, char **argv)
+@@ -4938,6 +4938,7 @@ static int img_dd(int argc, char **argv)
BlockDriver *drv = NULL, *proto_drv = NULL;
BlockBackend *blk1 = NULL, *blk2 = NULL;
QemuOpts *opts = NULL;
@@ -57,7 +57,7 @@ index 015d6d2ce4..7031195e32 100644
QemuOptsList *create_opts = NULL;
Error *local_err = NULL;
bool image_opts = false;
-@@ -4931,6 +4932,7 @@ static int img_dd(int argc, char **argv)
+@@ -4947,6 +4948,7 @@ static int img_dd(int argc, char **argv)
int64_t size = 0, readsize = 0;
int64_t block_count = 0, out_pos, in_pos;
bool force_share = false, skip_create = false;
@@ -65,7 +65,7 @@ index 015d6d2ce4..7031195e32 100644
struct DdInfo dd = {
.flags = 0,
.count = 0,
-@@ -4968,7 +4970,7 @@ static int img_dd(int argc, char **argv)
+@@ -4984,7 +4986,7 @@ static int img_dd(int argc, char **argv)
{ 0, 0, 0, 0 }
};
@@ -74,7 +74,7 @@ index 015d6d2ce4..7031195e32 100644
if (c == EOF) {
break;
}
-@@ -4991,6 +4993,19 @@ static int img_dd(int argc, char **argv)
+@@ -5007,6 +5009,19 @@ static int img_dd(int argc, char **argv)
case 'n':
skip_create = true;
break;
@@ -94,7 +94,7 @@ index 015d6d2ce4..7031195e32 100644
case 'U':
force_share = true;
break;
-@@ -5050,11 +5065,24 @@ static int img_dd(int argc, char **argv)
+@@ -5066,11 +5081,24 @@ static int img_dd(int argc, char **argv)
if (dd.flags & C_IF) {
blk1 = img_open(image_opts, in.filename, fmt, 0, false, false,
force_share);
@@ -120,7 +120,7 @@ index 015d6d2ce4..7031195e32 100644
}
if (dd.flags & C_OSIZE) {
-@@ -5203,6 +5231,7 @@ static int img_dd(int argc, char **argv)
+@@ -5219,6 +5247,7 @@ static int img_dd(int argc, char **argv)
out:
g_free(arg);
qemu_opts_del(opts);
diff --git a/debian/patches/pve/0051-vma-allow-partial-restore.patch b/debian/patches/pve/0051-vma-allow-partial-restore.patch
index 670eb68..ede4d67 100644
--- a/debian/patches/pve/0051-vma-allow-partial-restore.patch
+++ b/debian/patches/pve/0051-vma-allow-partial-restore.patch
@@ -166,10 +166,10 @@ index 4f4ee2b47b..844d95a5ba 100644
}
diff --git a/vma.c b/vma.c
-index 89440733b1..21e765a469 100644
+index 91612d50a2..e1a750ff50 100644
--- a/vma.c
+++ b/vma.c
-@@ -138,6 +138,7 @@ typedef struct RestoreMap {
+@@ -139,6 +139,7 @@ typedef struct RestoreMap {
char *throttling_group;
char *cache;
bool write_zero;
@@ -177,7 +177,7 @@ index 89440733b1..21e765a469 100644
} RestoreMap;
static bool try_parse_option(char **line, const char *optname, char **out, const char *inbuf) {
-@@ -245,47 +246,61 @@ static int extract_content(int argc, char **argv)
+@@ -246,47 +247,61 @@ static int extract_content(int argc, char **argv)
char *bps = NULL;
char *group = NULL;
char *cache = NULL;
@@ -265,7 +265,7 @@ index 89440733b1..21e765a469 100644
if (!devname) {
g_error("read map failed - no dev name specified ('%s')",
inbuf);
-@@ -299,6 +314,7 @@ static int extract_content(int argc, char **argv)
+@@ -300,6 +315,7 @@ static int extract_content(int argc, char **argv)
map->throttling_group = group;
map->cache = cache;
map->write_zero = write_zero;
@@ -273,7 +273,7 @@ index 89440733b1..21e765a469 100644
g_hash_table_insert(devmap, map->devname, map);
-@@ -328,6 +344,7 @@ static int extract_content(int argc, char **argv)
+@@ -329,6 +345,7 @@ static int extract_content(int argc, char **argv)
const char *cache = NULL;
int flags = BDRV_O_RDWR;
bool write_zero = true;
@@ -281,7 +281,7 @@ index 89440733b1..21e765a469 100644
BlockBackend *blk = NULL;
-@@ -343,6 +360,7 @@ static int extract_content(int argc, char **argv)
+@@ -344,6 +361,7 @@ static int extract_content(int argc, char **argv)
throttling_group = map->throttling_group;
cache = map->cache;
write_zero = map->write_zero;
@@ -289,7 +289,7 @@ index 89440733b1..21e765a469 100644
} else {
devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
dirname, di->devname);
-@@ -361,57 +379,60 @@ static int extract_content(int argc, char **argv)
+@@ -362,57 +380,60 @@ static int extract_content(int argc, char **argv)
write_zero = false;
}
diff --git a/debian/patches/pve/0052-pbs-namespace-support.patch b/debian/patches/pve/0052-pbs-namespace-support.patch
index 8d97602..67bda69 100644
--- a/debian/patches/pve/0052-pbs-namespace-support.patch
+++ b/debian/patches/pve/0052-pbs-namespace-support.patch
@@ -13,7 +13,7 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
-index 52ddbf95ad..69c868887a 100644
+index 4c799f00d9..0502f42be6 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -1041,6 +1041,7 @@ void coroutine_fn hmp_backup(Monitor *mon, const QDict *qdict)
@@ -202,7 +202,7 @@ index 9f6c04a512..f6a5f8c785 100644
backup_time,
dump_cb_block_size,
diff --git a/qapi/block-core.json b/qapi/block-core.json
-index d089328a1f..705f0c97ba 100644
+index 13e03ca154..89875f309c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -821,6 +821,8 @@
@@ -222,7 +222,7 @@ index d089328a1f..705f0c97ba 100644
'*backup-id': 'str',
'*backup-time': 'int',
'*use-dirty-bitmap': 'bool',
-@@ -3236,7 +3239,7 @@
+@@ -3256,7 +3259,7 @@
{ 'struct': 'BlockdevOptionsPbs',
'data': { 'repository': 'str', 'snapshot': 'str', 'archive': 'str',
'*keyfile': 'str', '*password': 'str', '*fingerprint': 'str',
diff --git a/debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch b/debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
new file mode 100644
index 0000000..4fd82ac
--- /dev/null
+++ b/debian/patches/pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
@@ -0,0 +1,80 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Fabian Ebner <f.ebner@proxmox.com>
+Date: Thu, 23 Jun 2022 14:00:05 +0200
+Subject: [PATCH] Revert "block/rbd: workaround for ceph issue #53784"
+
+This reverts commit fc176116cdea816ceb8dd969080b2b95f58edbc0 in
+preparation to revert 0347a8fd4c3faaedf119be04c197804be40a384b.
+
+Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
+---
+ block/rbd.c | 42 ++----------------------------------------
+ 1 file changed, 2 insertions(+), 40 deletions(-)
+
+diff --git a/block/rbd.c b/block/rbd.c
+index 0cec24c86d..0a9b97aa5e 100644
+--- a/block/rbd.c
++++ b/block/rbd.c
+@@ -1324,7 +1324,6 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+ int status, r;
+ RBDDiffIterateReq req = { .offs = offset };
+ uint64_t features, flags;
+- uint64_t head = 0;
+
+ assert(offset + bytes <= s->image_size);
+
+@@ -1352,43 +1351,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+ return status;
+ }
+
+-#if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 17, 0)
+- /*
+- * librbd had a bug until early 2022 that affected all versions of ceph that
+- * supported fast-diff. This bug results in reporting of incorrect offsets
+- * if the offset parameter to rbd_diff_iterate2 is not object aligned.
+- * Work around this bug by rounding down the offset to object boundaries.
+- * This is OK because we call rbd_diff_iterate2 with whole_object = true.
+- * However, this workaround only works for non cloned images with default
+- * striping.
+- *
+- * See: https://tracker.ceph.com/issues/53784
+- */
+-
+- /* check if RBD image has non-default striping enabled */
+- if (features & RBD_FEATURE_STRIPINGV2) {
+- return status;
+- }
+-
+-#pragma GCC diagnostic push
+-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+- /*
+- * check if RBD image is a clone (= has a parent).
+- *
+- * rbd_get_parent_info is deprecated from Nautilus onwards, but the
+- * replacement rbd_get_parent is not present in Luminous and Mimic.
+- */
+- if (rbd_get_parent_info(s->image, NULL, 0, NULL, 0, NULL, 0) != -ENOENT) {
+- return status;
+- }
+-#pragma GCC diagnostic pop
+-
+- head = req.offs & (s->object_size - 1);
+- req.offs -= head;
+- bytes += head;
+-#endif
+-
+- r = rbd_diff_iterate2(s->image, NULL, req.offs, bytes, true, true,
++ r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
+ qemu_rbd_diff_iterate_cb, &req);
+ if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
+ return status;
+@@ -1407,8 +1370,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
+ status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
+ }
+
+- assert(req.bytes > head);
+- *pnum = req.bytes - head;
++ *pnum = req.bytes;
+ return status;
+ }
+
diff --git a/debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch b/debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
new file mode 100644
index 0000000..6624c1d
--- /dev/null
+++ b/debian/patches/pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
@@ -0,0 +1,35 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Fabian Ebner <f.ebner@proxmox.com>
+Date: Thu, 23 Jun 2022 14:00:07 +0200
+Subject: [PATCH] Revert "block/rbd: fix handling of holes in
+ .bdrv_co_block_status"
+
+This reverts commit 9e302f64bb407a9bb097b626da97228c2654cfee in
+preparation to revert 0347a8fd4c3faaedf119be04c197804be40a384b.
+
+Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
+---
+ block/rbd.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/block/rbd.c b/block/rbd.c
+index 0a9b97aa5e..1c585d23e9 100644
+--- a/block/rbd.c
++++ b/block/rbd.c
+@@ -1283,11 +1283,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
+ RBDDiffIterateReq *req = opaque;
+
+ assert(req->offs + req->bytes <= offs);
+-
+- /* treat a hole like an unallocated area and bail out */
+- if (!exists) {
+- return 0;
+- }
++ /*
++ * we do not diff against a snapshot so we should never receive a callback
++ * for a hole.
++ */
++ assert(exists);
+
+ if (!req->exists && offs > req->offs) {
+ /*
diff --git a/debian/patches/pve/0053-Revert-block-rbd-implement-bdrv_co_block_status.patch b/debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
similarity index 97%
rename from debian/patches/pve/0053-Revert-block-rbd-implement-bdrv_co_block_status.patch
rename to debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
index d3c6a71..13e71b7 100644
--- a/debian/patches/pve/0053-Revert-block-rbd-implement-bdrv_co_block_status.patch
+++ b/debian/patches/pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
@@ -23,7 +23,7 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 112 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
-index a4b8fb482c..3393b06a4e 100644
+index 1c585d23e9..1704767041 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -97,12 +97,6 @@ typedef struct RBDTask {
@@ -39,7 +39,7 @@ index a4b8fb482c..3393b06a4e 100644
static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
BlockdevOptionsRbd *opts, bool cache,
const char *keypairs, const char *secretid,
-@@ -1267,111 +1261,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
+@@ -1269,111 +1263,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
return spec_info;
}
@@ -151,7 +151,7 @@ index a4b8fb482c..3393b06a4e 100644
static int64_t qemu_rbd_getlength(BlockDriverState *bs)
{
BDRVRBDState *s = bs->opaque;
-@@ -1607,7 +1496,6 @@ static BlockDriver bdrv_rbd = {
+@@ -1609,7 +1498,6 @@ static BlockDriver bdrv_rbd = {
#ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
.bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
#endif
diff --git a/debian/patches/pve/0054-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch b/debian/patches/pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
similarity index 100%
rename from debian/patches/pve/0054-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
rename to debian/patches/pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
diff --git a/debian/patches/pve/0055-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch b/debian/patches/pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
similarity index 100%
rename from debian/patches/pve/0055-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
rename to debian/patches/pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
diff --git a/debian/patches/pve/0056-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch b/debian/patches/pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
similarity index 100%
rename from debian/patches/pve/0056-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
rename to debian/patches/pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
diff --git a/debian/patches/pve/0057-vma-create-support-64KiB-unaligned-input-images.patch b/debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
similarity index 92%
rename from debian/patches/pve/0057-vma-create-support-64KiB-unaligned-input-images.patch
rename to debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
index 7d9a07d..3097cf6 100644
--- a/debian/patches/pve/0057-vma-create-support-64KiB-unaligned-input-images.patch
+++ b/debian/patches/pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
@@ -25,10 +25,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/vma.c b/vma.c
-index 21e765a469..6d02b29047 100644
+index e1a750ff50..b1137e27a7 100644
--- a/vma.c
+++ b/vma.c
-@@ -548,7 +548,7 @@ static void coroutine_fn backup_run(void *opaque)
+@@ -549,7 +549,7 @@ static void coroutine_fn backup_run(void *opaque)
struct iovec iov;
QEMUIOVector qiov;
@@ -37,7 +37,7 @@ index 21e765a469..6d02b29047 100644
int ret = 0;
unsigned char *buf = blk_blockalign(job->target, VMA_CLUSTER_SIZE);
-@@ -562,8 +562,16 @@ static void coroutine_fn backup_run(void *opaque)
+@@ -563,8 +563,16 @@ static void coroutine_fn backup_run(void *opaque)
iov.iov_len = VMA_CLUSTER_SIZE;
qemu_iovec_init_external(&qiov, &iov, 1);
diff --git a/debian/patches/pve/0058-vma-create-avoid-triggering-assertion-in-error-case.patch b/debian/patches/pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
similarity index 88%
rename from debian/patches/pve/0058-vma-create-avoid-triggering-assertion-in-error-case.patch
rename to debian/patches/pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
index 586f2ba..c7961ae 100644
--- a/debian/patches/pve/0058-vma-create-avoid-triggering-assertion-in-error-case.patch
+++ b/debian/patches/pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
@@ -11,10 +11,10 @@ Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
1 file changed, 2 insertions(+)
diff --git a/vma-writer.c b/vma-writer.c
-index 11d8321ffd..29567cba68 100644
+index df4b20793d..ac7da237d0 100644
--- a/vma-writer.c
+++ b/vma-writer.c
-@@ -310,6 +310,8 @@ VmaWriter *vma_writer_create(const char *filename, uuid_t uuid, Error **errp)
+@@ -311,6 +311,8 @@ VmaWriter *vma_writer_create(const char *filename, uuid_t uuid, Error **errp)
}
if (vmaw->fd < 0) {
diff --git a/debian/patches/pve/0059-block-alloc-track-avoid-premature-break.patch b/debian/patches/pve/0061-block-alloc-track-avoid-premature-break.patch
similarity index 100%
rename from debian/patches/pve/0059-block-alloc-track-avoid-premature-break.patch
rename to debian/patches/pve/0061-block-alloc-track-avoid-premature-break.patch
diff --git a/debian/patches/series b/debian/patches/series
index dc51355..6fa7ca8 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,22 +1,5 @@
extra/0001-monitor-qmp-fix-race-with-clients-disconnecting-earl.patch
-extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
-extra/0003-monitor-refactor-set-expire_password-and-allow-VNC-d.patch
-extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
-extra/0007-block-nbd-Delete-reconnect-delay-timer-when-done.patch
-extra/0008-block-nbd-Assert-there-are-no-timers-when-closed.patch
-extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
-extra/0010-acpi-fix-QEMU-crash-when-started-with-SLIC-table.patch
-extra/0011-virtio-net-fix-map-leaking-on-error-during-receive.patch
-extra/0012-memory-Fix-incorrect-calls-of-log_global_start-stop.patch
-extra/0013-acpi-fix-OEM-ID-OEM-Table-ID-padding.patch
-extra/0014-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch
-extra/0015-vhost-user-remove-VirtQ-notifier-restore.patch
-extra/0016-vhost-user-fix-VirtQ-notifier-cleanup.patch
-extra/0017-virtio-fix-the-condition-for-iommu_platform-not-supp.patch
-extra/0018-block-gluster-correctly-set-max_pdiscard-which-is-in.patch
-extra/0019-ui-vnc.c-Fixed-a-deadlock-bug.patch
-extra/0020-display-qxl-render-fix-race-condition-in-qxl_cursor-.patch
-extra/0021-ui-cursor-fix-integer-overflow-in-cursor_alloc-CVE-2.patch
+extra/0002-block-gluster-correctly-set-max_pdiscard-which-is-in.patch
bitmap-mirror/0001-drive-mirror-add-support-for-sync-bitmap-mode-never.patch
bitmap-mirror/0002-drive-mirror-add-support-for-conditional-and-always-.patch
bitmap-mirror/0003-mirror-add-check-for-bitmap-mode-without-bitmap.patch
@@ -75,10 +58,12 @@ pve/0049-PVE-savevm-async-register-yank-before-migration_inco.patch
pve/0050-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch
pve/0051-vma-allow-partial-restore.patch
pve/0052-pbs-namespace-support.patch
-pve/0053-Revert-block-rbd-implement-bdrv_co_block_status.patch
-pve/0054-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
-pve/0055-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
-pve/0056-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
-pve/0057-vma-create-support-64KiB-unaligned-input-images.patch
-pve/0058-vma-create-avoid-triggering-assertion-in-error-case.patch
-pve/0059-block-alloc-track-avoid-premature-break.patch
+pve/0053-Revert-block-rbd-workaround-for-ceph-issue-53784.patch
+pve/0054-Revert-block-rbd-fix-handling-of-holes-in-.bdrv_co_b.patch
+pve/0055-Revert-block-rbd-implement-bdrv_co_block_status.patch
+pve/0056-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
+pve/0057-PVE-Backup-ensure-jobs-in-di_list-are-referenced.patch
+pve/0058-PVE-Backup-avoid-segfault-issues-upon-backup-cancel.patch
+pve/0059-vma-create-support-64KiB-unaligned-input-images.patch
+pve/0060-vma-create-avoid-triggering-assertion-in-error-case.patch
+pve/0061-block-alloc-track-avoid-premature-break.patch
diff --git a/qemu b/qemu
index 44f28df..823a3f1 160000
--- a/qemu
+++ b/qemu
@@ -1 +1 @@
-Subproject commit 44f28df24767cf9dca1ddc9b23157737c4cbb645
+Subproject commit 823a3f11fb8f04c3c3cc0f95f968fef1bfc6534f
--
2.30.2
^ permalink raw reply related [relevance 9%]
Results 1-23 of 23 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-06-27 11:05 [pve-devel] [PATCH-SERIES qemu] update to 7.0.0 Fabian Ebner
2022-06-27 11:05 9% ` [pve-devel] [PATCH qemu 1/4] update submodule and patches " Fabian Ebner
2022-10-13 12:44 11% [pve-devel] [PATCH qemu 1/4] update submodule and patches to 7.1.0 Fiona Ebner
2022-10-14 12:07 11% [pve-devel] [PATCH v2 " Fiona Ebner
2025-03-18 10:39 8% [pve-devel] [RFC PATCH manager] WIP: api: implement node-independent bulk actions Dominik Csapak
2025-03-18 11:30 1% ` Stefan Hanreich
2025-03-19 9:04 1% ` Dominik Csapak
2026-02-13 9:33 [PATCH pve-cluster 00/14 v2] Rewrite pmxcfs with Rust Kefu Chai
2026-02-13 9:33 1% ` [PATCH pve-cluster 12/14 v2] pmxcfs-rs: add pmxcfs main daemon binary Kefu Chai
2026-10-12 10:51 [PATCH-SERIES qemu 0/2] stable fixes for QEMU 11.1 Fiona Ebner
2026-10-12 10:51 6% ` [PATCH qemu 1/2] update submodule and patches to QEMU 11.1.2 Fiona Ebner
2026-10-13 8:38 [PATCH-SERIES qemu v2 0/2] stable fixes for QEMU 11.1 Fiona Ebner
2026-10-13 8:38 6% ` [PATCH qemu v2 1/2] update submodule and patches to QEMU 11.1.2 Fiona Ebner
2026-10-28 15:08 [PATCH-SERIES qemu v3 0/2] stable fixes for QEMU 11.1 Fiona Ebner
2026-10-28 15:08 5% ` [PATCH qemu v3 1/2] update submodule and patches to QEMU 11.1.3 Fiona Ebner
2026-11-01 22:58 15% [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-01 22:58 19% ` [PATCH guest-common 04/19] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
2026-11-01 22:58 21% ` [PATCH manager 11/19] vzdump: back up guests of a job in parallel Thomas Lamprecht
2026-11-01 22:58 19% ` [PATCH manager 16/19] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
2026-11-01 22:58 13% ` [PATCH manager 18/19] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
2026-11-01 22:58 17% ` [PATCH docs 19/19] vzdump: document concurrent backups and their limits Thomas Lamprecht
2026-11-01 23:20 10% [PATCH guest-common,manager,docs 0/5] backup jobs: add a start window Thomas Lamprecht
2026-11-18 13:18 14% [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-18 13:18 19% ` [PATCH v2 guest-common 04/20] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
2026-11-18 13:18 21% ` [PATCH v2 manager 11/20] vzdump: back up guests of a job in parallel Thomas Lamprecht
2026-11-18 13:18 18% ` [PATCH v2 manager 17/20] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
2026-11-18 13:18 15% ` [PATCH v2 manager 19/20] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
2026-11-18 13:18 19% ` [PATCH v2 docs 20/20] vzdump: document concurrent backups and their limits Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox