To record the original "unpriv_sgio" value, this introduces "old_unpriv_sgio" for disk def. When the domain is starting, the disk's "unpriv_sgio" is set with regards to the config in domain XML. And when the domain is being destroyed, it's restored to the original value ("old_unpriv_sgio") --- src/conf/domain_conf.h | 1 + src/qemu/qemu_process.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 105fb7d..1a8de71 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -616,6 +616,7 @@ struct _virDomainDiskDef { bool rawio_specified; int rawio; /* no = 0, yes = 1 */ int unpriv_sgio; /* no = 0, yes = 1 */ + int old_unpriv_sgio; /* To record the old unpriv_sgio value, internally */ size_t nseclabels; virSecurityDeviceLabelDefPtr *seclabels; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 3d7a5a0..e48eed0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3703,6 +3703,26 @@ int qemuProcessStart(virConnectPtr conn, virCommandAllowCap(cmd, CAP_SYS_RAWIO); } + /* Set unpriv_sgio for disks */ + for (i = 0; i < vm->def->ndisks; i++) { + virDomainDiskDefPtr disk = vm->def->disks[i]; + int old_unpriv_sgio; + + if (!disk->unpriv_sgio) + continue; + + if (virGetDeviceUnprivSGIO(disk->src, &old_unpriv_sgio) < 0) + goto cleanup; + + disk->old_unpriv_sgio = old_unpriv_sgio; + + if (virSetDeviceUnprivSGIO(disk->src, + (disk->unpriv_sgio == + VIR_DOMAIN_DISK_UNPRIV_SGIO_YES) + ? 1 : 0) < 0) + goto cleanup; + } + virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData); virCommandSetOutputFD(cmd, &logfile); @@ -4093,6 +4113,17 @@ void qemuProcessStop(struct qemud_driver *driver, flags & VIR_QEMU_PROCESS_STOP_MIGRATED); virSecurityManagerReleaseLabel(driver->securityManager, vm->def); + /* Restore disk's unpriv_sgio */ + for (i = 0; i < vm->def->ndisks; i++) { + virDomainDiskDefPtr disk = vm->def->disks[i]; + + if (!disk->unpriv_sgio) + continue; + + if (virSetDeviceUnprivSGIO(disk->src, disk->old_unpriv_sgio) < 0) + VIR_WARN("Unable to restore unpriv_sgio for disk '%s'", disk->src); + } + /* Clear out dynamically assigned labels */ for (i = 0; i < vm->def->nseclabels; i++) { if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) { -- 1.7.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list