mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
conf: Add virStorageSource member for SCSI host device config data
The backend for the SCSI host device is a storage source. While the definition doesn't look like that it's converted to a storage source when the VM is running. Add the storage source to the definition object and also parse/format its private data which will be used for internal state storage while the VM is running. Note that the virStorageSourcePtr may not be allocated all the time so the private data parser allocates it if there is any private data present. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
baea669e80
commit
981d098250
@ -3019,6 +3019,8 @@ virDomainHostdevSubsysSCSIClear(virDomainHostdevSubsysSCSIPtr scsisrc)
|
||||
scsisrc->u.iscsi.src = NULL;
|
||||
} else {
|
||||
VIR_FREE(scsisrc->u.host.adapter);
|
||||
virObjectUnref(scsisrc->u.host.src);
|
||||
scsisrc->u.host.src = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8263,7 +8265,9 @@ virDomainStorageNetworkParseHosts(xmlNodePtr node,
|
||||
static int
|
||||
virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
|
||||
xmlXPathContextPtr ctxt,
|
||||
virDomainHostdevSubsysSCSIPtr scsisrc)
|
||||
virDomainHostdevSubsysSCSIPtr scsisrc,
|
||||
unsigned int flags,
|
||||
virDomainXMLOptionPtr xmlopt)
|
||||
{
|
||||
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
|
||||
g_autofree char *bus = NULL;
|
||||
@ -8313,6 +8317,16 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (flags & VIR_DOMAIN_DEF_PARSE_STATUS &&
|
||||
xmlopt && xmlopt->privateData.storageParse) {
|
||||
if ((ctxt->node = virXPathNode("./privateData", ctxt))) {
|
||||
if (!scsihostsrc->src &&
|
||||
!(scsihostsrc->src = virStorageSourceNew()))
|
||||
return -1;
|
||||
if (xmlopt->privateData.storageParse(ctxt, scsihostsrc->src) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -8413,7 +8427,8 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
|
||||
|
||||
switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) {
|
||||
case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE:
|
||||
return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, ctxt, scsisrc);
|
||||
return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, ctxt, scsisrc,
|
||||
flags, xmlopt);
|
||||
|
||||
case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI:
|
||||
return virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc, ctxt,
|
||||
@ -26305,6 +26320,11 @@ virDomainHostdevDefFormatSubsysSCSI(virBufferPtr buf,
|
||||
virBufferAsprintf(&sourceChildBuf, " bus='%u' target='%u' unit='%llu'",
|
||||
scsihostsrc->bus, scsihostsrc->target, scsihostsrc->unit);
|
||||
virBufferAddLit(&sourceChildBuf, "/>\n");
|
||||
|
||||
if (scsihostsrc->src &&
|
||||
virDomainDiskSourceFormatPrivateData(&sourceChildBuf, scsihostsrc->src,
|
||||
flags, xmlopt) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
virXMLFormatElement(buf, "source", &sourceAttrBuf, &sourceChildBuf);
|
||||
|
@ -245,6 +245,7 @@ struct _virDomainHostdevSubsysSCSIHost {
|
||||
unsigned bus;
|
||||
unsigned target;
|
||||
unsigned long long unit;
|
||||
virStorageSourcePtr src;
|
||||
};
|
||||
|
||||
struct _virDomainHostdevSubsysSCSIiSCSI {
|
||||
|
Loading…
x
Reference in New Issue
Block a user