提交 62569e45 编写于 作者: S Shivangi Dhir 提交者: John Ferlan

conf: Add new VIR_DOMAIN_VIRT_NONE enum

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.
上级 fd00f0e6
/* /*
* capabilities.c: hypervisor capabilities * capabilities.c: hypervisor capabilities
* *
* Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006-2015 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (C) 2006-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -573,7 +573,7 @@ virCapsDomainDataCompare(virCapsGuestPtr guest, ...@@ -573,7 +573,7 @@ virCapsDomainDataCompare(virCapsGuestPtr guest,
virCapsGuestMachinePtr machine, virCapsGuestMachinePtr machine,
int ostype, int ostype,
virArch arch, virArch arch,
int domaintype, virDomainVirtType domaintype,
const char *emulator, const char *emulator,
const char *machinetype) const char *machinetype)
{ {
...@@ -584,7 +584,8 @@ virCapsDomainDataCompare(virCapsGuestPtr guest, ...@@ -584,7 +584,8 @@ virCapsDomainDataCompare(virCapsGuestPtr guest,
if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch)) if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch))
return false; return false;
if (domaintype != -1 && (!domain || domain->type != domaintype)) if (domaintype != VIR_DOMAIN_VIRT_NONE &&
(!domain || domain->type != domaintype))
return false; return false;
if (emulator) { if (emulator) {
...@@ -611,7 +612,7 @@ static virCapsDomainDataPtr ...@@ -611,7 +612,7 @@ static virCapsDomainDataPtr
virCapabilitiesDomainDataLookupInternal(virCapsPtr caps, virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
int ostype, int ostype,
virArch arch, virArch arch,
int domaintype, virDomainVirtType domaintype,
const char *emulator, const char *emulator,
const char *machinetype) const char *machinetype)
{ {
...@@ -678,7 +679,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps, ...@@ -678,7 +679,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
virDomainOSTypeToString(ostype)); virDomainOSTypeToString(ostype));
if (arch) if (arch)
virBufferAsprintf(&buf, "arch=%s ", virArchToString(arch)); virBufferAsprintf(&buf, "arch=%s ", virArchToString(arch));
if (domaintype != -1) if (domaintype > VIR_DOMAIN_VIRT_NONE)
virBufferAsprintf(&buf, "domaintype=%s ", virBufferAsprintf(&buf, "domaintype=%s ",
virDomainVirtTypeToString(domaintype)); virDomainVirtTypeToString(domaintype));
if (emulator) if (emulator)
...@@ -723,7 +724,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps, ...@@ -723,7 +724,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
* @caps: capabilities to query * @caps: capabilities to query
* @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
* @arch: Architecture to search for * @arch: Architecture to search for
* @domaintype: domain type to search for, of enum VIR_DOMAIN_VIRT * @domaintype: domain type to search for, of enum virDomainVirtType
* @emulator: Emulator path to search for * @emulator: Emulator path to search for
* @machinetype: Machine type to search for * @machinetype: Machine type to search for
* *
......
/* /*
* capabilities.h: hypervisor capabilities * capabilities.h: hypervisor capabilities
* *
* Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006-2015 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (C) 2006-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -61,7 +61,7 @@ struct _virCapsGuestDomainInfo { ...@@ -61,7 +61,7 @@ struct _virCapsGuestDomainInfo {
typedef struct _virCapsGuestDomain virCapsGuestDomain; typedef struct _virCapsGuestDomain virCapsGuestDomain;
typedef virCapsGuestDomain *virCapsGuestDomainPtr; typedef virCapsGuestDomain *virCapsGuestDomainPtr;
struct _virCapsGuestDomain { struct _virCapsGuestDomain {
int type; int type; /* virDomainVirtType */
virCapsGuestDomainInfo info; virCapsGuestDomainInfo info;
}; };
...@@ -197,7 +197,7 @@ typedef virCapsDomainData *virCapsDomainDataPtr; ...@@ -197,7 +197,7 @@ typedef virCapsDomainData *virCapsDomainDataPtr;
struct _virCapsDomainData { struct _virCapsDomainData {
int ostype; int ostype;
int arch; int arch;
int domaintype; int domaintype; /* virDomainVirtType */
const char *emulator; const char *emulator;
const char *machinetype; const char *machinetype;
}; };
......
...@@ -106,6 +106,7 @@ VIR_ENUM_IMPL(virDomainTaint, VIR_DOMAIN_TAINT_LAST, ...@@ -106,6 +106,7 @@ VIR_ENUM_IMPL(virDomainTaint, VIR_DOMAIN_TAINT_LAST,
"custom-dtb"); "custom-dtb");
VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST, VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST,
"none",
"qemu", "qemu",
"kqemu", "kqemu",
"kvm", "kvm",
...@@ -14738,7 +14739,7 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -14738,7 +14739,7 @@ virDomainDefParseXML(xmlDocPtr xml,
virCapsDomainDataPtr capsdata = NULL; virCapsDomainDataPtr capsdata = NULL;
if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, 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))) NULL, NULL)))
goto error; goto error;
......
...@@ -209,6 +209,7 @@ struct _virDomainDeviceDef { ...@@ -209,6 +209,7 @@ struct _virDomainDeviceDef {
/* Different types of hypervisor */ /* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */ /* NB: Keep in sync with virDomainVirtTypeToString impl */
typedef enum { typedef enum {
VIR_DOMAIN_VIRT_NONE = 0,
VIR_DOMAIN_VIRT_QEMU, VIR_DOMAIN_VIRT_QEMU,
VIR_DOMAIN_VIRT_KQEMU, VIR_DOMAIN_VIRT_KQEMU,
VIR_DOMAIN_VIRT_KVM, VIR_DOMAIN_VIRT_KVM,
......
...@@ -223,39 +223,39 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED) ...@@ -223,39 +223,39 @@ test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED)
} }
/* Checking each parameter individually */ /* 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_OSTYPE_HVM, VIR_ARCH_X86_64,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-x86_64", "pc-0.11"); 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_OSTYPE_HVM, VIR_ARCH_X86_64,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-x86_64", "pc-0.11"); 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_OSTYPE_HVM, VIR_ARCH_AARCH64,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-aarch64", "virt"); VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-aarch64", "virt");
CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM, NULL, NULL, CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM, NULL, NULL,
VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
VIR_DOMAIN_VIRT_KVM, "/usr/bin/kvm", "pc"); 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_OSTYPE_HVM, VIR_ARCH_PPC64,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries"); 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_OSTYPE_HVM, VIR_ARCH_S390X,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-s390x", VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-s390x",
"s390-virtio"); "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_OSTYPE_HVM, VIR_ARCH_PPC64,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries"); 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_OSTYPE_HVM, VIR_ARCH_PPC64LE,
VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries"); 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(VIR_DOMAIN_OSTYPE_LINUX, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL);
CAPS_EXPECT_ERR(-1, VIR_ARCH_PPC64LE, -1, NULL, "pc"); CAPS_EXPECT_ERR(-1, VIR_ARCH_PPC64LE, VIR_DOMAIN_VIRT_NONE, NULL, "pc");
CAPS_EXPECT_ERR(-1, VIR_ARCH_MIPS, -1, NULL, NULL); CAPS_EXPECT_ERR(-1, VIR_ARCH_MIPS, VIR_DOMAIN_VIRT_NONE, NULL, NULL);
CAPS_EXPECT_ERR(-1, VIR_ARCH_AARCH64, VIR_DOMAIN_VIRT_KVM, CAPS_EXPECT_ERR(-1, VIR_ARCH_AARCH64, VIR_DOMAIN_VIRT_KVM,
"/usr/bin/qemu-system-aarch64", NULL); "/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"); "/usr/bin/qemu-system-aarch64", "pc");
CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "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) ...@@ -277,14 +277,14 @@ test_virCapsDomainDataLookupXen(const void *data ATTRIBUTE_UNUSED)
goto out; 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, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, VIR_DOMAIN_VIRT_XEN,
"/usr/lib/xen/bin/qemu-dm", "xenfv"); "/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, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_I686, VIR_DOMAIN_VIRT_XEN,
"/usr/lib/xen/bin/qemu-dm", "xenpv"); "/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; ret = 0;
out: out:
...@@ -305,10 +305,10 @@ test_virCapsDomainDataLookupLXC(const void *data ATTRIBUTE_UNUSED) ...@@ -305,10 +305,10 @@ test_virCapsDomainDataLookupLXC(const void *data ATTRIBUTE_UNUSED)
goto out; 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_OSTYPE_EXE, VIR_ARCH_X86_64,
VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); 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_OSTYPE_EXE, VIR_ARCH_X86_64,
VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册