From f79f0e1e91f789abb9679b448aab7a5aada2031a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 18 Jul 2018 13:58:59 +0200 Subject: [PATCH] qemu: domain: Prepare qemuDomainDiskGetBackendAlias for -blockdev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- 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 75b5e916b4..50b262403e 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; -- GitLab