]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainDeviceDefValidate: Validate watchdog
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 27 Sep 2017 11:45:07 +0000 (13:45 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 5 Oct 2017 12:23:20 +0000 (14:23 +0200)
Currently we don't do it. Therefore we accept senseless
combinations of models and buses they are attached to.
Moreover, diag288 watchdog is exclusive to s390(x).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c

index a8c718f62df4eb2c54ab1506f9727833a8189adb..2bcc9839d1a137a15b068152e0b680fe3bbb9186 100644 (file)
@@ -3366,6 +3366,54 @@ qemuDomainRedirdevDefValidate(const virDomainRedirdevDef *def)
 }
 
 
+static int
+qemuDomainWatchdogDefValidate(const virDomainWatchdogDef *dev,
+                              const virDomainDef *def)
+{
+    switch ((virDomainWatchdogModel) dev->model) {
+    case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
+        if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+            dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("%s model of watchog can go only on PCI bus"),
+                           virDomainWatchdogModelTypeToString(dev->model));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_WATCHDOG_MODEL_IB700:
+        if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+            dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("%s model of watchog can go only on ISA bus"),
+                           virDomainWatchdogModelTypeToString(dev->model));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_WATCHDOG_MODEL_DIAG288:
+        if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("%s model of watchog is virtual and cannot go on any bus."),
+                           virDomainWatchdogModelTypeToString(dev->model));
+            return -1;
+        }
+        if (!(ARCH_IS_S390(def->os.arch))) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("%s model of watchdog is allowed for s390 and s390x only"),
+                           virDomainWatchdogModelTypeToString(dev->model));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_WATCHDOG_MODEL_LAST:
+        break;
+    }
+
+    return 0;
+}
+
+
 static int
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                             const virDomainDef *def,
@@ -3474,6 +3522,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
     } else if (dev->type == VIR_DOMAIN_DEVICE_REDIRDEV) {
         if (qemuDomainRedirdevDefValidate(dev->data.redirdev) < 0)
             goto cleanup;
+    } else if (dev->type == VIR_DOMAIN_DEVICE_WATCHDOG) {
+        if (qemuDomainWatchdogDefValidate(dev->data.watchdog, def) < 0)
+            goto cleanup;
     }
 
     /* forbid capabilities mode hostdev in this kind of hypervisor */