render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
acda74
From 659a0e3cda2f5561abe45ccc10afc41014d1a331 Mon Sep 17 00:00:00 2001
acda74
Message-Id: <659a0e3cda2f5561abe45ccc10afc41014d1a331@dist-git>
acda74
From: Peter Krempa <pkrempa@redhat.com>
acda74
Date: Tue, 31 Jan 2023 14:37:40 +0100
acda74
Subject: [PATCH] qemu: command: Handle FD passing commandline via
acda74
 qemuBuildBlockStorageSourceAttachDataCommandline
acda74
acda74
Copy the pointer to qemuFDPass into struct qemuBlockStorageSourceAttachData
acda74
so that it can be used from qemuBuildBlockStorageSourceAttachDataCommandline
acda74
rather than looping again in qemuBuildDiskSourceCommandLineFDs.
acda74
acda74
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
acda74
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
acda74
(cherry picked from commit 65f14232fb031b57fad085a2e8792da87c97173f)
acda74
acda74
https://bugzilla.redhat.com/show_bug.cgi?id=2040272
acda74
---
acda74
 src/qemu/qemu_block.h                         |  2 ++
acda74
 src/qemu/qemu_command.c                       | 26 +++----------------
acda74
 .../disk-source-fd.x86_64-latest.args         |  6 ++---
acda74
 3 files changed, 9 insertions(+), 25 deletions(-)
acda74
acda74
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
acda74
index eac986e0f0..5a61a19da2 100644
acda74
--- a/src/qemu/qemu_block.h
acda74
+++ b/src/qemu/qemu_block.h
acda74
@@ -99,6 +99,8 @@ struct qemuBlockStorageSourceAttachData {
acda74
     char *tlsAlias;
acda74
     virJSONValue *tlsKeySecretProps;
acda74
     char *tlsKeySecretAlias;
acda74
+
acda74
+    qemuFDPass *fdpass;
acda74
 };
acda74
 
acda74
 
acda74
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
acda74
index b96f2d33c1..5edad046d5 100644
acda74
--- a/src/qemu/qemu_command.c
acda74
+++ b/src/qemu/qemu_command.c
acda74
@@ -2119,6 +2119,8 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommand *cmd,
acda74
             return -1;
acda74
     }
acda74
 
acda74
+    qemuFDPassTransferCommand(data->fdpass, cmd);
acda74
+
acda74
     if (data->storageProps) {
acda74
         if (!(tmp = virJSONValueToString(data->storageProps, false)))
acda74
             return -1;
acda74
@@ -2147,25 +2149,6 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommand *cmd,
acda74
 }
acda74
 
acda74
 
acda74
-static int
acda74
-qemuBuildDiskSourceCommandLineFDs(virCommand *cmd,
acda74
-                                  virDomainDiskDef *disk)
acda74
-{
acda74
-    virStorageSource *n;
acda74
-
acda74
-    for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
acda74
-        qemuDomainStorageSourcePrivate *srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(n);
acda74
-
acda74
-        if (!srcpriv || !srcpriv->fdpass)
acda74
-            continue;
acda74
-
acda74
-        qemuFDPassTransferCommand(srcpriv->fdpass, cmd);
acda74
-    }
acda74
-
acda74
-    return 0;
acda74
-}
acda74
-
acda74
-
acda74
 static int
acda74
 qemuBuildDiskSourceCommandLine(virCommand *cmd,
acda74
                                virDomainDiskDef *disk,
acda74
@@ -2183,9 +2166,6 @@ qemuBuildDiskSourceCommandLine(virCommand *cmd,
acda74
         if (virStorageSourceIsEmpty(disk->src))
acda74
             return 0;
acda74
 
acda74
-        if (qemuBuildDiskSourceCommandLineFDs(cmd, disk) < 0)
acda74
-            return -1;
acda74
-
acda74
         if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src)))
acda74
             return -1;
acda74
 
acda74
@@ -10537,6 +10517,8 @@ qemuBuildStorageSourceAttachPrepareCommon(virStorageSource *src,
acda74
 
acda74
             tlsKeySecretAlias = srcpriv->tlsKeySecret->alias;
acda74
         }
acda74
+
acda74
+        data->fdpass = srcpriv->fdpass;
acda74
     }
acda74
 
acda74
     if (src->haveTLS == VIR_TRISTATE_BOOL_YES &&
acda74
diff --git a/tests/qemuxml2argvdata/disk-source-fd.x86_64-latest.args b/tests/qemuxml2argvdata/disk-source-fd.x86_64-latest.args
acda74
index b4a81acfc7..a7ddd65000 100644
acda74
--- a/tests/qemuxml2argvdata/disk-source-fd.x86_64-latest.args
acda74
+++ b/tests/qemuxml2argvdata/disk-source-fd.x86_64-latest.args
acda74
@@ -33,13 +33,13 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
acda74
 -blockdev '{"driver":"file","filename":"/dev/fdset/2","node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap"}' \
acda74
 -blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"qcow2","file":"libvirt-4-storage"}' \
acda74
 -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"libvirt-4-format","id":"virtio-disk4","bootindex":1}' \
acda74
--add-fd set=0,fd=704,opaque=libvirt-1-storage0 \
acda74
--add-fd set=1,fd=777,opaque=libvirt-2-storage0 \
acda74
--add-fd set=1,fd=778,opaque=libvirt-2-storage1 \
acda74
 -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/rhel7.1484071876","node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \
acda74
 -blockdev '{"node-name":"libvirt-3-format","read-only":true,"driver":"qcow2","file":"libvirt-3-storage","backing":null}' \
acda74
+-add-fd set=1,fd=777,opaque=libvirt-2-storage0 \
acda74
+-add-fd set=1,fd=778,opaque=libvirt-2-storage1 \
acda74
 -blockdev '{"driver":"file","filename":"/dev/fdset/1","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
acda74
 -blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"qcow2","file":"libvirt-2-storage","backing":"libvirt-3-format"}' \
acda74
+-add-fd set=0,fd=704,opaque=libvirt-1-storage0 \
acda74
 -blockdev '{"driver":"file","filename":"/dev/fdset/0","node-name":"libvirt-1-storage","read-only":false,"discard":"unmap"}' \
acda74
 -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage","backing":"libvirt-2-format"}' \
acda74
 -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"libvirt-1-format","id":"virtio-disk5"}' \
acda74
-- 
acda74
2.39.1
acda74