mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: Introduce virDomainDiskSourceIsBlockType
Introduce a new helper to check if the disk source is of block type
This commit is contained in:
parent
c00b2f0dd1
commit
1f49b05a82
@ -41,6 +41,7 @@
|
|||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "nwfilter_conf.h"
|
#include "nwfilter_conf.h"
|
||||||
|
#include "storage_conf.h"
|
||||||
#include "virstoragefile.h"
|
#include "virstoragefile.h"
|
||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
#include "virbitmap.h"
|
#include "virbitmap.h"
|
||||||
@ -18380,3 +18381,34 @@ virDomainDefFindDevice(virDomainDefPtr def,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDomainDiskSourceIsBlockType:
|
||||||
|
*
|
||||||
|
* Check if the disk *source* is of block type. This just tries
|
||||||
|
* to check from the type of disk def, not to probe the underlying
|
||||||
|
* storage.
|
||||||
|
*
|
||||||
|
* Return true if its source is block type, or false otherwise.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
|
||||||
|
{
|
||||||
|
/* No reason to think the disk source is block type if
|
||||||
|
* the source is empty
|
||||||
|
*/
|
||||||
|
if (!def->src)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (def->type == VIR_DOMAIN_DISK_TYPE_BLOCK)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* For volume types, check the srcpool.
|
||||||
|
* If it's a block type source pool, then it's possible
|
||||||
|
*/
|
||||||
|
if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool &&
|
||||||
|
def->srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -2715,4 +2715,7 @@ int virDomainDefFindDevice(virDomainDefPtr def,
|
|||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
bool reportError);
|
bool reportError);
|
||||||
|
|
||||||
|
bool virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
|
||||||
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
#endif /* __DOMAIN_CONF_H */
|
#endif /* __DOMAIN_CONF_H */
|
||||||
|
@ -206,6 +206,7 @@ virDomainDiskProtocolTransportTypeToString;
|
|||||||
virDomainDiskProtocolTypeToString;
|
virDomainDiskProtocolTypeToString;
|
||||||
virDomainDiskRemove;
|
virDomainDiskRemove;
|
||||||
virDomainDiskRemoveByName;
|
virDomainDiskRemoveByName;
|
||||||
|
virDomainDiskSourceIsBlockType;
|
||||||
virDomainDiskTypeFromString;
|
virDomainDiskTypeFromString;
|
||||||
virDomainDiskTypeToString;
|
virDomainDiskTypeToString;
|
||||||
virDomainEmulatorPinAdd;
|
virDomainEmulatorPinAdd;
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "domain_audit.h"
|
#include "domain_audit.h"
|
||||||
#include "domain_conf.h"
|
#include "domain_conf.h"
|
||||||
#include "snapshot_conf.h"
|
#include "snapshot_conf.h"
|
||||||
|
#include "storage_conf.h"
|
||||||
#include "network/bridge_driver.h"
|
#include "network/bridge_driver.h"
|
||||||
#include "virnetdevtap.h"
|
#include "virnetdevtap.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
@ -3492,9 +3493,7 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
|
|||||||
virDomainDiskProtocolTypeToString(disk->protocol));
|
virDomainDiskProtocolTypeToString(disk->protocol));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK &&
|
} else if (!virDomainDiskSourceIsBlockType(disk)) {
|
||||||
!(disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME &&
|
|
||||||
disk->srcpool->voltype == VIR_STORAGE_VOL_BLOCK)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("disk device='lun' is only valid for block type disk source"));
|
_("disk device='lun' is only valid for block type disk source"));
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
#include "viratomic.h"
|
#include "viratomic.h"
|
||||||
|
#include "storage_conf.h"
|
||||||
#include "configmake.h"
|
#include "configmake.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||||
@ -867,12 +868,7 @@ qemuAddSharedDevice(virQEMUDriverPtr driver,
|
|||||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
||||||
disk = dev->data.disk;
|
disk = dev->data.disk;
|
||||||
|
|
||||||
if (!disk->shared ||
|
if (!disk->shared || !virDomainDiskSourceIsBlockType(disk))
|
||||||
!disk->src ||
|
|
||||||
(disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK &&
|
|
||||||
!(disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME &&
|
|
||||||
disk->srcpool &&
|
|
||||||
disk->srcpool->voltype == VIR_STORAGE_VOL_BLOCK)))
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
||||||
hostdev = dev->data.hostdev;
|
hostdev = dev->data.hostdev;
|
||||||
@ -978,12 +974,7 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver,
|
|||||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
||||||
disk = dev->data.disk;
|
disk = dev->data.disk;
|
||||||
|
|
||||||
if (!disk->shared ||
|
if (!disk->shared || !virDomainDiskSourceIsBlockType(disk))
|
||||||
!disk->src ||
|
|
||||||
(disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK &&
|
|
||||||
!(disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME &&
|
|
||||||
disk->srcpool &&
|
|
||||||
disk->srcpool->voltype == VIR_STORAGE_VOL_BLOCK)))
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
||||||
hostdev = dev->data.hostdev;
|
hostdev = dev->data.hostdev;
|
||||||
@ -1073,12 +1064,8 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|||||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
||||||
disk = dev->data.disk;
|
disk = dev->data.disk;
|
||||||
|
|
||||||
if (!disk->src ||
|
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
|
||||||
disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
|
virDomainDiskSourceIsBlockType(disk))
|
||||||
(disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK &&
|
|
||||||
!(disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME &&
|
|
||||||
disk->srcpool &&
|
|
||||||
disk->srcpool->voltype == VIR_STORAGE_VOL_BLOCK)))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
path = disk->src;
|
path = disk->src;
|
||||||
|
Loading…
Reference in New Issue
Block a user