Just like for domain starting, the original unpriv_sgio state
is recorded for restoring when detaching.
---
src/qemu/qemu_driver.c | 48 +++++++++++++++++++++++++++++++++++++-----------
1 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2c36935..b75b6fe 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6042,17 +6042,43 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
NULLSTR(disk->src));
}
- /* If the attached disk is shareable, add it to the list
- * qemud_driver->sharedDisks if attachment succeeded
- */
- if (ret == 0 && disk->shared) {
- if (qemuSharedDiskListAdd(driver->sharedDisks,
- disk->src,
- vm->def->name) < 0) {
- VIR_DEBUG("Failed to add the disk '%s' of domain '%s' to
"
- "sharedDisks list", disk->src, vm->def->name);
- }
- }
+ if (ret == 0) {
+ if (disk->cdbfilter) {
+ int val;
+
+ /* Store the original unpriv_sgio state */
+ if (virGetDeviceUnprivSGIO(disk->src, &val) < 0) {
+ VIR_DEBUG("Failed to get unpriv_sgio of disk '%s'",
disk->src);
+ goto end;
+ }
+
+ if (val == 0)
+ disk->old_cdbfilter = VIR_DOMAIN_DISK_CDB_FILTER_YES;
+ else
+ disk->old_cdbfilter = VIR_DOMAIN_DISK_CDB_FILTER_NO;
+
+ /* Set unpriv_sgio */
+ if (virSetDeviceUnprivSGIO(disk->src,
+ (disk->cdbfilter ==
+ VIR_DOMAIN_DISK_CDB_FILTER_NO)
+ ? 1 : 0) < 0) {
+ VIR_DEBUG("Failed to set unpriv_sgio of disk '%s'",
disk->src);
+ goto end;
+ }
+ }
+
+ /* If the attached disk is shareable, add it to the list
+ * qemud_driver->sharedDisks if attachment succeeded
+ */
+ if (disk->shared) {
+ if (qemuSharedDiskListAdd(driver->sharedDisks,
+ disk->src,
+ vm->def->name) < 0) {
+ VIR_DEBUG("Failed to add the disk '%s' of domain
'%s' to "
+ "sharedDisks list", disk->src,
vm->def->name);
+ }
+ }
+ }
end:
if (cgroup)
virCgroupFree(&cgroup);
--
1.7.7.6