From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server v2 5/9] blockdev: implement reopen function
Date: Wed, 11 Nov 2026 13:01:44 +0100 [thread overview]
Message-ID: <20261111120211.110737-6-f.ebner@proxmox.com> (raw)
In-Reply-To: <20261111120211.110737-1-f.ebner@proxmox.com>
Similar to the attach() function, but for re-opening an already
attached block node. Currently limited to non-throttle nodes.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
No changes in v2.
src/PVE/QemuServer/Blockdev.pm | 68 ++++++++++++++++++++++++++++------
1 file changed, 57 insertions(+), 11 deletions(-)
diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm
index ef038c7e..6678bc33 100644
--- a/src/PVE/QemuServer/Blockdev.pm
+++ b/src/PVE/QemuServer/Blockdev.pm
@@ -548,6 +548,33 @@ my sub blockdev_add {
=pod
+=head3 generate_drive_blockdev_for_peer
+
+Helper for the C<attach> and C<reopen> functions, see C<attach> for the parameter descriptions.
+Returns the generated blockdev and the QMP peer information.
+
+=cut
+
+my sub generate_drive_blockdev_for_peer {
+ my ($storecfg, $id, $drive, $options) = @_;
+
+ my $qmp_peer = $options->{qsd} ? qsd_qmp_peer($id) : vm_qmp_peer($id);
+
+ my $machine_version;
+ if ($options->{qsd}) { # qemu-storage-daemon runs with the installed binary version
+ $machine_version =
+ 'pc-i440fx-' . PVE::QemuServer::Machine::latest_installed_machine_version();
+ } else {
+ $machine_version = PVE::QemuServer::Machine::get_current_qemu_machine($id);
+ }
+
+ my $blockdev = generate_drive_blockdev($storecfg, $drive, $machine_version, $options);
+
+ return ($blockdev, $qmp_peer);
+}
+
+=pod
+
=head3 attach
my ($node_name, $read_only) = attach($storecfg, $id, $drive, $options);
@@ -596,17 +623,7 @@ state image.
sub attach {
my ($storecfg, $id, $drive, $options) = @_;
- my $qmp_peer = $options->{qsd} ? qsd_qmp_peer($id) : vm_qmp_peer($id);
-
- my $machine_version;
- if ($options->{qsd}) { # qemu-storage-daemon runs with the installed binary version
- $machine_version =
- 'pc-i440fx-' . PVE::QemuServer::Machine::latest_installed_machine_version();
- } else {
- $machine_version = PVE::QemuServer::Machine::get_current_qemu_machine($id);
- }
-
- my $blockdev = generate_drive_blockdev($storecfg, $drive, $machine_version, $options);
+ my ($blockdev, $qmp_peer) = generate_drive_blockdev_for_peer($storecfg, $id, $drive, $options);
my $throttle_group_id;
if (parse_top_node_name($blockdev->{'node-name'})) { # device top nodes need a throttle group
@@ -727,6 +744,35 @@ sub detach_fleecing_block_nodes {
}
}
+=pod
+
+=head3 reopen
+
+ reopen($storecfg, $id, $drive, $options);
+
+Re-open the already attached drive C<$drive> of the VM C<$id> while considering the additional
+options C<$options>. See C<attach> for the description of parameters and options. The C<no-throttle>
+option is currently required to be set.
+
+=cut
+
+sub reopen {
+ my ($storecfg, $id, $drive, $options) = @_;
+
+ # Will need additional consideration regarding the throttle group objects.
+ die "reopen for a throttle node is not implemented yet\n" if !$options->{'no-throttle'};
+
+ my ($blockdev, $qmp_peer) = generate_drive_blockdev_for_peer($storecfg, $id, $drive, $options);
+
+ if ($blockdev->{driver} eq 'zeroinit') { # zero-init does not support re-open, defer to child
+ $blockdev = $blockdev->{file};
+ }
+
+ qmp_cmd($qmp_peer, 'blockdev-reopen', options => [$blockdev]);
+
+ return;
+}
+
sub resize {
my ($vmid, $deviceid, $storecfg, $volid, $size) = @_;
--
2.47.3
next prev parent reply other threads:[~2026-11-11 12:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 12:01 [PATCH-SERIES qemu/qemu-server v2 0/9] mirror: fix regressions with blockdev and allow migration with 'ro' flag Fiona Ebner
2026-11-11 12:01 ` [PATCH qemu v2 1/9] patches/extra: allow mirror job to use non-root block node Fiona Ebner
2026-11-11 12:01 ` [PATCH qemu-server v2 2/9] partially fix #7299: fix regression with guest IO limits applying to mirror job Fiona Ebner
2026-11-11 12:01 ` [PATCH qemu-server v2 3/9] partially fix #7299: migrate: fix regression with guest IO limits applying to NBD export Fiona Ebner
2026-11-11 12:01 ` [PATCH qemu-server v2 4/9] blockdev: attach: support explicitly attaching as writeable Fiona Ebner
2026-11-11 12:01 ` Fiona Ebner [this message]
2026-11-11 12:01 ` [PATCH qemu-server v2 6/9] partially fix #7836: allow mirror for drive with read-only flag when using blockdev Fiona Ebner
2026-11-11 12:01 ` [PATCH qemu-server v2 7/9] qm: schema: declare 'nbdstop' command as being for internal use only Fiona Ebner
2026-11-11 12:01 ` [PATCH qemu-server v2 8/9] migrate: log messages from remote nbdstop command Fiona Ebner
2026-11-11 12:01 ` [PATCH qemu-server v2 9/9] partially fix #7836: allow migration for drive with read-only flag when using blockdev Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111120211.110737-6-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.