From: Masayoshi Mizuma <m.mizuma(a)jp.fujitsu.com>
Enable <shareable/> disk option for transient disk hotplug.
Signed-off-by: Masayoshi Mizuma <m.mizuma(a)jp.fujitsu.com>
---
src/qemu/qemu_hotplug.c | 3 +++
src/qemu/qemu_validate.c | 21 +++++++++++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 138645260f..04b76db5e3 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1124,6 +1124,9 @@ qemuHotplugDiskPrepareOneDiskTransient(virQEMUDriverPtr driver,
QEMU_ASYNC_JOB_NONE, created) < 0)
return -1;
+ if (origsrc->shared)
+ origsrc->readonly = true;
+
transrc->backingStore = origsrc;
disk->src = transrc;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 6043f974ce..5426e7a784 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2907,6 +2907,23 @@ qemuValidateDomainDeviceDefDiskTransient(const virDomainDiskDef
*disk,
}
+static bool
+qemuValidateDomainDeviceDefDiskShareable(const virDomainDiskDef *disk)
+{
+ virDomainDiskBus bus = (virDomainDiskBus) disk->bus;
+
+ if (!disk->src->readonly && !disk->transient &&
+ !qemuBlockStorageSourceSupportsConcurrentAccess(disk->src))
+ return false;
+ else if (disk->transient &&
+ (bus != VIR_DOMAIN_DISK_BUS_VIRTIO) &&
+ (bus != VIR_DOMAIN_DISK_BUS_SCSI))
+ return false;
+ else
+ return true;
+}
+
+
int
qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
const virDomainDef *def,
@@ -2927,8 +2944,8 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
if (qemuValidateDomainDeviceDefDiskTransient(disk, qemuCaps) < 0)
return -1;
- if (disk->src->shared && !disk->src->readonly &&
- !qemuBlockStorageSourceSupportsConcurrentAccess(disk->src)) {
+ if (disk->src->shared &&
+ !qemuValidateDomainDeviceDefDiskShareable(disk)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("shared access for disk '%s' requires use of
"
"supported storage format"), disk->dst);
--
2.27.0