[PATCH 6/8] conf: add compatiblity check for boot index when updating device

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

 



Signed-off-by: Wang Rui <moon.wangrui@xxxxxxxxxx>
Signed-off-by: Zhou Yimin <zhouyimin@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d2c4a0a..5beb830 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19991,29 +19991,32 @@ virDomainDefCompatibleDevice(virDomainDefPtr def,
 {
     virDomainDeviceInfoPtr info = virDomainDeviceGetInfo(dev);
 
-    if (action != VIR_DOMAIN_DEVICE_ACTION_ATTACH)
-        return 0;
-
-    if (!virDomainDefHasUSB(def) &&
-        STRNEQ(def->os.type, "exe") &&
-        virDomainDeviceIsUSB(dev)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Device configuration is not compatible: "
-                         "Domain has no USB bus support"));
-        return -1;
-    }
-
-    if (info && info->bootIndex > 0) {
-        if (def->os.nBootDevs > 0) {
+    switch (action) {
+    case VIR_DOMAIN_DEVICE_ACTION_ATTACH:
+        if (!virDomainDefHasUSB(def) &&
+            STRNEQ(def->os.type, "exe") &&
+            virDomainDeviceIsUSB(dev)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("per-device boot elements cannot be used"
-                             " together with os/boot elements"));
+                           _("Device configuration is not compatible: "
+                             "Domain has no USB bus support"));
             return -1;
         }
-        if (virDomainDeviceInfoIterate(def,
-                                       virDomainDeviceInfoCheckBootIndex,
-                                       info) < 0)
-            return -1;
+    case VIR_DOMAIN_DEVICE_ACTION_UPDATE:
+        if (info && info->bootIndex > 0) {
+            if (def->os.nBootDevs > 0) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("per-device boot elements cannot be used"
+                                 " together with os/boot elements"));
+                return -1;
+            }
+            if (virDomainDeviceInfoIterate(def,
+                                           virDomainDeviceInfoCheckBootIndex,
+                                           info) < 0)
+                return -1;
+        }
+        break;
+    default:
+        return 0;
     }
 
     return 0;
-- 
1.7.12.4


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]