mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +00:00
qemu: Introduce qemuIsSharedHostdev
Add a single boolean function to handle whether the hostdev is shared or not. Use the new function for the qemu{Add|Remove}SharedHostdev calls as well as qemuSetUnprivSGIO. NB: This third usage fixes a possible bug where if this feature is enabled at some time in the future and the shareable flag wasn't set, the sgio would have been erroneously set. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
4f4ac3913a
commit
8c43258ed5
@ -1201,6 +1201,17 @@ qemuAddSharedDisk(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev)
|
||||
{
|
||||
return (hostdev->shareable &&
|
||||
(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
||||
hostdev->source.subsys.u.scsi.protocol !=
|
||||
VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI));
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev)
|
||||
{
|
||||
@ -1238,10 +1249,7 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
|
||||
char *key = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!hostdev->shareable ||
|
||||
!(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
||||
hostdev->source.subsys.u.scsi.protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI))
|
||||
if (!qemuIsSharedHostdev(hostdev))
|
||||
return 0;
|
||||
|
||||
if (!(key = qemuGetSharedHostdevKey(hostdev)))
|
||||
@ -1342,10 +1350,7 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver,
|
||||
char *key = NULL;
|
||||
int ret;
|
||||
|
||||
if (!hostdev->shareable ||
|
||||
!(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
||||
hostdev->source.subsys.u.scsi.protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI))
|
||||
if (!qemuIsSharedHostdev(hostdev))
|
||||
return 0;
|
||||
|
||||
if (!(key = qemuGetSharedHostdevKey(hostdev)))
|
||||
@ -1407,11 +1412,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
||||
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
||||
hostdev = dev->data.hostdev;
|
||||
|
||||
if (!qemuIsSharedHostdev(hostdev))
|
||||
return 0;
|
||||
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
hostdev->source.subsys.type ==
|
||||
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
||||
hostdev->source.subsys.u.scsi.sgio) {
|
||||
if (hostdev->source.subsys.u.scsi.sgio) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("'sgio' is not supported for SCSI "
|
||||
"generic device yet "));
|
||||
|
Loading…
x
Reference in New Issue
Block a user