[libvirt] [PATCH 04/17] qemu: Move CCW S390 Address check to controller def validate

John Ferlan posted 17 patches 7 years, 5 months ago
There is a newer version of this series
[libvirt] [PATCH 04/17] qemu: Move CCW S390 Address check to controller def validate
Posted by John Ferlan 7 years, 5 months ago
Move the call to qemuDomainCheckCCWS390AddressSupport from
qemuBuildControllerDevStr to qemuDomainDeviceDefValidateController.

This means we will get the qemuCaps from the driver opaque
variable passed to qemuDomainDeviceDefValidate.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/qemu/qemu_command.c |  4 ----
 src/qemu/qemu_domain.c  | 18 +++++++++++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 818a057bc..15d9209c6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2662,10 +2662,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 
     *devstr = NULL;
 
-    if (!qemuDomainCheckCCWS390AddressSupport(domainDef, def->info, qemuCaps,
-                                              "controller"))
-        return -1;
-
     if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
         if ((qemuDomainSetSCSIControllerModel(domainDef, qemuCaps, &model)) < 0)
             return -1;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d4c7674c0..1fc360af9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3960,7 +3960,8 @@ qemuDomainDeviceDefSkipController(const virDomainControllerDef *controller,
 
 static int
 qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
-                                      const virDomainDef *def)
+                                      const virDomainDef *def,
+                                      virQEMUCapsPtr qemuCaps)
 {
     unsigned int flags = 0;
 
@@ -3970,6 +3971,10 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
     if (flags & QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FAIL_FLAG)
         return -1;
 
+    if (!qemuDomainCheckCCWS390AddressSupport(def, controller->info, qemuCaps,
+                                              "controller"))
+        return -1;
+
     switch ((virDomainControllerType) controller->type) {
     case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
     case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
@@ -3990,9 +3995,15 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
 static int
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                             const virDomainDef *def,
-                            void *opaque ATTRIBUTE_UNUSED)
+                            void *opaque)
 {
     int ret = 0;
+    virQEMUDriverPtr driver = opaque;
+    virQEMUCapsPtr qemuCaps = NULL;
+
+    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
+                                            def->emulator)))
+        return -1;
 
     switch ((virDomainDeviceType) dev->type) {
     case VIR_DOMAIN_DEVICE_NET:
@@ -4032,7 +4043,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         break;
 
     case VIR_DOMAIN_DEVICE_CONTROLLER:
-        ret = qemuDomainDeviceDefValidateController(dev->data.controller, def);
+        ret = qemuDomainDeviceDefValidateController(dev->data.controller, def,
+                                                    qemuCaps);
         break;
 
     case VIR_DOMAIN_DEVICE_LEASE:
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 04/17] qemu: Move CCW S390 Address check to controller def validate
Posted by Ján Tomko 7 years, 5 months ago
On Mon, Dec 04, 2017 at 08:38:54PM -0500, John Ferlan wrote:
>Move the call to qemuDomainCheckCCWS390AddressSupport from
>qemuBuildControllerDevStr to qemuDomainDeviceDefValidateController.
>
>This means we will get the qemuCaps from the driver opaque
>variable passed to qemuDomainDeviceDefValidate.
>
>Signed-off-by: John Ferlan <jferlan@redhat.com>
>---
> src/qemu/qemu_command.c |  4 ----
> src/qemu/qemu_domain.c  | 18 +++++++++++++++---
> 2 files changed, 15 insertions(+), 7 deletions(-)
>

>@@ -3990,9 +3995,15 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
> static int
> qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
>                             const virDomainDef *def,
>-                            void *opaque ATTRIBUTE_UNUSED)
>+                            void *opaque)
> {
>     int ret = 0;
>+    virQEMUDriverPtr driver = opaque;
>+    virQEMUCapsPtr qemuCaps = NULL;
>+
>+    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
>+                                            def->emulator)))
>+        return -1;

The corresponding Unref should be a part of this patch

Jan

>
>     switch ((virDomainDeviceType) dev->type) {
>     case VIR_DOMAIN_DEVICE_NET:
>@@ -4032,7 +4043,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
>         break;
>
>     case VIR_DOMAIN_DEVICE_CONTROLLER:
>-        ret = qemuDomainDeviceDefValidateController(dev->data.controller, def);
>+        ret = qemuDomainDeviceDefValidateController(dev->data.controller, def,
>+                                                    qemuCaps);
>         break;
>
>     case VIR_DOMAIN_DEVICE_LEASE:
>-- 
>2.13.6
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list