mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
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: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
623366d130
commit
0b0f389335
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user