all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu 1/3] PVE backup: prepare for the switch to using blockdev rather than drive
Date: Thu, 26 Jun 2025 18:04:37 +0200	[thread overview]
Message-ID: <20250626160504.330350-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250626160504.330350-1-f.ebner@proxmox.com>

Also allow finding block nodes by their node name rather than just via
an associated block backend, which might not exist for block nodes.

For regular drives, it is essential to not use the throttle group,
because otherwise the limits intended only for the guest would also
apply to the backup job.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 pve-backup.c | 51 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 12 deletions(-)

diff --git a/pve-backup.c b/pve-backup.c
index 0450303017..457fcb7e5c 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -847,29 +847,56 @@ static PVEBackupDevInfo coroutine_fn GRAPH_RDLOCK *get_single_device_info(
     Error **errp)
 {
     BlockBackend *blk = blk_by_name(device);
-    if (!blk) {
-        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
-                  "Device '%s' not found", device);
-        return NULL;
+    BlockDriverState *root_bs, *bs;
+
+    if (blk) {
+        root_bs = bs = blk_bs(blk);
+    } else {
+        /* TODO PVE 10 - fleecing will always be attached without blk */
+        root_bs = bs = bdrv_find_node(device);
+        if (!bs) {
+            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                      "Device '%s' not found", device);
+            return NULL;
+        }
+        /* For TPM, bs is already correct, otherwise need the file child. */
+        if (!strncmp(bs->drv->format_name, "throttle", 8)) {
+            if (!bs->file || !bs->file->bs) {
+                error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                          "Device '%s' not found (no file child)", device);
+                return NULL;
+            }
+            bs = bs->file->bs;
+        }
     }
-    BlockDriverState *bs = blk_bs(blk);
+
     if (!bdrv_co_is_inserted(bs)) {
         error_setg(errp, "Device '%s' has no medium", device);
         return NULL;
     }
+
     PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
     di->bs = bs;
-    di->device_name = g_strdup(bdrv_get_device_name(bs));
+    /* Need the name of the root node, e.g. drive-scsi0 */
+    di->device_name = g_strdup(bdrv_get_device_or_node_name(root_bs));
 
     if (device_uses_fleecing && device_uses_fleecing(device)) {
         g_autofree gchar *fleecing_devid = g_strconcat(device, "-fleecing", NULL);
+        BlockDriverState *fleecing_bs;
+
         BlockBackend *fleecing_blk = blk_by_name(fleecing_devid);
-        if (!fleecing_blk) {
-            error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
-                      "Device '%s' not found", fleecing_devid);
-            goto fail;
+        if (fleecing_blk) {
+            fleecing_bs = blk_bs(fleecing_blk);
+        } else {
+            /* TODO PVE 10 - fleecing will always be attached without blk */
+            fleecing_bs = bdrv_find_node(fleecing_devid);
+            if (!fleecing_bs) {
+                error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                          "Device '%s' not found", fleecing_devid);
+                goto fail;
+            }
         }
-        BlockDriverState *fleecing_bs = blk_bs(fleecing_blk);
+
         if (!bdrv_co_is_inserted(fleecing_bs)) {
             error_setg(errp, "Device '%s' has no medium", fleecing_devid);
             goto fail;
@@ -927,7 +954,7 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info(
 
             PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
             di->bs = bs;
-            di->device_name = g_strdup(bdrv_get_device_name(bs));
+            di->device_name = g_strdup(bdrv_get_device_or_node_name(bs));
             di_list = g_list_append(di_list, di);
         }
     }
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-06-26 16:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26 16:04 [pve-devel] [PATCH-SERIES qemu 0/3] prepartion for blockdev Fiona Ebner
2025-06-26 16:04 ` Fiona Ebner [this message]
2025-06-26 16:04 ` [pve-devel] [PATCH qemu 2/3] block/zeroinit: support using as blockdev driver Fiona Ebner
2025-06-26 16:04 ` [pve-devel] [PATCH qemu 3/3] blockdev: query file child QMP command Fiona Ebner
2025-06-30 12:43   ` Fabian Grünbichler
2025-06-30 14:23     ` Fiona Ebner
2025-06-27 15:51 ` [pve-devel] [PATCH qemu 4/4] block/alloc-track: support using as blockdev driver 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=20250626160504.330350-2-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal