Pass in the node name as the backend alias when -blockdev is used. As
copy-on-read is expressed by a separate -blockdev backing chain member
we need to decide which node name to use here.
For empty cdroms when using -blockdev there is no backend at all so NULL
is returned.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fc2a3d9f60..7ce4487b05 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8691,12 +8691,29 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
*/
int
qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
- virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
+ virQEMUCapsPtr qemuCaps,
char **backendAlias)
{
+ qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+ const char *nodename = NULL;
*backendAlias = NULL;
- if (!(*backendAlias = qemuAliasDiskDriveFromDisk(disk)))
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+ if (!(*backendAlias = qemuAliasDiskDriveFromDisk(disk)))
+ return -1;
+
+ return 0;
+ }
+
+ if (virStorageSourceIsEmpty(disk->src))
+ return 0;
+
+ if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON)
+ nodename = priv->nodeCopyOnRead;
+ else
+ nodename = disk->src->nodeformat;
+
+ if (VIR_STRDUP(*backendAlias, nodename) < 0)
return -1;
return 0;
--
2.16.2