[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/6] unpriv_sgio: Manage unpriv_sgio in domain's lifecyle



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 |   19 ++++++++++---------
 2 files changed, 11 insertions(+), 9 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 98096c5..e48eed0 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3706,19 +3706,20 @@ int qemuProcessStart(virConnectPtr conn,
     /* Set unpriv_sgio for disks */
     for (i = 0; i < vm->def->ndisks; i++) {
         virDomainDiskDefPtr disk = vm->def->disks[i];
-        int old_sgio;
+        int old_unpriv_sgio;
 
-        if (!disk->sgio)
+        if (!disk->unpriv_sgio)
             continue;
 
-        if (virGetDeviceSGIO(disk->src, &old_sgio) < 0)
+        if (virGetDeviceUnprivSGIO(disk->src, &old_unpriv_sgio) < 0)
             goto cleanup;
 
-        disk->old_sgio = old_sgio;
+        disk->old_unpriv_sgio = old_unpriv_sgio;
 
-        if (virSetDeviceSGIO(disk->src,
-                             (disk->sgio == VIR_DOMAIN_DISK_SGIO_YES)
-                             ? 1 : 0) < 0)
+        if (virSetDeviceUnprivSGIO(disk->src,
+                                   (disk->unpriv_sgio ==
+                                    VIR_DOMAIN_DISK_UNPRIV_SGIO_YES)
+                                   ? 1 : 0) < 0)
             goto cleanup;
     }
 
@@ -4116,10 +4117,10 @@ void qemuProcessStop(struct qemud_driver *driver,
     for (i = 0; i < vm->def->ndisks; i++) {
         virDomainDiskDefPtr disk = vm->def->disks[i];
 
-        if (!disk->sgio)
+        if (!disk->unpriv_sgio)
             continue;
 
-        if (virSetDeviceSGIO(disk->src, disk->old_sgio) < 0)
+        if (virSetDeviceUnprivSGIO(disk->src, disk->old_unpriv_sgio) < 0)
             VIR_WARN("Unable to restore unpriv_sgio for disk '%s'", disk->src);
     }
 
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]