forked from rpms/libvirt
107 lines
3.5 KiB
Diff
107 lines
3.5 KiB
Diff
|
From 4ad02094b6166037a04310dbf9a3eb2dcc21ca61 Mon Sep 17 00:00:00 2001
|
||
|
Message-Id: <4ad02094b6166037a04310dbf9a3eb2dcc21ca61@dist-git>
|
||
|
From: Peter Krempa <pkrempa@redhat.com>
|
||
|
Date: Tue, 4 Feb 2020 15:07:37 +0100
|
||
|
Subject: [PATCH] qemu: domain: Extract code to determine topmost nodename to
|
||
|
qemuDomainDiskGetTopNodename
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
There are more places which require getting the topmost nodename to be
|
||
|
passed to qemu. Separate it out into a new function.
|
||
|
|
||
|
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
||
|
Reviewed-by: Eric Blake <eblake@redhat.com>
|
||
|
(cherry picked from commit 0b0f389335e5d11150fa60561cae960f20d5ca44)
|
||
|
|
||
|
https://bugzilla.redhat.com/show_bug.cgi?id=1792195
|
||
|
Message-Id: <b3c89cd0893677d101bc8f491bbd323db6133b19.1580824112.git.pkrempa@redhat.com>
|
||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||
|
---
|
||
|
src/qemu/qemu_domain.c | 38 ++++++++++++++++++++++++++------------
|
||
|
src/qemu/qemu_domain.h | 4 ++++
|
||
|
2 files changed, 30 insertions(+), 12 deletions(-)
|
||
|
|
||
|
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||
|
index e37404340f..be9de75909 100644
|
||
|
--- a/src/qemu/qemu_domain.c
|
||
|
+++ b/src/qemu/qemu_domain.c
|
||
|
@@ -11598,6 +11598,31 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
|
||
|
}
|
||
|
|
||
|
|
||
|
+/**
|
||
|
+ * qemuDomainDiskGetTopNodename:
|
||
|
+ *
|
||
|
+ * @disk: disk definition object
|
||
|
+ *
|
||
|
+ * Returns the pointer to the node-name of the topmost layer used by @disk as
|
||
|
+ * backend. Currently returns the nodename of the copy-on-read filter if enabled
|
||
|
+ * or the nodename of the top image's format driver. Empty disks return NULL.
|
||
|
+ * This must be used only when VIR_QEMU_CAPS_BLOCKDEV is enabled.
|
||
|
+ */
|
||
|
+const char *
|
||
|
+qemuDomainDiskGetTopNodename(virDomainDiskDefPtr disk)
|
||
|
+{
|
||
|
+ qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||
|
+
|
||
|
+ if (virStorageSourceIsEmpty(disk->src))
|
||
|
+ return NULL;
|
||
|
+
|
||
|
+ if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON)
|
||
|
+ return priv->nodeCopyOnRead;
|
||
|
+
|
||
|
+ return disk->src->nodeformat;
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
/**
|
||
|
* qemuDomainDiskGetBackendAlias:
|
||
|
* @disk: disk definition
|
||
|
@@ -11617,8 +11642,6 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
|
||
|
virQEMUCapsPtr qemuCaps,
|
||
|
char **backendAlias)
|
||
|
{
|
||
|
- qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||
|
- const char *nodename = NULL;
|
||
|
*backendAlias = NULL;
|
||
|
|
||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
|
||
|
@@ -11628,16 +11651,7 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
|
||
|
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;
|
||
|
-
|
||
|
- *backendAlias = g_strdup(nodename);
|
||
|
-
|
||
|
+ *backendAlias = g_strdup(qemuDomainDiskGetTopNodename(disk));
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
||
|
index 60b80297fa..d1ab5da2c7 100644
|
||
|
--- a/src/qemu/qemu_domain.h
|
||
|
+++ b/src/qemu/qemu_domain.h
|
||
|
@@ -881,6 +881,10 @@ int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
|
||
|
virStorageSourcePtr parent);
|
||
|
char *qemuDomainStorageAlias(const char *device, int depth);
|
||
|
|
||
|
+const char *
|
||
|
+qemuDomainDiskGetTopNodename(virDomainDiskDefPtr disk)
|
||
|
+ ATTRIBUTE_NONNULL(1);
|
||
|
+
|
||
|
int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
|
||
|
virQEMUCapsPtr qemuCaps,
|
||
|
char **backendAlias)
|
||
|
--
|
||
|
2.25.0
|
||
|
|