util: move virStorageSourceFindByNodeName into qemu_domain

It's only relevant for QEMU driver.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Pavel Hrdina 2021-01-15 20:52:00 +01:00
parent 90caf9d763
commit eaa0b3288e
4 changed files with 32 additions and 37 deletions

View File

@ -3175,7 +3175,6 @@ virStorageSourceChainHasManagedPR;
virStorageSourceChainHasNVMe; virStorageSourceChainHasNVMe;
virStorageSourceClear; virStorageSourceClear;
virStorageSourceCopy; virStorageSourceCopy;
virStorageSourceFindByNodeName;
virStorageSourceGetActualType; virStorageSourceGetActualType;
virStorageSourceGetSecurityLabelDef; virStorageSourceGetSecurityLabelDef;
virStorageSourceHasBacking; virStorageSourceHasBacking;

View File

@ -2582,6 +2582,32 @@ qemuDomainObjPrivateXMLParseBlockjobChain(xmlNodePtr node,
} }
/**
* qemuDomainVirStorageSourceFindByNodeName:
* @top: backing chain top
* @nodeName: node name to find in backing chain
*
* Looks up the given storage source in the backing chain and returns the
* pointer to it.
* On failure NULL is returned and no error is reported.
*/
static virStorageSourcePtr
qemuDomainVirStorageSourceFindByNodeName(virStorageSourcePtr top,
const char *nodeName)
{
virStorageSourcePtr tmp;
for (tmp = top; virStorageSourceIsBacking(tmp); tmp = tmp->backingStore) {
if ((tmp->nodeformat && STREQ(tmp->nodeformat, nodeName)) ||
(tmp->nodestorage && STREQ(tmp->nodestorage, nodeName)))
return tmp;
}
return NULL;
}
static void static void
qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlockJobDataPtr job, qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlockJobDataPtr job,
const char *xpath, const char *xpath,
@ -2596,15 +2622,15 @@ qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlockJobDataPtr job,
return; return;
if (job->disk && if (job->disk &&
(*src = virStorageSourceFindByNodeName(job->disk->src, nodename))) (*src = qemuDomainVirStorageSourceFindByNodeName(job->disk->src, nodename)))
return; return;
if (job->chain && if (job->chain &&
(*src = virStorageSourceFindByNodeName(job->chain, nodename))) (*src = qemuDomainVirStorageSourceFindByNodeName(job->chain, nodename)))
return; return;
if (job->mirrorChain && if (job->mirrorChain &&
(*src = virStorageSourceFindByNodeName(job->mirrorChain, nodename))) (*src = qemuDomainVirStorageSourceFindByNodeName(job->mirrorChain, nodename)))
return; return;
/* the node was in the XML but was not found in the job definitions */ /* the node was in the XML but was not found in the job definitions */
@ -10028,11 +10054,11 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def,
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
virDomainDiskDefPtr domdisk = def->disks[i]; virDomainDiskDefPtr domdisk = def->disks[i];
if ((*src = virStorageSourceFindByNodeName(domdisk->src, nodename))) if ((*src = qemuDomainVirStorageSourceFindByNodeName(domdisk->src, nodename)))
return domdisk; return domdisk;
if (domdisk->mirror && if (domdisk->mirror &&
(*src = virStorageSourceFindByNodeName(domdisk->mirror, nodename))) (*src = qemuDomainVirStorageSourceFindByNodeName(domdisk->mirror, nodename)))
return domdisk; return domdisk;
} }
@ -10041,7 +10067,7 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def,
virDomainBackupDiskDefPtr backupdisk = backupdef->disks + i; virDomainBackupDiskDefPtr backupdisk = backupdef->disks + i;
if (backupdisk->store && if (backupdisk->store &&
(*src = virStorageSourceFindByNodeName(backupdisk->store, nodename))) (*src = qemuDomainVirStorageSourceFindByNodeName(backupdisk->store, nodename)))
return virDomainDiskByTarget(def, backupdisk->name); return virDomainDiskByTarget(def, backupdisk->name);
} }
} }

View File

@ -4445,31 +4445,6 @@ virStorageSourceIsRelative(virStorageSourcePtr src)
} }
/**
* virStorageSourceFindByNodeName:
* @top: backing chain top
* @nodeName: node name to find in backing chain
*
* Looks up the given storage source in the backing chain and returns the
* pointer to it.
* On failure NULL is returned and no error is reported.
*/
virStorageSourcePtr
virStorageSourceFindByNodeName(virStorageSourcePtr top,
const char *nodeName)
{
virStorageSourcePtr tmp;
for (tmp = top; virStorageSourceIsBacking(tmp); tmp = tmp->backingStore) {
if ((tmp->nodeformat && STREQ(tmp->nodeformat, nodeName)) ||
(tmp->nodestorage && STREQ(tmp->nodestorage, nodeName)))
return tmp;
}
return NULL;
}
static unsigned int static unsigned int
virStorageSourceNetworkDefaultPort(virStorageNetProtocol protocol) virStorageSourceNetworkDefaultPort(virStorageNetProtocol protocol)
{ {

View File

@ -521,11 +521,6 @@ int virStorageSourceNewFromBackingAbsolute(const char *path,
bool virStorageSourceIsRelative(virStorageSourcePtr src); bool virStorageSourceIsRelative(virStorageSourcePtr src);
virStorageSourcePtr
virStorageSourceFindByNodeName(virStorageSourcePtr top,
const char *nodeName)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
void void
virStorageSourceNetworkAssignDefaultPorts(virStorageSourcePtr src) virStorageSourceNetworkAssignDefaultPorts(virStorageSourcePtr src)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);