diff mbox series

[4/7] conf: Drop unneccessary caps parsing logic

Message ID 2622a099eb9fc903cddc3c99e18876b671338f58.1532467269.git.crobinso@redhat.com
State Accepted
Commit b251d6ad24b00000664080ba7fb32be2a0baa4d3
Headers show
Series conf: Replace SKIP_OSTYPE with SKIP_VALIDATE | expand

Commit Message

Cole Robinson July 24, 2018, 9:23 p.m. UTC
The comment says:

    /* If the logic here seems fairly arbitrary, that's because it is :)
     * This is duplicating how the code worked before
     * CapabilitiesDomainDataLookup was added. We can simplify this,
     * but it would take a bit of work because the test suite fails
     * in numerous minor ways. */

Nowadays the test suite changes appear quite simple, just extending
test capabilities data a bit so that we aren't trying to define
invalid arch/os/virtType/machine combos

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/conf/domain_conf.c | 15 ++-------------
 tests/testutils.c      | 13 ++++++++++++-
 tests/testutilsqemu.c  | 18 ++++++++++++++++++
 tests/vircapstest.c    |  2 --
 4 files changed, 32 insertions(+), 16 deletions(-)

-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5a90429cd6..b7f6a22e20 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19178,20 +19178,9 @@  virDomainDefParseCaps(virDomainDefPtr def,
         goto cleanup;
     }
 
-    if ((!def->os.arch || !def->os.machine) &&
-        !(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) {
-        /* If the logic here seems fairly arbitrary, that's because it is :)
-         * This is duplicating how the code worked before
-         * CapabilitiesDomainDataLookup was added. We can simplify this,
-         * but it would take a bit of work because the test suite fails
-         * in numerous minor ways. */
-        bool use_virttype = ((def->os.arch == VIR_ARCH_NONE) ||
-            !def->os.machine);
-
+    if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) {
         if (!(capsdata = virCapabilitiesDomainDataLookup(caps,
-                def->os.type,
-                def->os.arch,
-                use_virttype ? def->virtType : VIR_DOMAIN_VIRT_NONE,
+                def->os.type, def->os.arch, def->virtType,
                 NULL, NULL)))
             goto cleanup;
 
diff --git a/tests/testutils.c b/tests/testutils.c
index 423f4bfdff..ab938c12fc 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -1196,7 +1196,12 @@  virCapsPtr virTestGenericCapsInit(void)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, NULL, 0, NULL))
         goto error;
-
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
+                                       NULL, NULL, 0, NULL))
+        goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
     if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
                                          "/usr/bin/acme-virt", NULL,
@@ -1205,6 +1210,12 @@  virCapsPtr virTestGenericCapsInit(void)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, NULL, 0, NULL))
         goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
+                                       NULL, NULL, 0, NULL))
+        goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
 
     if (virTestGetDebug() > 1) {
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index dc7e90b952..cc2f8a7b64 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -219,6 +219,9 @@  static int testQemuAddPPC64Guest(virCapsPtr caps)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
         goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
     return 0;
 
@@ -246,6 +249,9 @@  static int testQemuAddPPC64LEGuest(virCapsPtr caps)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
         goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
     return 0;
 
@@ -276,6 +282,9 @@  static int testQemuAddPPCGuest(virCapsPtr caps)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
         goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
     return 0;
 
@@ -307,6 +316,9 @@  static int testQemuAddS390Guest(virCapsPtr caps)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
         goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
     return 0;
 
@@ -338,6 +350,9 @@  static int testQemuAddArmGuest(virCapsPtr caps)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
         goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
     return 0;
 
@@ -367,6 +382,9 @@  static int testQemuAddAARCH64Guest(virCapsPtr caps)
 
     if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
         goto error;
+    if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
+                                       NULL, NULL, 0, NULL))
+        goto error;
 
     return 0;
 
diff --git a/tests/vircapstest.c b/tests/vircapstest.c
index 1df3fa091f..19e3c79302 100644
--- a/tests/vircapstest.c
+++ b/tests/vircapstest.c
@@ -195,8 +195,6 @@  test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED)
     CAPS_EXPECT_ERR(VIR_DOMAIN_OSTYPE_LINUX, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL);
     CAPS_EXPECT_ERR(-1, VIR_ARCH_PPC64LE, VIR_DOMAIN_VIRT_NONE, NULL, "pc");
     CAPS_EXPECT_ERR(-1, VIR_ARCH_MIPS, VIR_DOMAIN_VIRT_NONE, NULL, NULL);
-    CAPS_EXPECT_ERR(-1, VIR_ARCH_AARCH64, VIR_DOMAIN_VIRT_KVM,
-        "/usr/bin/qemu-system-aarch64", NULL);
     CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE,
         "/usr/bin/qemu-system-aarch64", "pc");
     CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc");