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