[PATCH 1/3] conf: Add new VIR_DOMAIN_VIRT_NONE enum

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

 



Introduce VIR_DOMAIN_VIRT_NONE to give domaintype the default value of zero.
This is specially helpful in constructing better error messages
when we don't want to look up the default emulator by virtType.

The test data in vircapstest.c is also modified to reflect this change.
---
 src/conf/capabilities.c |  4 ++--
 src/conf/domain_conf.c  |  3 ++-
 src/conf/domain_conf.h  |  1 +
 tests/vircapstest.c     | 32 ++++++++++++++++----------------
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 9c2c6b4..533c925 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -584,7 +584,7 @@ virCapsDomainDataCompare(virCapsGuestPtr guest,
     if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch))
         return false;
 
-    if (domaintype != -1 && (!domain || domain->type != domaintype))
+    if (domaintype != VIR_DOMAIN_VIRT_NONE && (!domain || domain->type != domaintype))
         return false;
 
     if (emulator) {
@@ -678,7 +678,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
                               virDomainOSTypeToString(ostype));
         if (arch)
             virBufferAsprintf(&buf, "arch=%s ", virArchToString(arch));
-        if (domaintype != -1)
+        if (domaintype)
             virBufferAsprintf(&buf, "domaintype=%s ",
                               virDomainVirtTypeToString(domaintype));
         if (emulator)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6df1618..589546d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -106,6 +106,7 @@ VIR_ENUM_IMPL(virDomainTaint, VIR_DOMAIN_TAINT_LAST,
               "custom-dtb");
 
 VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST,
+              "none",
               "qemu",
               "kqemu",
               "kvm",
@@ -14815,7 +14816,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         virCapsDomainDataPtr capsdata = NULL;
 
         if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
-                def->os.arch, use_virttype ? def->virtType : -1,
+                def->os.arch, use_virttype ? def->virtType : VIR_DOMAIN_VIRT_NONE,
                 NULL, NULL)))
             goto error;
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f043554..16f449d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -209,6 +209,7 @@ struct _virDomainDeviceDef {
 /* Different types of hypervisor */
 /* NB: Keep in sync with virDomainVirtTypeToString impl */
 typedef enum {
+    VIR_DOMAIN_VIRT_NONE = 0,
     VIR_DOMAIN_VIRT_QEMU,
     VIR_DOMAIN_VIRT_KQEMU,
     VIR_DOMAIN_VIRT_KVM,
diff --git a/tests/vircapstest.c b/tests/vircapstest.c
index 3b41654..acb0c03 100644
--- a/tests/vircapstest.c
+++ b/tests/vircapstest.c
@@ -223,39 +223,39 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED)
     }
 
     /* Checking each parameter individually */
-    CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, NULL,
+    CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL,
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
         VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-x86_64", "pc-0.11");
-    CAPSCOMP(VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_NONE, -1, NULL, NULL,
+    CAPSCOMP(VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL,
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
         VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-x86_64", "pc-0.11");
-    CAPSCOMP(-1, VIR_ARCH_AARCH64, -1, NULL, NULL,
+    CAPSCOMP(-1, VIR_ARCH_AARCH64, VIR_DOMAIN_VIRT_NONE, NULL, NULL,
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_AARCH64,
         VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-aarch64", "virt");
     CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM, NULL, NULL,
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
         VIR_DOMAIN_VIRT_KVM, "/usr/bin/kvm", "pc");
-    CAPSCOMP(-1, VIR_ARCH_NONE, -1, "/usr/bin/qemu-system-ppc64", NULL,
+    CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, "/usr/bin/qemu-system-ppc64", NULL,
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64,
         VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries");
-    CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, "s390-virtio",
+    CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, "s390-virtio",
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_S390X,
         VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-s390x",
         "s390-virtio");
 
-    CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, "pseries",
+    CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, "pseries",
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64,
         VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries");
-    CAPSCOMP(-1, VIR_ARCH_PPC64LE, -1, NULL, "pseries",
+    CAPSCOMP(-1, VIR_ARCH_PPC64LE, VIR_DOMAIN_VIRT_NONE, NULL, "pseries",
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64LE,
         VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries");
 
-    CAPS_EXPECT_ERR(VIR_DOMAIN_OSTYPE_LINUX, VIR_ARCH_NONE, -1, NULL, NULL);
-    CAPS_EXPECT_ERR(-1, VIR_ARCH_PPC64LE, -1, NULL, "pc");
-    CAPS_EXPECT_ERR(-1, VIR_ARCH_MIPS, -1, NULL, NULL);
+    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, -1,
+    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");
 
@@ -277,14 +277,14 @@ test_virCapsDomainDataLookupXen(const void *data ATTRIBUTE_UNUSED)
         goto out;
     }
 
-    CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, NULL,
+    CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL,
         VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, VIR_DOMAIN_VIRT_XEN,
         "/usr/lib/xen/bin/qemu-dm", "xenfv");
-    CAPSCOMP(VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_NONE, -1, NULL, NULL,
+    CAPSCOMP(VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL,
         VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_I686, VIR_DOMAIN_VIRT_XEN,
         "/usr/lib/xen/bin/qemu-dm", "xenpv");
 
-    CAPS_EXPECT_ERR(VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_NONE, -1, NULL, "xenfv");
+    CAPS_EXPECT_ERR(VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, "xenfv");
 
     ret = 0;
  out:
@@ -305,10 +305,10 @@ test_virCapsDomainDataLookupLXC(const void *data ATTRIBUTE_UNUSED)
         goto out;
     }
 
-    CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, NULL,
+    CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL,
         VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64,
         VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL);
-    CAPSCOMP(-1, VIR_ARCH_X86_64, -1, NULL, NULL,
+    CAPSCOMP(-1, VIR_ARCH_X86_64, VIR_DOMAIN_VIRT_NONE, NULL, NULL,
         VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64,
         VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL);
 
-- 
1.9.1

--
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]