]> xenbits.xensource.com Git - libvirt.git/commitdiff
Move qemuCheckCCWS390AddressSupport to qemu_domain
authorJán Tomko <jtomko@redhat.com>
Wed, 11 Oct 2017 13:06:07 +0000 (15:06 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 19 Oct 2017 12:39:05 +0000 (14:39 +0200)
Let it be reused in qemu_domain_address.

src/qemu/qemu_command.c
src/qemu/qemu_command.h
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_hotplug.c

index c12e65785939919326b0fe284cb637f572afc2b1..b85484a7c5b2f1dbd52d47a528ffdfe5af623c35 100644 (file)
@@ -1262,46 +1262,6 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk)
 }
 
 
-/* Check whether the device address is using either 'ccw' or default s390
- * address format and whether that's "legal" for the current qemu and/or
- * guest os.machine type. This is the corollary to the code which doesn't
- * find the address type set using an emulator that supports either 'ccw'
- * or s390 and sets the address type based on the capabilities.
- *
- * If the address is using 'ccw' or s390 and it's not supported, generate
- * an error and return false; otherwise, return true.
- */
-bool
-qemuCheckCCWS390AddressSupport(const virDomainDef *def,
-                               virDomainDeviceInfo info,
-                               virQEMUCapsPtr qemuCaps,
-                               const char *devicename)
-{
-    if (info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-        if (!qemuDomainIsS390CCW(def)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("cannot use CCW address type for device "
-                             "'%s' using machine type '%s'"),
-                       devicename, def->os.machine);
-            return false;
-        } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("CCW address type is not supported by "
-                             "this QEMU"));
-            return false;
-        }
-    } else if (info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("virtio S390 address type is not supported by "
-                             "this QEMU"));
-            return false;
-        }
-    }
-    return true;
-}
-
-
 /* QEMU 1.2 and later have a binary flag -enable-fips that must be
  * used for VNC auth to obey FIPS settings; but the flag only
  * exists on Linux, and with no way to probe for it via QMP.  Our
@@ -1951,7 +1911,7 @@ qemuBuildDriveDevStr(const virDomainDef *def,
     if (qemuCheckDiskConfig(disk) < 0)
         goto error;
 
-    if (!qemuCheckCCWS390AddressSupport(def, disk->info, qemuCaps, disk->dst))
+    if (!qemuDomainCheckCCWS390AddressSupport(def, disk->info, qemuCaps, disk->dst))
         goto error;
 
     if (disk->iothread && !qemuCheckIOThreads(def, disk))
@@ -2685,8 +2645,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 
     *devstr = NULL;
 
-    if (!qemuCheckCCWS390AddressSupport(domainDef, def->info, qemuCaps,
-                                        "controller"))
+    if (!qemuDomainCheckCCWS390AddressSupport(domainDef, def->info, qemuCaps,
+                                              "controller"))
         return -1;
 
     if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
@@ -5895,8 +5855,8 @@ qemuBuildRNGDevStr(const virDomainDef *def,
         goto error;
     }
 
-    if (!qemuCheckCCWS390AddressSupport(def, dev->info, qemuCaps,
-                                        dev->source.file))
+    if (!qemuDomainCheckCCWS390AddressSupport(def, dev->info, qemuCaps,
+                                              dev->source.file))
         goto error;
 
     if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)
index e1ddc43d628bef379772d09c43575a2f84c71f9a..48ee502aa71d04ddfda63f9c1681b8360baedcd9 100644 (file)
@@ -182,11 +182,6 @@ int qemuCheckDiskConfig(virDomainDiskDefPtr disk);
 bool
 qemuCheckFips(void);
 
-bool qemuCheckCCWS390AddressSupport(const virDomainDef *def,
-                                    virDomainDeviceInfo info,
-                                    virQEMUCapsPtr qemuCaps,
-                                    const char *devicename);
-
 virJSONValuePtr qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
     ATTRIBUTE_NONNULL(1);
 
index 42db316ef7351bd3fdb3a3846b3b2a7d98e09196..23b9c6c1387e101a1dd6fcb8ad9d5a9f4473b6d7 100644 (file)
@@ -10162,3 +10162,43 @@ qemuDomainGetMachineName(virDomainObjPtr vm)
 
     return ret;
 }
+
+
+/* Check whether the device address is using either 'ccw' or default s390
+ * address format and whether that's "legal" for the current qemu and/or
+ * guest os.machine type. This is the corollary to the code which doesn't
+ * find the address type set using an emulator that supports either 'ccw'
+ * or s390 and sets the address type based on the capabilities.
+ *
+ * If the address is using 'ccw' or s390 and it's not supported, generate
+ * an error and return false; otherwise, return true.
+ */
+bool
+qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
+                                     virDomainDeviceInfo info,
+                                     virQEMUCapsPtr qemuCaps,
+                                     const char *devicename)
+{
+    if (info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+        if (!qemuDomainIsS390CCW(def)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("cannot use CCW address type for device "
+                             "'%s' using machine type '%s'"),
+                       devicename, def->os.machine);
+            return false;
+        } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("CCW address type is not supported by "
+                             "this QEMU"));
+            return false;
+        }
+    } else if (info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("virtio S390 address type is not supported by "
+                             "this QEMU"));
+            return false;
+        }
+    }
+    return true;
+}
index 1c99be4c28a57687d2e0ba938caab77f8e5b159e..7c9364f35ee53cb9759b1033e654d12f9e71eb5e 100644 (file)
@@ -987,4 +987,9 @@ int
 qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
                                         virTristateBool *allowReboot);
 
+bool qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
+                                    virDomainDeviceInfo info,
+                                    virQEMUCapsPtr qemuCaps,
+                                    const char *devicename);
+
 #endif /* __QEMU_DOMAIN_H__ */
index 1e7931a84ac4ca95ade219c156c0aa4dcaf73e92..1885123c692ff9171bca3806f491445fe9c8263e 100644 (file)
@@ -379,8 +379,8 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
         else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
             disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390;
     } else {
-        if (!qemuCheckCCWS390AddressSupport(vm->def, disk->info, priv->qemuCaps,
-                                            disk->dst))
+        if (!qemuDomainCheckCCWS390AddressSupport(vm->def, disk->info, priv->qemuCaps,
+                                                  disk->dst))
             goto cleanup;
     }
 
@@ -553,8 +553,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
         else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
             controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390;
     } else {
-        if (!qemuCheckCCWS390AddressSupport(vm->def, controller->info,
-                                            priv->qemuCaps, "controller"))
+        if (!qemuDomainCheckCCWS390AddressSupport(vm->def, controller->info,
+                                                  priv->qemuCaps, "controller"))
             goto cleanup;
     }
 
@@ -2158,8 +2158,8 @@ qemuDomainAttachRNGDevice(virConnectPtr conn,
             rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390;
         }
     } else {
-        if (!qemuCheckCCWS390AddressSupport(vm->def, rng->info, priv->qemuCaps,
-                                            "rng"))
+        if (!qemuDomainCheckCCWS390AddressSupport(vm->def, rng->info, priv->qemuCaps,
+                                                  "rng"))
             goto cleanup;
     }