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