提交 0b0f3893 编写于 作者: P Peter Krempa

qemu: domain: Extract code to determine topmost nodename to qemuDomainDiskGetTopNodename

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 623366d1
......@@ -11530,6 +11530,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
......@@ -11549,8 +11574,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)) {
......@@ -11560,16 +11583,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;
}
......
......@@ -874,6 +874,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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册