[libvirt] [PATCH 00/11] caps: various internal cleanups

First two patches are straight bug fixes. The rest is a bunch of internal cleanup I felt compelled to do. Summary is - Switch caps and domain to use an enum for os.type value (hvm, xen, exe, ...) - Switch caps to use VIR_DOMAIN_VIRT* internally - Add a single function for looking up domain XML relevant values from capabilities, and test the crap out of it. - Use that function to simplfy and improve a lot of code. Thanks, Cole Cole Robinson (11): domain: conf: Better errors on bad os <type> values domain: conf: Don't validate VM ostype/arch at daemon startup caps: Use an enum internally for ostype value caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value domain: Convert os.type to VIR_DOMAIN_OSTYPE enum caps: Convert to use VIR_DOMAIN_VIRT internally caps: Add virCapabilitiesDomainDataLookup domain: conf: Do ostype/arch/machine parsing earlier domain: conf: Use CapabilitiesDomainDataLookup for caps validation caps: Use DomainDataLookup to replace GuestDefault* domain: conf: Drop expectedVirtTypes src/bhyve/bhyve_capabilities.c | 6 +- src/bhyve/bhyve_driver.c | 5 - src/conf/capabilities.c | 307 ++++++++++++-------------- src/conf/capabilities.h | 50 ++--- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 331 +++++++++++------------------ src/conf/domain_conf.h | 25 ++- src/conf/snapshot_conf.c | 18 +- src/conf/snapshot_conf.h | 2 - src/esx/esx_driver.c | 12 +- src/hyperv/hyperv_driver.c | 4 +- src/libvirt_private.syms | 6 +- src/libxl/libxl_conf.c | 14 +- src/libxl/libxl_domain.c | 7 +- src/libxl/libxl_driver.c | 8 +- src/libxl/libxl_migration.c | 2 - src/lxc/lxc_conf.c | 8 +- src/lxc/lxc_controller.c | 1 - src/lxc/lxc_driver.c | 7 +- src/lxc/lxc_native.c | 4 +- src/openvz/openvz_conf.c | 7 +- src/openvz/openvz_driver.c | 7 +- src/parallels/parallels_driver.c | 23 +- src/parallels/parallels_sdk.c | 6 +- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 10 +- src/qemu/qemu_capabilities.c | 21 +- src/qemu/qemu_command.c | 29 +-- src/qemu/qemu_domain.c | 1 - src/qemu/qemu_domain.h | 6 - src/qemu/qemu_driver.c | 14 +- src/qemu/qemu_migration.c | 5 +- src/security/virt-aa-helper.c | 9 +- src/test/test_driver.c | 12 +- src/uml/uml_conf.c | 4 +- src/uml/uml_driver.c | 6 +- src/util/virerror.c | 5 +- src/vbox/vbox_common.c | 23 +- src/vmware/vmware_conf.c | 8 +- src/vmware/vmware_driver.c | 4 +- src/vmx/vmx.c | 3 +- src/xen/xen_driver.c | 5 +- src/xen/xen_hypervisor.c | 4 +- src/xen/xend_internal.c | 6 +- src/xenapi/xenapi_driver.c | 20 +- src/xenapi/xenapi_utils.c | 4 +- src/xenconfig/xen_common.c | 64 +++--- src/xenconfig/xen_sxpr.c | 5 +- src/xenconfig/xen_xl.c | 17 +- src/xenconfig/xen_xm.c | 12 +- tests/Makefile.am | 8 +- tests/domainconftest.c | 3 +- tests/domainsnapshotxml2xmltest.c | 1 - tests/lxcxml2xmltest.c | 1 - tests/openvzutilstest.c | 2 +- tests/qemuagenttest.c | 1 - tests/qemuhotplugtest.c | 1 - tests/qemuxml2argvtest.c | 1 - tests/qemuxml2xmltest.c | 3 +- tests/qemuxmlnstest.c | 1 - tests/securityselinuxlabeldata/chardev.xml | 2 +- tests/securityselinuxlabeldata/disks.xml | 2 +- tests/securityselinuxlabeldata/kernel.xml | 2 +- tests/securityselinuxlabeldata/nfs.xml | 2 +- tests/securityselinuxlabeltest.c | 4 +- tests/testutils.c | 8 +- tests/testutilslxc.c | 10 +- tests/testutilsqemu.c | 38 ++-- tests/testutilsxen.c | 18 +- tests/vircapstest.c | 209 +++++++++++++++++- tests/vmx2xmltest.c | 8 +- tests/xlconfigtest.c | 1 - tests/xmconfigtest.c | 1 - tests/xml2sexprtest.c | 1 - tests/xml2vmxtest.c | 9 +- 75 files changed, 742 insertions(+), 756 deletions(-) -- 2.3.5

If no <os><type> was specified: before: unknown OS type no OS type after : xml error: an os <type> must be specified If an <os><type> is specified that's not in our capabiliities data: before: unknown OS type: $type after : unsupported configuration: no support found for os <type> '$type' VIR_ERR_OS_TYPE is now unused (as it should be frankly) so drop its strings as well to save our translators some effort. --- src/conf/domain_conf.c | 9 +++++---- src/util/virerror.c | 5 +---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ab4f2bf..8458f5b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14638,8 +14638,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (VIR_STRDUP(def->os.type, "xen") < 0) goto error; } else { - virReportError(VIR_ERR_OS_TYPE, - "%s", _("no OS type")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("an os <type> must be specified")); goto error; } } @@ -14656,8 +14656,9 @@ virDomainDefParseXML(xmlDocPtr xml, } if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { - virReportError(VIR_ERR_OS_TYPE, - "%s", def->os.type); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no support found for os <type> '%s'"), + def->os.type); goto error; } diff --git a/src/util/virerror.c b/src/util/virerror.c index 73dae95..aab36ae 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -900,10 +900,7 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg = _("failed Xen syscall %s"); break; case VIR_ERR_OS_TYPE: - if (info == NULL) - errmsg = _("unknown OS type"); - else - errmsg = _("unknown OS type %s"); + errmsg = "%s"; break; case VIR_ERR_NO_KERNEL: errmsg = _("missing kernel information"); -- 2.3.5

On 18.04.2015 03:45, Cole Robinson wrote:
If no <os><type> was specified: before: unknown OS type no OS type after : xml error: an os <type> must be specified
If an <os><type> is specified that's not in our capabiliities data: before: unknown OS type: $type after : unsupported configuration: no support found for os <type> '$type'
VIR_ERR_OS_TYPE is now unused (as it should be frankly) so drop its strings as well to save our translators some effort. --- src/conf/domain_conf.c | 9 +++++---- src/util/virerror.c | 5 +---- 2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ab4f2bf..8458f5b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14638,8 +14638,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (VIR_STRDUP(def->os.type, "xen") < 0) goto error; } else { - virReportError(VIR_ERR_OS_TYPE, - "%s", _("no OS type")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("an os <type> must be specified")); goto error; } } @@ -14656,8 +14656,9 @@ virDomainDefParseXML(xmlDocPtr xml, }
if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { - virReportError(VIR_ERR_OS_TYPE, - "%s", def->os.type); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no support found for os <type> '%s'"), + def->os.type); goto error; }
diff --git a/src/util/virerror.c b/src/util/virerror.c index 73dae95..aab36ae 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -900,10 +900,7 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg = _("failed Xen syscall %s"); break; case VIR_ERR_OS_TYPE: - if (info == NULL) - errmsg = _("unknown OS type"); - else - errmsg = _("unknown OS type %s"); + errmsg = "%s";
Even though there are no other calls with VIR_ERR_OS_TYPE, I'd feel more safe with: if (info == NULL) errmsg = _("invalid or missing OS type"); else errmsg = "%s"; I find it more future proof. Michal

On 04/20/2015 09:53 AM, Michal Privoznik wrote:
On 18.04.2015 03:45, Cole Robinson wrote:
If no <os><type> was specified: before: unknown OS type no OS type after : xml error: an os <type> must be specified
If an <os><type> is specified that's not in our capabiliities data: before: unknown OS type: $type after : unsupported configuration: no support found for os <type> '$type'
VIR_ERR_OS_TYPE is now unused (as it should be frankly) so drop its strings as well to save our translators some effort. --- src/conf/domain_conf.c | 9 +++++---- src/util/virerror.c | 5 +---- 2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ab4f2bf..8458f5b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14638,8 +14638,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (VIR_STRDUP(def->os.type, "xen") < 0) goto error; } else { - virReportError(VIR_ERR_OS_TYPE, - "%s", _("no OS type")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("an os <type> must be specified")); goto error; } } @@ -14656,8 +14656,9 @@ virDomainDefParseXML(xmlDocPtr xml, }
if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { - virReportError(VIR_ERR_OS_TYPE, - "%s", def->os.type); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no support found for os <type> '%s'"), + def->os.type); goto error; }
diff --git a/src/util/virerror.c b/src/util/virerror.c index 73dae95..aab36ae 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -900,10 +900,7 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg = _("failed Xen syscall %s"); break; case VIR_ERR_OS_TYPE: - if (info == NULL) - errmsg = _("unknown OS type"); - else - errmsg = _("unknown OS type %s"); + errmsg = "%s";
Even though there are no other calls with VIR_ERR_OS_TYPE, I'd feel more safe with:
if (info == NULL) errmsg = _("invalid or missing OS type"); else errmsg = "%s";
I find it more future proof.
Thanks for the review. I just the dropped virerror.c diff, rather than add a new string that needs translation yet isn't used anywhere. Thanks, Cole

When parsing XML, we validate the passed ostype + arch combo against the detected hypervisor capabilities. This has led to the following problem: - Define x86 qemu guest - qemu is inadvertently removed from the host - libvirtd is restarted. fails to parse VM config since arch is removed - 'virsh list --all' is now empty, user is wondering where their VMs went Add a new internal flag VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS. Use it when loading VM and snapshot configs from disk. https://bugzilla.redhat.com/show_bug.cgi?id=1043572 --- src/conf/domain_conf.c | 93 +++++++++++++++++++++++++----------------------- src/conf/domain_conf.h | 4 +++ src/conf/snapshot_conf.c | 6 ++-- 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8458f5b..860c950 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14655,61 +14655,64 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } - if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { + tmp = virXPathString("string(./os/type[1]/@arch)", ctxt); + if (tmp && !(def->os.arch = virArchFromString(tmp))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("no support found for os <type> '%s'"), - def->os.type); + _("Unknown architecture %s"), + tmp); goto error; } + VIR_FREE(tmp); - tmp = virXPathString("string(./os/type[1]/@arch)", ctxt); - if (tmp) { - def->os.arch = virArchFromString(tmp); - if (!def->os.arch) { + def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt); + + if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) { + if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown architecture %s"), - tmp); + _("no support found for os <type> '%s'"), + def->os.type); goto error; } - VIR_FREE(tmp); - if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No guest options available for arch '%s'"), - virArchToString(def->os.arch)); - goto error; - } + if (def->os.arch) { + if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No guest options available for arch '%s'"), + virArchToString(def->os.arch)); + goto error; + } - if (!virCapabilitiesSupportsGuestOSTypeArch(caps, - def->os.type, - def->os.arch)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No os type '%s' available for arch '%s'"), - def->os.type, virArchToString(def->os.arch)); - goto error; + if (!virCapabilitiesSupportsGuestOSTypeArch(caps, + def->os.type, + def->os.arch)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No os type '%s' available for arch '%s'"), + def->os.type, virArchToString(def->os.arch)); + goto error; + } + } else { + def->os.arch = + virCapabilitiesDefaultGuestArch(caps, + def->os.type, + virDomainVirtTypeToString(def->virtType)); + if (!def->os.arch) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no supported architecture for os type '%s'"), + def->os.type); + goto error; + } } - } else { - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - virDomainVirtTypeToString(def->virtType)); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - def->os.type); - goto error; + + if (!def->os.machine) { + const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, + def->os.type, + def->os.arch, + virDomainVirtTypeToString(def->virtType)); + if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) + goto error; } } - def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt); - if (!def->os.machine) { - const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - virDomainVirtTypeToString(def->virtType)); - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto error; - } /* * Booting options for different OS types.... @@ -21591,7 +21594,8 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, goto error; if (!(def = virDomainDefParseFile(configFile, caps, xmlopt, expectedVirtTypes, - VIR_DOMAIN_DEF_PARSE_INACTIVE))) + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS))) goto error; if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) @@ -21641,7 +21645,8 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, VIR_DOMAIN_DEF_PARSE_STATUS | VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES | - VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST))) + VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST | + VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS))) goto error; virUUIDFormat(obj->def->uuid, uuidstr); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e6fa3c9..3045652 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2530,6 +2530,10 @@ typedef enum { /* parse only source half of <disk> */ VIR_DOMAIN_DEF_PARSE_DISK_SOURCE = 1 << 7, VIR_DOMAIN_DEF_PARSE_VALIDATE = 1 << 8, + /* don't validate os.type and arch against capabilities. Prevents + * VMs from disappearing when qemu is removed and libvirtd is restarted + */ + VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS = 1 << 9, } virDomainDefParseFlags; typedef enum { diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index df19449..e725a23 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -270,6 +270,9 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, * clients will have to decide between best effort * initialization or outright failure. */ if ((tmp = virXPathString("string(./domain/@type)", ctxt))) { + int domainflags = VIR_DOMAIN_DEF_PARSE_INACTIVE; + if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL) + domainflags |= VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS; xmlNodePtr domainNode = virXPathNode("./domain", ctxt); VIR_FREE(tmp); @@ -280,8 +283,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, } def->dom = virDomainDefParseNode(ctxt->node->doc, domainNode, caps, xmlopt, - expectedVirtTypes, - VIR_DOMAIN_DEF_PARSE_INACTIVE); + expectedVirtTypes, domainflags); if (!def->dom) goto cleanup; } else { -- 2.3.5

But the internal API stays the same, and we just convert the value as needed. Not useful yet, but this is the beginning step of using an enum for ostype throughout the code. --- src/conf/capabilities.c | 74 ++++++++++++++++++++++++++++++++++++++----------- src/conf/capabilities.h | 2 +- src/conf/domain_conf.c | 8 ++++++ src/conf/domain_conf.h | 13 +++++++++ src/xenconfig/xen_xl.c | 2 +- 5 files changed, 81 insertions(+), 18 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index b66c6dd..acae41a 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -32,6 +32,7 @@ #include "cpu_conf.h" #include "virerror.h" #include "virstring.h" +#include "domain_conf.h" #define VIR_FROM_THIS VIR_FROM_CAPABILITIES @@ -155,8 +156,6 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest) if (guest == NULL) return; - VIR_FREE(guest->ostype); - VIR_FREE(guest->arch.defaultInfo.emulator); VIR_FREE(guest->arch.defaultInfo.loader); for (i = 0; i < guest->arch.defaultInfo.nmachines; i++) @@ -408,7 +407,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines, */ virCapsGuestPtr virCapabilitiesAddGuest(virCapsPtr caps, - const char *ostype, + const char *ostypestr, virArch arch, const char *emulator, const char *loader, @@ -416,13 +415,18 @@ virCapabilitiesAddGuest(virCapsPtr caps, virCapsGuestMachinePtr *machines) { virCapsGuestPtr guest; + int ostype; if (VIR_ALLOC(guest) < 0) goto error; - if (VIR_STRDUP(guest->ostype, ostype) < 0) + if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), ostypestr); goto error; + } + guest->ostype = ostype; guest->arch.id = arch; guest->arch.wordsize = virArchGetWordSize(arch); @@ -603,11 +607,19 @@ virCapabilitiesSupportsGuestArch(virCapsPtr caps, */ extern int virCapabilitiesSupportsGuestOSType(virCapsPtr caps, - const char *ostype) + const char *ostypestr) { size_t i; + int ostype; + + if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), ostypestr); + return 0; + } + for (i = 0; i < caps->nguests; i++) { - if (STREQ(caps->guests[i]->ostype, ostype)) + if (caps->guests[i]->ostype == ostype) return 1; } return 0; @@ -625,12 +637,20 @@ virCapabilitiesSupportsGuestOSType(virCapsPtr caps, */ extern int virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, - const char *ostype, + const char *ostypestr, virArch arch) { size_t i; + int ostype; + + if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), ostypestr); + return 0; + } + for (i = 0; i < caps->nguests; i++) { - if (STREQ(caps->guests[i]->ostype, ostype) && + if (caps->guests[i]->ostype == ostype && caps->guests[i]->arch.id == arch) return 1; } @@ -648,14 +668,21 @@ virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, */ extern virArch virCapabilitiesDefaultGuestArch(virCapsPtr caps, - const char *ostype, + const char *ostypestr, const char *domain) { size_t i, j; + int ostype; + + if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), ostypestr); + return VIR_ARCH_NONE; + } /* First try to find one matching host arch */ for (i = 0; i < caps->nguests; i++) { - if (STREQ(caps->guests[i]->ostype, ostype)) { + if (caps->guests[i]->ostype == ostype) { for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { if (STREQ(caps->guests[i]->arch.domains[j]->type, domain) && caps->guests[i]->arch.id == caps->host.arch) @@ -666,7 +693,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, /* Otherwise find the first match */ for (i = 0; i < caps->nguests; i++) { - if (STREQ(caps->guests[i]->ostype, ostype)) { + if (caps->guests[i]->ostype == ostype) { for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { if (STREQ(caps->guests[i]->arch.domains[j]->type, domain)) return caps->guests[i]->arch.id; @@ -690,17 +717,24 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, */ extern const char * virCapabilitiesDefaultGuestMachine(virCapsPtr caps, - const char *ostype, + const char *ostypestr, virArch arch, const char *domain) { size_t i; + int ostype; + + if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), ostypestr); + return NULL; + } for (i = 0; i < caps->nguests; i++) { virCapsGuestPtr guest = caps->guests[i]; size_t j; - if (!STREQ(guest->ostype, ostype) || + if (guest->ostype != ostype || guest->arch.id != arch) continue; @@ -736,14 +770,22 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps, */ extern const char * virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, - const char *ostype, + const char *ostypestr, virArch arch, const char *domain) { size_t i, j; + int ostype; + + if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), ostypestr); + return NULL; + } + for (i = 0; i < caps->nguests; i++) { char *emulator; - if (STREQ(caps->guests[i]->ostype, ostype) && + if (caps->guests[i]->ostype == ostype && caps->guests[i]->arch.id == arch) { emulator = caps->guests[i]->arch.defaultInfo.emulator; for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { @@ -944,7 +986,7 @@ virCapabilitiesFormatXML(virCapsPtr caps) virBufferAddLit(&buf, "<guest>\n"); virBufferAdjustIndent(&buf, 2); virBufferAsprintf(&buf, "<os_type>%s</os_type>\n", - caps->guests[i]->ostype); + virDomainOSTypeToString(caps->guests[i]->ostype)); if (caps->guests[i]->arch.id) virBufferAsprintf(&buf, "<arch name='%s'>\n", virArchToString(caps->guests[i]->arch.id)); diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 476deba..fc852ac 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -79,7 +79,7 @@ struct _virCapsGuestArch { typedef struct _virCapsGuest virCapsGuest; typedef virCapsGuest *virCapsGuestPtr; struct _virCapsGuest { - char *ostype; + int ostype; virCapsGuestArch arch; size_t nfeatures; size_t nfeatures_max; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 860c950..8731fc1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -122,6 +122,14 @@ VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST, "parallels", "bhyve") +VIR_ENUM_IMPL(virDomainOS, VIR_DOMAIN_OSTYPE_LAST, + "hvm", + "xen", + "linux", + "exe", + "uml", + "aix") + VIR_ENUM_IMPL(virDomainBoot, VIR_DOMAIN_BOOT_LAST, "fd", "cdrom", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3045652..6dc9918 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -228,6 +228,19 @@ typedef enum { } virDomainVirtType; typedef enum { + VIR_DOMAIN_OSTYPE_HVM, + VIR_DOMAIN_OSTYPE_XEN, + VIR_DOMAIN_OSTYPE_LINUX, + VIR_DOMAIN_OSTYPE_EXE, + VIR_DOMAIN_OSTYPE_UML, + VIR_DOMAIN_OSTYPE_AIX, + + VIR_DOMAIN_OSTYPE_LAST +} virDomainOSType; +VIR_ENUM_DECL(virDomainOS) + + +typedef enum { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE, diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index b572587..62284f7 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -68,7 +68,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) const char *boot; for (i = 0; i < caps->nguests; i++) { - if (STREQ(caps->guests[i]->ostype, "hvm") && + if (caps->guests[i]->ostype == VIR_DOMAIN_OSTYPE_HVM && caps->guests[i]->arch.id == def->os.arch) { if (VIR_ALLOC(def->os.loader) < 0 || VIR_STRDUP(def->os.loader->path, -- 2.3.5

On 18.04.2015 03:45, Cole Robinson wrote:
But the internal API stays the same, and we just convert the value as needed. Not useful yet, but this is the beginning step of using an enum for ostype throughout the code. --- src/conf/capabilities.c | 74 ++++++++++++++++++++++++++++++++++++++----------- src/conf/capabilities.h | 2 +- src/conf/domain_conf.c | 8 ++++++ src/conf/domain_conf.h | 13 +++++++++ src/xenconfig/xen_xl.c | 2 +- 5 files changed, 81 insertions(+), 18 deletions(-)
Missing src/libvirt_private.syms adjustment. You need to export virDomainOsTypeFromString and virDomainOsTypeToString. Michal

Hey, On Fri, Apr 17, 2015 at 09:45:13PM -0400, Cole Robinson wrote:
+VIR_ENUM_IMPL(virDomainOS, VIR_DOMAIN_OSTYPE_LAST, + "hvm", + "xen", + "linux", + "exe", + "uml", + "aix") +
This is preexisting before your patch, but is more obvious now. Shouldn't 'aix' be listed in docs/schemas/capability.rng? Currently it's <define name='ostype'> <element name='os_type'> <choice> <value>xen</value> <!-- Xen 3.0 pv --> <value>linux</value> <!-- same as 'xen' - legacy --> <value>hvm</value> <!-- unmodified OS --> <value>exe</value> <!-- For container based virt --> <value>uml</value> <!-- user mode linux --> </choice> </element> </define> Christophe

On 04/21/2015 05:22 AM, Christophe Fergeau wrote:
Hey,
On Fri, Apr 17, 2015 at 09:45:13PM -0400, Cole Robinson wrote:
+VIR_ENUM_IMPL(virDomainOS, VIR_DOMAIN_OSTYPE_LAST, + "hvm", + "xen", + "linux", + "exe", + "uml", + "aix") +
This is preexisting before your patch, but is more obvious now. Shouldn't 'aix' be listed in docs/schemas/capability.rng? Currently it's
<define name='ostype'> <element name='os_type'> <choice> <value>xen</value> <!-- Xen 3.0 pv --> <value>linux</value> <!-- same as 'xen' - legacy --> <value>hvm</value> <!-- unmodified OS --> <value>exe</value> <!-- For container based virt --> <value>uml</value> <!-- user mode linux --> </choice> </element> </define>
Christophe
Good point, I just sent a patch Thanks, Cole

Rather than an opencoded string. This should be a no-op --- src/bhyve/bhyve_capabilities.c | 2 +- src/conf/capabilities.c | 11 ++--------- src/conf/capabilities.h | 2 +- src/esx/esx_driver.c | 4 ++-- src/libxl/libxl_conf.c | 2 +- src/lxc/lxc_conf.c | 4 ++-- src/openvz/openvz_conf.c | 2 +- src/parallels/parallels_driver.c | 6 +++--- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_capabilities.c | 2 +- src/security/virt-aa-helper.c | 9 +++++++-- src/test/test_driver.c | 3 ++- src/uml/uml_conf.c | 2 +- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_conf.c | 4 ++-- src/xen/xen_hypervisor.c | 2 +- src/xenapi/xenapi_driver.c | 4 ++-- tests/testutils.c | 4 ++-- tests/testutilslxc.c | 6 ++++-- tests/testutilsqemu.c | 18 +++++++++--------- tests/testutilsxen.c | 10 ++++++---- tests/vmx2xmltest.c | 4 ++-- tests/xml2vmxtest.c | 4 ++-- 23 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index fff0312..3cb6778 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -86,7 +86,7 @@ virBhyveCapsBuild(void) false, false)) == NULL) return NULL; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, "bhyve", NULL, 0, NULL)) == NULL) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index acae41a..a8b098a 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -393,7 +393,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines, /** * virCapabilitiesAddGuest: * @caps: capabilities to extend - * @ostype: guest operating system type ('hvm' or 'xen') + * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * @arch: guest CPU architecture * @wordsize: number of bits in CPU word * @emulator: path to default device emulator for arch/ostype @@ -407,7 +407,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines, */ virCapsGuestPtr virCapabilitiesAddGuest(virCapsPtr caps, - const char *ostypestr, + int ostype, virArch arch, const char *emulator, const char *loader, @@ -415,17 +415,10 @@ virCapabilitiesAddGuest(virCapsPtr caps, virCapsGuestMachinePtr *machines) { virCapsGuestPtr guest; - int ostype; if (VIR_ALLOC(guest) < 0) goto error; - if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown OS type '%s'"), ostypestr); - goto error; - } - guest->ostype = ostype; guest->arch.id = arch; guest->arch.wordsize = virArchGetWordSize(arch); diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index fc852ac..9312cc2 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -236,7 +236,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines, extern virCapsGuestPtr virCapabilitiesAddGuest(virCapsPtr caps, - const char *ostype, + int ostype, virArch arch, const char *emulator, const char *loader, diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index bfc8695..c114861 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -573,7 +573,7 @@ esxCapsInit(esxPrivate *priv) goto failure; /* i686 */ - guest = virCapabilitiesAddGuest(caps, "hvm", + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, NULL, NULL, 0, NULL); @@ -586,7 +586,7 @@ esxCapsInit(esxPrivate *priv) /* x86_64 */ if (supportsLongMode == esxVI_Boolean_True) { - guest = virCapabilitiesAddGuest(caps, "hvm", + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, NULL, NULL, 0, NULL); diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 230daec..0609fdd 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -425,7 +425,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps) return -1; if ((guest = virCapabilitiesAddGuest(caps, - guest_archs[i].hvm ? "hvm" : "xen", + guest_archs[i].hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN, guest_archs[i].arch, LIBXL_EXECBIN_DIR "/qemu-system-i386", (guest_archs[i].hvm ? diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index d1a3be5..999e45f 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -99,7 +99,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) goto error; if ((guest = virCapabilitiesAddGuest(caps, - "exe", + VIR_DOMAIN_OSTYPE_EXE, caps->host.arch, lxc_path, NULL, @@ -118,7 +118,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) /* On 64-bit hosts, we can use personality() to request a 32bit process */ if ((altArch = lxcContainerGetAlt32bitArch(caps->host.arch)) != VIR_ARCH_NONE) { if ((guest = virCapabilitiesAddGuest(caps, - "exe", + VIR_DOMAIN_OSTYPE_EXE, altArch, lxc_path, NULL, diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index bfa2141..80df15a 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -179,7 +179,7 @@ virCapsPtr openvzCapsInit(void) goto no_memory; if ((guest = virCapabilitiesAddGuest(caps, - "exe", + VIR_DOMAIN_OSTYPE_EXE, caps->host.arch, NULL, NULL, diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 3aa87ca..d80fe24 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -93,13 +93,13 @@ parallelsBuildCapabilities(void) if (nodeCapsInitNUMA(caps) < 0) goto error; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, "parallels", NULL, 0, NULL)) == NULL) goto error; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, "parallels", NULL, 0, NULL)) == NULL) @@ -110,7 +110,7 @@ parallelsBuildCapabilities(void) "parallels", NULL, NULL, 0, NULL) == NULL) goto error; - if ((guest = virCapabilitiesAddGuest(caps, "exe", + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64, "parallels", NULL, 0, NULL)) == NULL) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index f4db2e0..a6b96de 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -342,7 +342,7 @@ phypCapsInit(void) } if ((guest = virCapabilitiesAddGuest(caps, - "linux", + VIR_DOMAIN_OSTYPE_LINUX, caps->host.arch, NULL, NULL, 0, NULL)) == NULL) goto no_memory; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3b49271..9606459 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -829,7 +829,7 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, /* We register kvm as the base emulator too, since we can * just give -no-kvm to disable acceleration if required */ if ((guest = virCapabilitiesAddGuest(caps, - "hvm", + VIR_DOMAIN_OSTYPE_HVM, guestarch, binary, NULL, diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 5a070d7..5a742a5 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -707,7 +707,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr) static int get_definition(vahControl * ctl, const char *xmlStr) { - int rc = -1; + int rc = -1, ostype; virCapsGuestPtr guest; /* this is freed when caps is freed */ /* @@ -727,8 +727,13 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } + if ((ostype = virDomainOSTypeFromString(ctl->hvm)) < 0) { + vah_error(ctl, _("unknown OS type")); + goto exit; + } + if ((guest = virCapabilitiesAddGuest(ctl->caps, - ctl->hvm, + ostype, ctl->arch, NULL, NULL, diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d49c4b3..0dec75e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -314,7 +314,8 @@ testBuildCapabilities(virConnectPtr conn) testConnPtr privconn = conn->privateData; virCapsPtr caps; virCapsGuestPtr guest; - const char *const guest_types[] = { "hvm", "xen" }; + int guest_types[] = { VIR_DOMAIN_OSTYPE_HVM, + VIR_DOMAIN_OSTYPE_XEN }; size_t i; if ((caps = virCapabilitiesNew(VIR_ARCH_I686, false, false)) == NULL) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 02f15c6..d4d380a 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -80,7 +80,7 @@ virCapsPtr umlCapsInit(void) } if ((guest = virCapabilitiesAddGuest(caps, - "uml", + VIR_DOMAIN_OSTYPE_UML, caps->host.arch, NULL, NULL, diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 78b5906..710c50f 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -322,7 +322,7 @@ static virCapsPtr vboxCapsInit(void) goto no_memory; if ((guest = virCapabilitiesAddGuest(caps, - "hvm", + VIR_DOMAIN_OSTYPE_HVM, caps->host.arch, NULL, NULL, diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 5c8a7be..6e274e2 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -73,7 +73,7 @@ vmwareCapsInit(void) /* i686 guests are always supported */ if ((guest = virCapabilitiesAddGuest(caps, - "hvm", + VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, NULL, NULL, 0, NULL)) == NULL) goto error; @@ -105,7 +105,7 @@ vmwareCapsInit(void) cpuHasFeature(data, "svm")))) { if ((guest = virCapabilitiesAddGuest(caps, - "hvm", + VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, NULL, NULL, 0, NULL)) == NULL) goto error; diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index bc498ff..82447c1 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2142,7 +2142,7 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch, goto no_memory; if ((guest = virCapabilitiesAddGuest(caps, - guest_archs[i].hvm ? "hvm" : "xen", + guest_archs[i].hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN, guest_archs[i].arch, (hostarch == VIR_ARCH_X86_64 ? "/usr/lib64/xen/bin/qemu-dm" : diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index d495f21..2ec0b65 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -106,13 +106,13 @@ getCapsObject(void) if (!caps) return NULL; - guest1 = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64, "", "", 0, NULL); + guest1 = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, "", "", 0, NULL); if (!guest1) goto error_cleanup; domain1 = virCapabilitiesAddGuestDomain(guest1, "xen", "", "", 0, NULL); if (!domain1) goto error_cleanup; - guest2 = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_X86_64, "", "", 0, NULL); + guest2 = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_X86_64, "", "", 0, NULL); if (!guest2) goto error_cleanup; domain2 = virCapabilitiesAddGuestDomain(guest2, "xen", "", "", 0, NULL); diff --git a/tests/testutils.c b/tests/testutils.c index bebb14b..2e18040 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -935,7 +935,7 @@ virCapsPtr virTestGenericCapsInit(void) false, false)) == NULL) return NULL; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, "/usr/bin/acme-virt", NULL, 0, NULL)) == NULL) goto error; @@ -944,7 +944,7 @@ virCapsPtr virTestGenericCapsInit(void) goto error; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, "/usr/bin/acme-virt", NULL, 0, NULL)) == NULL) goto error; diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index 09dfd02..c05e37c 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -17,7 +17,8 @@ virCapsPtr testLXCCapsInit(void) false, false)) == NULL) return NULL; - if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_I686, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, + VIR_ARCH_I686, "/usr/libexec/libvirt_lxc", NULL, 0, NULL)) == NULL) goto error; @@ -26,7 +27,8 @@ virCapsPtr testLXCCapsInit(void) goto error; - if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_X86_64, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, + VIR_ARCH_X86_64, "/usr/libexec/libvirt_lxc", NULL, 0, NULL)) == NULL) goto error; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 7c581a1..579cbe2 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -146,7 +146,7 @@ static int testQemuAddPPC64Guest(virCapsPtr caps) if (!machines) goto error; - guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_PPC64, + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64, "/usr/bin/qemu-system-ppc64", NULL, 1, machines); if (!guest) @@ -173,7 +173,7 @@ static int testQemuAddPPC64LEGuest(virCapsPtr caps) if (!machines) goto error; - guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_PPC64LE, + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64LE, "/usr/bin/qemu-system-ppc64", NULL, 1, machines); if (!guest) @@ -203,7 +203,7 @@ static int testQemuAddPPCGuest(virCapsPtr caps) if (!machines) goto error; - guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_PPC, + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC, "/usr/bin/qemu-system-ppc", NULL, 1, machines); if (!guest) @@ -232,7 +232,7 @@ static int testQemuAddS390Guest(virCapsPtr caps) if (!machines) goto error; - guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_S390X, + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_S390X, "/usr/bin/qemu-system-s390x", NULL, ARRAY_CARDINALITY(s390_machines), machines); @@ -262,7 +262,7 @@ static int testQemuAddArmGuest(virCapsPtr caps) if (!capsmachines) goto error; - guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_ARMV7L, + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_ARMV7L, "/usr/bin/qemu-system-arm", NULL, ARRAY_CARDINALITY(machines), capsmachines); @@ -290,7 +290,7 @@ static int testQemuAddAARCH64Guest(virCapsPtr caps) if (!capsmachines) goto error; - guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_AARCH64, + guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_AARCH64, "/usr/bin/qemu-system-aarch64", NULL, ARRAY_CARDINALITY(machines), capsmachines); @@ -339,7 +339,7 @@ virCapsPtr testQemuCapsInit(void) if ((machines = testQemuAllocMachines(&nmachines)) == NULL) goto cleanup; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, "/usr/bin/qemu", NULL, nmachines, machines)) == NULL || !virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false)) @@ -357,7 +357,7 @@ virCapsPtr testQemuCapsInit(void) if ((machines = testQemuAllocNewerMachines(&nmachines)) == NULL) goto cleanup; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, "/usr/bin/qemu-system-x86_64", NULL, nmachines, machines)) == NULL || !virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false)) @@ -388,7 +388,7 @@ virCapsPtr testQemuCapsInit(void) if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL) goto cleanup; - if ((guest = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_X86_64, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_X86_64, "/usr/bin/xenner", NULL, nmachines, machines)) == NULL) goto cleanup; diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index c60e324..44b48d4 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -30,7 +30,7 @@ virCapsPtr testXenCapsInit(void) if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL) goto cleanup; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, "/usr/lib/xen/bin/qemu-dm", NULL, nmachines, machines)) == NULL) goto cleanup; @@ -48,7 +48,7 @@ virCapsPtr testXenCapsInit(void) if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL) goto cleanup; - if ((guest = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_I686, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_I686, "/usr/lib/xen/bin/qemu-dm", NULL, nmachines, machines)) == NULL) goto cleanup; @@ -91,7 +91,8 @@ testXLInitCaps(void) nmachines = ARRAY_CARDINALITY(x86_machines); if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL) goto cleanup; - if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, + VIR_ARCH_X86_64, "/usr/lib/xen/bin/qemu-system-i386", "/usr/lib/xen/boot/hvmloader", nmachines, machines)) == NULL) @@ -104,7 +105,8 @@ testXLInitCaps(void) if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL) goto cleanup; - if ((guest = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_X86_64, + if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, + VIR_ARCH_X86_64, "/usr/lib/xen/bin/qemu-system-i386", NULL, nmachines, machines)) == NULL) diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 412be88..caef2f7 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -34,7 +34,7 @@ testCapsInit(void) /* i686 guest */ guest = - virCapabilitiesAddGuest(caps, "hvm", + virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, NULL, NULL, 0, NULL); @@ -48,7 +48,7 @@ testCapsInit(void) /* x86_64 guest */ guest = - virCapabilitiesAddGuest(caps, "hvm", + virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, NULL, NULL, 0, NULL); diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 2d72407..9bc6ae8 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -35,7 +35,7 @@ testCapsInit(void) /* i686 guest */ guest = - virCapabilitiesAddGuest(caps, "hvm", + virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, NULL, NULL, 0, NULL); @@ -49,7 +49,7 @@ testCapsInit(void) /* x86_64 guest */ guest = - virCapabilitiesAddGuest(caps, "hvm", + virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, NULL, NULL, 0, NULL); -- 2.3.5

On 18.04.2015 03:45, Cole Robinson wrote:
Rather than an opencoded string. This should be a no-op --- src/bhyve/bhyve_capabilities.c | 2 +- src/conf/capabilities.c | 11 ++--------- src/conf/capabilities.h | 2 +- src/esx/esx_driver.c | 4 ++-- src/libxl/libxl_conf.c | 2 +- src/lxc/lxc_conf.c | 4 ++-- src/openvz/openvz_conf.c | 2 +- src/parallels/parallels_driver.c | 6 +++--- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_capabilities.c | 2 +- src/security/virt-aa-helper.c | 9 +++++++-- src/test/test_driver.c | 3 ++- src/uml/uml_conf.c | 2 +- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_conf.c | 4 ++-- src/xen/xen_hypervisor.c | 2 +- src/xenapi/xenapi_driver.c | 4 ++-- tests/testutils.c | 4 ++-- tests/testutilslxc.c | 6 ++++-- tests/testutilsqemu.c | 18 +++++++++--------- tests/testutilsxen.c | 10 ++++++---- tests/vmx2xmltest.c | 4 ++-- tests/xml2vmxtest.c | 4 ++-- 23 files changed, 56 insertions(+), 53 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 5a070d7..5a742a5 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -707,7 +707,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr) static int get_definition(vahControl * ctl, const char *xmlStr) { - int rc = -1; + int rc = -1, ostype; virCapsGuestPtr guest; /* this is freed when caps is freed */
/* @@ -727,8 +727,13 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; }
+ if ((ostype = virDomainOSTypeFromString(ctl->hvm)) < 0) { + vah_error(ctl, _("unknown OS type"));
This won't compile. You need to: - vah_error(ctl, _("unknown OS type")); + vah_error(ctl, 0, _("unknown OS type"));
+ goto exit; + } + if ((guest = virCapabilitiesAddGuest(ctl->caps, - ctl->hvm, + ostype, ctl->arch, NULL, NULL,
Michal

--- src/conf/capabilities.c | 55 ++++--------------- src/conf/capabilities.h | 10 ++-- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 115 +++++++++++++++++++-------------------- src/conf/domain_conf.h | 2 +- src/hyperv/hyperv_driver.c | 4 +- src/libvirt_private.syms | 2 + src/libxl/libxl_conf.c | 10 ++-- src/libxl/libxl_domain.c | 6 +- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/lxc/lxc_native.c | 4 +- src/openvz/openvz_conf.c | 3 +- src/openvz/openvz_driver.c | 4 +- src/parallels/parallels_driver.c | 8 +-- src/parallels/parallels_sdk.c | 6 +- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 3 +- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_command.c | 10 ++-- src/qemu/qemu_driver.c | 2 +- src/uml/uml_driver.c | 2 +- src/vbox/vbox_common.c | 15 ++--- src/vmware/vmware_driver.c | 2 +- src/vmx/vmx.c | 3 +- src/xen/xen_driver.c | 2 +- src/xen/xend_internal.c | 6 +- src/xenapi/xenapi_driver.c | 12 +--- src/xenapi/xenapi_utils.c | 4 +- src/xenconfig/xen_common.c | 29 +++++----- src/xenconfig/xen_sxpr.c | 5 +- src/xenconfig/xen_xl.c | 15 ++--- src/xenconfig/xen_xm.c | 12 ++-- tests/openvzutilstest.c | 2 +- 34 files changed, 152 insertions(+), 211 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index a8b098a..deae472 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -593,23 +593,16 @@ virCapabilitiesSupportsGuestArch(virCapsPtr caps, /** * virCapabilitiesSupportsGuestOSType: * @caps: capabilities to query - * @ostype: OS type to search for (eg 'hvm', 'xen') + * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * * Returns non-zero if the capabilities support the * requested operating system type */ extern int virCapabilitiesSupportsGuestOSType(virCapsPtr caps, - const char *ostypestr) + int ostype) { size_t i; - int ostype; - - if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown OS type '%s'"), ostypestr); - return 0; - } for (i = 0; i < caps->nguests; i++) { if (caps->guests[i]->ostype == ostype) @@ -622,7 +615,7 @@ virCapabilitiesSupportsGuestOSType(virCapsPtr caps, /** * virCapabilitiesSupportsGuestOSTypeArch: * @caps: capabilities to query - * @ostype: OS type to search for (eg 'hvm', 'xen') + * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * @arch: Architecture to search for * * Returns non-zero if the capabilities support the @@ -630,17 +623,10 @@ virCapabilitiesSupportsGuestOSType(virCapsPtr caps, */ extern int virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, - const char *ostypestr, + int ostype, virArch arch) { size_t i; - int ostype; - - if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown OS type '%s'"), ostypestr); - return 0; - } for (i = 0; i < caps->nguests; i++) { if (caps->guests[i]->ostype == ostype && @@ -654,24 +640,17 @@ virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, /** * virCapabilitiesDefaultGuestArch: * @caps: capabilities to query - * @ostype: OS type to search for + * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * * Returns the first architecture able to run the * requested operating system type */ extern virArch virCapabilitiesDefaultGuestArch(virCapsPtr caps, - const char *ostypestr, + int ostype, const char *domain) { size_t i, j; - int ostype; - - if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown OS type '%s'"), ostypestr); - return VIR_ARCH_NONE; - } /* First try to find one matching host arch */ for (i = 0; i < caps->nguests; i++) { @@ -700,7 +679,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, /** * virCapabilitiesDefaultGuestMachine: * @caps: capabilities to query - * @ostype: OS type to search for + * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * @arch: architecture to search for * @domain: domain type to search for * @@ -710,18 +689,11 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, */ extern const char * virCapabilitiesDefaultGuestMachine(virCapsPtr caps, - const char *ostypestr, + int ostype, virArch arch, const char *domain) { size_t i; - int ostype; - - if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown OS type '%s'"), ostypestr); - return NULL; - } for (i = 0; i < caps->nguests; i++) { virCapsGuestPtr guest = caps->guests[i]; @@ -753,7 +725,7 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps, /** * virCapabilitiesDefaultGuestEmulator: * @caps: capabilities to query - * @ostype: OS type to search for ('xen', 'hvm') + * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * @arch: architecture to search for * @domain: domain type ('xen', 'qemu', 'kvm') * @@ -763,18 +735,11 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps, */ extern const char * virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, - const char *ostypestr, + int ostype, virArch arch, const char *domain) { size_t i, j; - int ostype; - - if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown OS type '%s'"), ostypestr); - return NULL; - } for (i = 0; i < caps->nguests; i++) { char *emulator; diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 9312cc2..8969a97 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -267,10 +267,10 @@ virCapabilitiesSupportsGuestArch(virCapsPtr caps, virArch arch); extern int virCapabilitiesSupportsGuestOSType(virCapsPtr caps, - const char *ostype); + int ostype); extern int virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, - const char *ostype, + int ostype, virArch arch); void @@ -279,16 +279,16 @@ virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu, extern virArch virCapabilitiesDefaultGuestArch(virCapsPtr caps, - const char *ostype, + int ostype, const char *domain); extern const char * virCapabilitiesDefaultGuestMachine(virCapsPtr caps, - const char *ostype, + int ostype, virArch arch, const char *domain); extern const char * virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, - const char *ostype, + int ostype, virArch arch, const char *domain); diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 159ebf5..3e93d97 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -859,7 +859,7 @@ virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success) if (i == 0 && (vm->def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || vm->def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) && - STREQ_NULLABLE(vm->def->os.type, "hvm")) + vm->def->os.type == VIR_DOMAIN_OSTYPE_HVM) continue; virDomainAuditChardev(vm, NULL, vm->def->consoles[i], "start", true); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8731fc1..727d060 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2276,7 +2276,6 @@ void virDomainDefFree(virDomainDefPtr def) VIR_FREE(def->idmap.uidmap); VIR_FREE(def->idmap.gidmap); - VIR_FREE(def->os.type); VIR_FREE(def->os.machine); VIR_FREE(def->os.init); for (i = 0; def->os.initargv && def->os.initargv[i]; i++) @@ -3065,7 +3064,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, i == 0 && (def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) && - STREQ_NULLABLE(def->os.type, "hvm")) + def->os.type == VIR_DOMAIN_OSTYPE_HVM) continue; device.data.chr = def->consoles[i]; if (cb(def, &device, &def->consoles[i]->info, opaque) < 0) @@ -3299,14 +3298,8 @@ virDomainDefPostParseInternal(virDomainDefPtr def, { size_t i; - if (!def->os.type) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("hypervisor type must be specified")); - return -1; - } - /* verify init path for container based domains */ - if (STREQ(def->os.type, "exe") && !def->os.init) { + if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) { virReportError(VIR_ERR_XML_ERROR, "%s", _("init binary must be specified")); return -1; @@ -3384,7 +3377,7 @@ virDomainDefPostParseInternal(virDomainDefPtr def, return -1; } } - if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") && + if (def->nconsoles > 0 && def->os.type == VIR_DOMAIN_OSTYPE_HVM && (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) { @@ -9451,7 +9444,7 @@ virDomainInputDefParseXML(const virDomainDef *dom, goto error; } - if (STREQ(dom->os.type, "hvm")) { + if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE && def->type != VIR_DOMAIN_INPUT_TYPE_KBD) { @@ -9466,7 +9459,7 @@ virDomainInputDefParseXML(const virDomainDef *dom, bus); goto error; } - } else if (STREQ(dom->os.type, "xen")) { + } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN) { if (def->bus != VIR_DOMAIN_INPUT_BUS_XEN) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported input bus %s"), @@ -9506,7 +9499,7 @@ virDomainInputDefParseXML(const virDomainDef *dom, } } } else { - if (STREQ(dom->os.type, "hvm")) { + if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) { if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || def->type == VIR_DOMAIN_INPUT_TYPE_KBD) && (ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) { @@ -9514,7 +9507,7 @@ virDomainInputDefParseXML(const virDomainDef *dom, } else { def->bus = VIR_DOMAIN_INPUT_BUS_USB; } - } else if (STREQ(dom->os.type, "xen")) { + } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN) { def->bus = VIR_DOMAIN_INPUT_BUS_XEN; } else { if ((dom->virtType == VIR_DOMAIN_VIRT_PARALLELS)) @@ -10989,9 +10982,8 @@ virDomainVideoDefaultType(const virDomainDef *def) case VIR_DOMAIN_VIRT_KQEMU: case VIR_DOMAIN_VIRT_KVM: case VIR_DOMAIN_VIRT_XEN: - if (def->os.type && - (STREQ(def->os.type, "xen") || - STREQ(def->os.type, "linux"))) + if (def->os.type == VIR_DOMAIN_OSTYPE_XEN || + def->os.type == VIR_DOMAIN_OSTYPE_LINUX) return VIR_DOMAIN_VIDEO_TYPE_XEN; else if ARCH_IS_PPC64(def->os.arch) return VIR_DOMAIN_VIDEO_TYPE_VGA; @@ -11005,15 +10997,10 @@ virDomainVideoDefaultType(const virDomainDef *def) return VIR_DOMAIN_VIDEO_TYPE_VMVGA; case VIR_DOMAIN_VIRT_PARALLELS: - if (def->os.type) { - if (STREQ(def->os.type, "hvm")) - return VIR_DOMAIN_VIDEO_TYPE_VGA; - else - return VIR_DOMAIN_VIDEO_TYPE_PARALLELS; - } else { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) return VIR_DOMAIN_VIDEO_TYPE_VGA; - } - + else + return VIR_DOMAIN_VIDEO_TYPE_PARALLELS; default: return -1; } @@ -12992,7 +12979,8 @@ virDomainDefGetDefaultEmulator(virDomainDefPtr def, virReportError(VIR_ERR_INTERNAL_ERROR, _("no emulator for domain %s os type %s " "on architecture %s"), - type, def->os.type, virArchToString(def->os.arch)); + type, virDomainOSTypeToString(def->os.type), + virArchToString(def->os.arch)); return NULL; } @@ -14640,27 +14628,32 @@ virDomainDefParseXML(xmlDocPtr xml, def->os.bootloader = virXPathString("string(./bootloader)", ctxt); def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt); - def->os.type = virXPathString("string(./os/type[1])", ctxt); - if (!def->os.type) { + tmp = virXPathString("string(./os/type[1])", ctxt); + if (!tmp) { if (def->os.bootloader) { - if (VIR_STRDUP(def->os.type, "xen") < 0) - goto error; + def->os.type = VIR_DOMAIN_OSTYPE_XEN; } else { virReportError(VIR_ERR_XML_ERROR, "%s", _("an os <type> must be specified")); goto error; } + } else { + if ((def->os.type = virDomainOSTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); } + /* * HACK: For xen driver we previously used bogus 'linux' as the * os type for paravirt, whereas capabilities declare it to * be 'xen'. So we accept the former and convert */ - if (STREQ(def->os.type, "linux") && + if (def->os.type == VIR_DOMAIN_OSTYPE_LINUX && def->virtType == VIR_DOMAIN_VIRT_XEN) { - VIR_FREE(def->os.type); - if (VIR_STRDUP(def->os.type, "xen") < 0) - goto error; + def->os.type = VIR_DOMAIN_OSTYPE_XEN; } tmp = virXPathString("string(./os/type[1]/@arch)", ctxt); @@ -14678,7 +14671,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("no support found for os <type> '%s'"), - def->os.type); + virDomainOSTypeToString(def->os.type)); goto error; } @@ -14695,7 +14688,8 @@ virDomainDefParseXML(xmlDocPtr xml, def->os.arch)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("No os type '%s' available for arch '%s'"), - def->os.type, virArchToString(def->os.arch)); + virDomainOSTypeToString(def->os.type), + virArchToString(def->os.arch)); goto error; } } else { @@ -14706,7 +14700,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (!def->os.arch) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"), - def->os.type); + virDomainOSTypeToString(def->os.type)); goto error; } } @@ -14731,7 +14725,7 @@ virDomainDefParseXML(xmlDocPtr xml, * - An init script (exe) */ - if (STREQ(def->os.type, "exe")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) { def->os.init = virXPathString("string(./os/init[1])", ctxt); def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt); @@ -14755,9 +14749,9 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); } - if (STREQ(def->os.type, "xen") || - STREQ(def->os.type, "hvm") || - STREQ(def->os.type, "uml")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_XEN || + def->os.type == VIR_DOMAIN_OSTYPE_HVM || + def->os.type == VIR_DOMAIN_OSTYPE_UML) { xmlNodePtr loader_node; def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt); @@ -14777,7 +14771,7 @@ virDomainDefParseXML(xmlDocPtr xml, } } - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (virDomainDefParseBootXML(ctxt, def) < 0) goto error; if (!(bootHash = virHashCreate(5, NULL))) @@ -15055,15 +15049,15 @@ virDomainDefParseXML(xmlDocPtr xml, /* With QEMU / KVM / Xen graphics, mouse + PS/2 is implicit * with graphics, so don't store it. * XXX will this be true for other virt types ? */ - if ((STREQ(def->os.type, "hvm") && + if ((def->os.type == VIR_DOMAIN_OSTYPE_HVM && input->bus == VIR_DOMAIN_INPUT_BUS_PS2 && (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) || - (STREQ(def->os.type, "xen") && + (def->os.type == VIR_DOMAIN_OSTYPE_XEN && input->bus == VIR_DOMAIN_INPUT_BUS_XEN && (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) || - (STREQ(def->os.type, "exe") && + (def->os.type == VIR_DOMAIN_OSTYPE_EXE && def->virtType == VIR_DOMAIN_VIRT_PARALLELS && input->bus == VIR_DOMAIN_INPUT_BUS_PARALLELS && (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || @@ -15097,9 +15091,9 @@ virDomainDefParseXML(xmlDocPtr xml, (ARCH_IS_X86(def->os.arch) || def->os.arch == VIR_ARCH_NONE)) { int input_bus = VIR_DOMAIN_INPUT_BUS_XEN; - if (STREQ(def->os.type, "hvm")) + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) input_bus = VIR_DOMAIN_INPUT_BUS_PS2; - if (STREQ(def->os.type, "exe") && + if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && def->virtType == VIR_DOMAIN_VIRT_PARALLELS) input_bus = VIR_DOMAIN_INPUT_BUS_PARALLELS; @@ -16795,10 +16789,11 @@ virDomainDefCheckABIStability(virDomainDefPtr src, goto error; } - if (STRNEQ(src->os.type, dst->os.type)) { + if (src->os.type != dst->os.type) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Target domain OS type %s does not match source %s"), - dst->os.type, src->os.type); + virDomainOSTypeToString(dst->os.type), + virDomainOSTypeToString(src->os.type)); goto error; } if (src->os.arch != dst->os.arch) { @@ -16810,8 +16805,8 @@ virDomainDefCheckABIStability(virDomainDefPtr src, } if (STRNEQ_NULLABLE(src->os.machine, dst->os.machine)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain OS type %s does not match source %s"), - dst->os.machine, src->os.machine); + _("Target domain machine type %s does not match source %s"), + dst->os.machine, src->os.machine); goto error; } @@ -20819,10 +20814,12 @@ virDomainDefFormatInternal(virDomainDefPtr def, * be 'xen'. So we convert to the former for backcompat */ if (def->virtType == VIR_DOMAIN_VIRT_XEN && - STREQ(def->os.type, "xen")) - virBufferAsprintf(buf, ">%s</type>\n", "linux"); + def->os.type == VIR_DOMAIN_OSTYPE_XEN) + virBufferAsprintf(buf, ">%s</type>\n", + virDomainOSTypeToString(VIR_DOMAIN_OSTYPE_LINUX)); else - virBufferAsprintf(buf, ">%s</type>\n", def->os.type); + virBufferAsprintf(buf, ">%s</type>\n", + virDomainOSTypeToString(def->os.type)); virBufferEscapeString(buf, "<init>%s</init>\n", def->os.init); @@ -21194,7 +21191,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, /* Back compat, ignore the console element for hvm guests * if it is type == serial */ - if (STREQ(def->os.type, "hvm") && + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM && (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) && (n < def->nserials)) { @@ -21207,7 +21204,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (virDomainChrDefFormat(buf, &console, flags) < 0) goto error; } - if (STREQ(def->os.type, "hvm") && + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM && def->nconsoles == 0 && def->nserials > 0) { virDomainChrDef console; @@ -21240,9 +21237,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, .info = { .alias = NULL }, }; - if (STREQ(def->os.type, "hvm")) + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) autoInput.bus = VIR_DOMAIN_INPUT_BUS_PS2; - else if (STREQ(def->os.type, "exe") && + else if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && def->virtType == VIR_DOMAIN_VIRT_PARALLELS) autoInput.bus = VIR_DOMAIN_INPUT_BUS_PARALLELS; else @@ -21479,7 +21476,7 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, return 0; if (!virDomainDefHasUSB(def) && - STRNEQ(def->os.type, "exe") && + def->os.type != VIR_DOMAIN_OSTYPE_EXE && virDomainDeviceIsUSB(dev)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Device configuration is not compatible: " diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 6dc9918..3c99019 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1783,7 +1783,7 @@ void virDomainLoaderDefFree(virDomainLoaderDefPtr loader); typedef struct _virDomainOSDef virDomainOSDef; typedef virDomainOSDef *virDomainOSDefPtr; struct _virDomainOSDef { - char *type; + int type; virArch arch; char *machine; size_t nBootDevs; diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 00169c7..b539541 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -875,9 +875,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) def->vcpus = processorSettingData->data->VirtualQuantity; def->maxvcpus = processorSettingData->data->VirtualQuantity; - - if (VIR_STRDUP(def->os.type, "hvm") < 0) - goto cleanup; + def->os.type = VIR_DOMAIN_OSTYPE_HVM; /* FIXME: devices section is totally missing */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8c37303..a587597 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -400,6 +400,8 @@ virDomainObjSetDefTransient; virDomainObjSetMetadata; virDomainObjSetState; virDomainObjTaint; +virDomainOSTypeFromString; +virDomainOSTypeToString; virDomainParseMemory; virDomainPausedReasonTypeFromString; virDomainPausedReasonTypeToString; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 0609fdd..322dd56 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -499,7 +499,7 @@ libxlMakeDomCreateInfo(libxl_ctx *ctx, libxl_domain_create_info_init(c_info); - if (STREQ(def->os.type, "hvm")) + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) c_info->type = LIBXL_DOMAIN_TYPE_HVM; else c_info->type = LIBXL_DOMAIN_TYPE_PV; @@ -625,7 +625,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config) { libxl_domain_build_info *b_info = &d_config->b_info; - int hvm = STREQ(def->os.type, "hvm"); + int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; size_t i; libxl_domain_build_info_init(b_info); @@ -875,7 +875,7 @@ libxlDomainGetEmulatorType(const virDomainDef *def) virCommandPtr cmd = NULL; char *output = NULL; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (def->emulator) { cmd = virCommandNew(def->emulator); @@ -1070,7 +1070,7 @@ libxlMakeNic(virDomainDefPtr def, virDomainNetDefPtr l_nic, libxl_device_nic *x_nic) { - bool ioemu_nic = STREQ(def->os.type, "hvm"); + bool ioemu_nic = def->os.type == VIR_DOMAIN_OSTYPE_HVM; virDomainNetType actual_type = virDomainNetGetActualType(l_nic); /* TODO: Where is mtu stored? @@ -1309,7 +1309,7 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports, * VNC or SDL info must also be set in libxl_domain_build_info * for HVM domains. Use the first vfb device. */ - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { libxl_domain_build_info *b_info = &d_config->b_info; libxl_device_vfb vfb = d_config->vfbs[0]; diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 77d46d0..f33df42 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -235,7 +235,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, if (dev->type == VIR_DOMAIN_DEVICE_CHR && dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && - STRNEQ(def->os.type, "hvm")) + def->os.type != VIR_DOMAIN_OSTYPE_HVM) dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; if (dev->type == VIR_DOMAIN_DEVICE_NET && @@ -278,7 +278,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN; } - if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && STREQ(def->os.type, "hvm")) { + if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && def->os.type == VIR_DOMAIN_OSTYPE_HVM) { int dm_type = libxlDomainGetEmulatorType(def); switch (dev->data.video->type) { @@ -315,7 +315,7 @@ libxlDomainDefPostParse(virDomainDefPtr def, { /* Xen PV domains always have a PV console, so add one to the domain config * via post-parse callback if not explicitly specified in the XML. */ - if (STRNEQ(def->os.type, "hvm") && def->nconsoles == 0) { + if (def->os.type != VIR_DOMAIN_OSTYPE_HVM && def->nconsoles == 0) { virDomainChrDefPtr chrdef; if (!(chrdef = virDomainChrDefNew())) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 9eb071e..1271149 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1295,7 +1295,7 @@ libxlDomainGetOSType(virDomainPtr dom) if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (VIR_STRDUP(type, vm->def->os.type) < 0) + if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0) goto cleanup; cleanup: diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8dfa686..b491f34 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -665,7 +665,7 @@ static char *lxcDomainGetOSType(virDomainPtr dom) if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (VIR_STRDUP(ret, vm->def->os.type) < 0) + if (VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)) < 0) goto cleanup; cleanup: diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index c15eb19..25d5383 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -1025,9 +1025,7 @@ lxcParseConfigString(const char *config) vmdef->vcpus = 1; vmdef->nfss = 0; - - if (VIR_STRDUP(vmdef->os.type, "exe") < 0) - goto error; + vmdef->os.type = VIR_DOMAIN_OSTYPE_EXE; if ((value = virConfGetValue(properties, "lxc.arch")) && value->str) { virArch arch = virArchFromString(value->str); diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 80df15a..a2d2da7 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -564,8 +564,7 @@ int openvzLoadDomains(struct openvz_driver *driver) goto cleanup; } - if (VIR_STRDUP(def->os.type, "exe") < 0) - goto cleanup; + def->os.type = VIR_DOMAIN_OSTYPE_EXE; if (VIR_STRDUP(def->os.init, "/sbin/init") < 0) goto cleanup; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index f9f924f..f07337a 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -92,7 +92,7 @@ openvzDomainDefPostParse(virDomainDefPtr def, void *opaque ATTRIBUTE_UNUSED) { /* fill the init path */ - if (STREQ(def->os.type, "exe") && !def->os.init) { + if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) { if (VIR_STRDUP(def->os.init, "/sbin/init") < 0) return -1; } @@ -371,7 +371,7 @@ static char *openvzDomainGetOSType(virDomainPtr dom) goto cleanup; } - ignore_value(VIR_STRDUP(ret, vm->def->os.type)); + ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type))); cleanup: if (vm) diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index d80fe24..f7a75e0 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -184,7 +184,7 @@ parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, (dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK || dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) && !dev->data.net->model && - STREQ(def->os.type, "hvm") && + def->os.type == VIR_DOMAIN_OSTYPE_HVM && VIR_STRDUP(dev->data.net->model, "e1000") < 0) goto cleanup; @@ -575,7 +575,7 @@ parallelsDomainGetOSType(virDomainPtr domain) goto cleanup; } - ignore_value(VIR_STRDUP(ret, privdom->def->os.type)); + ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(privdom->def->os.type))); cleanup: if (privdom) @@ -712,10 +712,10 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int olddom = virDomainObjListFindByUUID(privconn->domains, def->uuid); if (olddom == NULL) { virResetLastError(); - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (prlsdkCreateVm(conn, def)) goto cleanup; - } else if (STREQ(def->os.type, "exe")) { + } else if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) { if (prlsdkCreateCt(conn, def)) goto cleanup; } else { diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c index dcc0bec..2915d80 100644 --- a/src/parallels/parallels_sdk.c +++ b/src/parallels/parallels_sdk.c @@ -1164,12 +1164,10 @@ prlsdkConvertDomainType(PRL_HANDLE sdkdom, virDomainDefPtr def) switch (domainType) { case PVT_VM: - if (VIR_STRDUP(def->os.type, "hvm") < 0) - return -1; + def->os.type = VIR_DOMAIN_OSTYPE_HVM; break; case PVT_CT: - if (VIR_STRDUP(def->os.type, "exe") < 0) - return -1; + def->os.type = VIR_DOMAIN_OSTYPE_EXE; if (VIR_STRDUP(def->os.init, "/sbin/init") < 0) return -1; break; diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h index 0f29374..5731381 100644 --- a/src/parallels/parallels_utils.h +++ b/src/parallels/parallels_utils.h @@ -37,7 +37,7 @@ virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__, \ __FUNCTION__, __LINE__, _("Can't parse prlctl output")) -# define IS_CT(def) (STREQ_NULLABLE(def->os.type, "exe")) +# define IS_CT(def) (def->os.type == VIR_DOMAIN_OSTYPE_HVM) # define parallelsDomNotFoundError(domain) \ do { \ diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a6b96de..6e177b0 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1720,8 +1720,7 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml) if (domain_name == NULL) goto cleanup; - if (VIR_STRDUP(def->os.type, "aix") < 0) - goto cleanup; + def->os.type = VIR_DOMAIN_OSTYPE_AIX; dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9606459..afeeddf 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1897,7 +1897,7 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps, hostarch = virArchFromHost(); if ((binary = virCapabilitiesDefaultGuestEmulator(caps, - "hvm", + VIR_DOMAIN_OSTYPE_HVM, hostarch, "qemu")) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e7e0937..886bba4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8834,8 +8834,8 @@ qemuBuildCommandLine(virConnectPtr conn, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_UUID)) virCommandAddArgList(cmd, "-uuid", uuid, NULL); if (def->virtType == VIR_DOMAIN_VIRT_XEN || - STREQ(def->os.type, "xen") || - STREQ(def->os.type, "linux")) { + def->os.type == VIR_DOMAIN_OSTYPE_XEN || + def->os.type == VIR_DOMAIN_OSTYPE_LINUX) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_XEN_DOMID)) { virCommandAddArg(cmd, "-xen-attach"); virCommandAddArg(cmd, "-xen-domid"); @@ -12315,11 +12315,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps, if (strstr(path, "xenner")) { def->virtType = VIR_DOMAIN_VIRT_KVM; - if (VIR_STRDUP(def->os.type, "xen") < 0) - goto error; + def->os.type = VIR_DOMAIN_OSTYPE_XEN; } else { - if (VIR_STRDUP(def->os.type, "hvm") < 0) - goto error; + def->os.type = VIR_DOMAIN_OSTYPE_HVM; if (strstr(path, "kvm")) { def->virtType = VIR_DOMAIN_VIRT_KVM; def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b3816ee..0f16678 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2241,7 +2241,7 @@ static char *qemuDomainGetOSType(virDomainPtr dom) { if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - ignore_value(VIR_STRDUP(type, vm->def->os.type)); + ignore_value(VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type))); cleanup: qemuDomObjEndAPI(&vm); diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 6b4f655..6744702 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1773,7 +1773,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) { if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (VIR_STRDUP(type, vm->def->os.type) < 0) + if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0) goto cleanup; cleanup: diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 710c50f..b419ddc 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -930,7 +930,7 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data, PRUint32 maxBootPosition = 0; size_t i = 0; - VIR_DEBUG("def->os.type %s", def->os.type); + VIR_DEBUG("def->os.type %s", virDomainOSTypeToString(def->os.type)); VIR_DEBUG("def->os.arch %s", virArchToString(def->os.arch)); VIR_DEBUG("def->os.machine %s", def->os.machine); VIR_DEBUG("def->os.nBootDevs %zu", def->os.nBootDevs); @@ -3906,9 +3906,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) /* Skip cpumasklen, cpumask, onReboot, onPoweroff, onCrash */ - if (VIR_STRDUP(def->os.type, "hvm") < 0) - goto cleanup; - + def->os.type = VIR_DOMAIN_OSTYPE_HVM; def->os.arch = virArchFromHost(); def->os.nBootDevs = 0; @@ -4122,8 +4120,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, if (!(def = virDomainDefNew())) return ret; - if (VIR_STRDUP(def->os.type, "hvm") < 0) - goto cleanup; + def->os.type = VIR_DOMAIN_OSTYPE_HVM; dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, VIR_DOMAIN_DEF_PARSE_INACTIVE); @@ -4254,8 +4251,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) if (!(def = virDomainDefNew())) return ret; - if (VIR_STRDUP(def->os.type, "hvm") < 0) - goto cleanup; + def->os.type = VIR_DOMAIN_OSTYPE_HVM; dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, VIR_DOMAIN_DEF_PARSE_INACTIVE); @@ -6061,8 +6057,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, * reading and while dumping xml */ virDomainDefSetMemoryInitial(def->dom, memorySize * 1024); - if (VIR_STRDUP(def->dom->os.type, "hvm") < 0) - goto cleanup; + def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM; def->dom->os.arch = virArchFromHost(); gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount); def->dom->maxvcpus = def->dom->vcpus = CPUCount; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 3382994..6967dbc 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -870,7 +870,7 @@ vmwareDomainGetOSType(virDomainPtr dom) goto cleanup; } - ignore_value(VIR_STRDUP(ret, vm->def->os.type)); + ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type))); cleanup: if (vm) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 8b81436..cacc951 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1522,8 +1522,7 @@ virVMXParseConfig(virVMXContext *ctx, def->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY; /* def:os */ - if (VIR_STRDUP(def->os.type, "hvm") < 0) - goto cleanup; + def->os.type = VIR_DOMAIN_OSTYPE_HVM; /* vmx:guestOS -> def:os.arch */ if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 3b11e9a..6cd3b76 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -338,7 +338,7 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, if (dev->type == VIR_DOMAIN_DEVICE_CHR && dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && - STRNEQ(def->os.type, "hvm")) + def->os.type != VIR_DOMAIN_OSTYPE_HVM) dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; /* forbid capabilities mode hostdev in this kind of hypervisor */ diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 3813900..99dfdcb 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2261,7 +2261,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn, case VIR_DOMAIN_DEVICE_DISK: if (xenFormatSxprDisk(dev->data.disk, &buf, - STREQ(def->os.type, "hvm") ? 1 : 0, + def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0, priv->xendConfigVersion, 1) < 0) goto cleanup; @@ -2274,7 +2274,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn, if (xenFormatSxprNet(conn, dev->data.net, &buf, - STREQ(def->os.type, "hvm") ? 1 : 0, + def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0, priv->xendConfigVersion, 1) < 0) goto cleanup; @@ -2409,7 +2409,7 @@ xenDaemonUpdateDeviceFlags(virConnectPtr conn, case VIR_DOMAIN_DEVICE_DISK: if (xenFormatSxprDisk(dev->data.disk, &buf, - STREQ(def->os.type, "hvm") ? 1 : 0, + def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0, priv->xendConfigVersion, 1) < 0) goto cleanup; break; diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 2ec0b65..6b2e5ee 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -52,7 +52,7 @@ xenapiDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, if (dev->type == VIR_DOMAIN_DEVICE_CHR && dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && - STRNEQ(def->os.type, "hvm")) + def->os.type != VIR_DOMAIN_OSTYPE_HVM) dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; /* forbid capabilities mode hostdev in this kind of hypervisor */ @@ -1427,10 +1427,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) goto error; xen_vm_get_hvm_boot_policy(session, &boot_policy, vm); if (STREQ(boot_policy, "BIOS order")) { - if (VIR_STRDUP(defPtr->os.type, "hvm") < 0) { - VIR_FREE(boot_policy); - goto error; - } + defPtr->os.type = VIR_DOMAIN_OSTYPE_HVM; xen_vm_get_hvm_boot_params(session, &result, vm); if (result != NULL) { size_t i; @@ -1450,10 +1447,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) VIR_FREE(boot_policy); } else { char *value = NULL; - if (VIR_STRDUP(defPtr->os.type, "xen") < 0) { - VIR_FREE(boot_policy); - goto error; - } + defPtr->os.type = VIR_DOMAIN_OSTYPE_XEN; if (VIR_ALLOC(defPtr->os.loader) < 0 || VIR_STRDUP(defPtr->os.loader->path, "pygrub") < 0) { VIR_FREE(boot_policy); diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index ce95260..a80e084 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -464,7 +464,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def, virUUIDFormat(def->uuid, uuidStr); if (VIR_STRDUP((*record)->uuid, uuidStr) < 0) goto error; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { char *boot_order = NULL; if (VIR_STRDUP((*record)->hvm_boot_policy, "BIOS order") < 0) goto error; @@ -476,7 +476,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def, (*record)->hvm_boot_params = hvm_boot_params; VIR_FREE(boot_order); } - } else if (STREQ(def->os.type, "xen")) { + } else if (def->os.type == VIR_DOMAIN_OSTYPE_XEN) { if (VIR_STRDUP((*record)->pv_bootloader, "pygrub") < 0) goto error; if (def->os.kernel) { diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 7ae2d4a..48484d6 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -331,7 +331,7 @@ xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def, if (xenConfigGetBool(conf, "localtime", &vmlocaltime, 0) < 0) return -1; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { /* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset */ if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) { if (vmlocaltime) @@ -513,7 +513,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def) if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0)) return -1; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetBool(conf, "pae", &val, 1) < 0) return -1; @@ -570,7 +570,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) { int val; char *listenAddr = NULL; - int hvm = STREQ(def->os.type, "hvm"); + int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; virConfValuePtr list; virDomainGraphicsDefPtr graphics = NULL; @@ -724,7 +724,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def) virConfValuePtr value = NULL; virDomainChrDefPtr chr = NULL; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetString(conf, "parallel", &str, NULL) < 0) goto cleanup; if (str && STRNEQ(str, "none") && @@ -967,7 +967,7 @@ xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def) { const char *str; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetString(conf, "soundhw", &str, NULL) < 0) return -1; @@ -997,8 +997,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) STREQ(str, "hvm")) hvm = 1; - if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0) - return -1; + def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN); def->os.arch = virCapabilitiesDefaultGuestArch(caps, @@ -1007,7 +1006,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) if (!def->os.arch) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"), - def->os.type); + virDomainOSTypeToString(def->os.type)); return -1; } @@ -1346,7 +1345,7 @@ xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) } } else { - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { /* >=3.1 HV: VARIABLE */ int rtc_timeoffset; @@ -1447,7 +1446,7 @@ xenFormatCharDev(virConfPtr conf, virDomainDefPtr def) { size_t i; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (def->nparallels) { virBuffer buf = VIR_BUFFER_INITIALIZER; char *str; @@ -1565,7 +1564,7 @@ xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion { size_t i; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigSetInt(conf, "pae", (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) @@ -1621,7 +1620,7 @@ xenFormatCDROM(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) { size_t i; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) { for (i = 0; i < def->ndisks; i++) { if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM && @@ -1644,7 +1643,7 @@ xenFormatCDROM(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) static int xenFormatVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) { - int hvm = STREQ(def->os.type, "hvm") ? 1 : 0; + int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0; if (def->ngraphics == 1 && def->graphics[0]->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { @@ -1763,7 +1762,7 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) static int xenFormatSound(virConfPtr conf, virDomainDefPtr def) { - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (def->sounds) { virBuffer buf = VIR_BUFFER_INITIALIZER; char *str = NULL; @@ -1792,7 +1791,7 @@ xenFormatVif(virConfPtr conf, { virConfValuePtr netVal = NULL; size_t i; - int hvm = STREQ(def->os.type, "hvm"); + int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; if (VIR_ALLOC(netVal) < 0) goto cleanup; diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index d77abf3..5f58fd8 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1145,8 +1145,7 @@ xenParseSxpr(const struct sexpr *root, goto error; } - if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "linux") < 0) - goto error; + def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_LINUX); if (def->id != 0) { if (sexpr_lookup(root, "domain/image")) { @@ -2273,7 +2272,7 @@ xenFormatSxpr(virConnectPtr conn, } virBufferAsprintf(&buf, "(on_crash '%s')", tmp); - if (STREQ(def->os.type, "hvm")) + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) hvm = 1; if (!def->os.bootloader) { diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 62284f7..db554b2 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -64,7 +64,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) size_t i; const char *extra, *root; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { const char *boot; for (i = 0; i < caps->nguests; i++) { @@ -159,7 +159,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) char *listenAddr = NULL; int val; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetBool(conf, "spice", &val, 0) < 0) return -1; @@ -353,7 +353,8 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def) } } - if (STRPREFIX(libxldisk->vdev, "xvd") || !STREQ(def->os.type, "hvm")) + if (STRPREFIX(libxldisk->vdev, "xvd") || + def->os.type != VIR_DOMAIN_OSTYPE_HVM) disk->bus = VIR_DOMAIN_DISK_BUS_XEN; else if (STRPREFIX(libxldisk->vdev, "sd")) disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; @@ -388,7 +389,7 @@ xenParseXLInputDevs(virConfPtr conf, virDomainDefPtr def) const char *str; virConfValuePtr val; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { val = virConfGetValue(conf, "usbdevice"); /* usbdevice can be defined as either a single string or a list */ if (val && val->type == VIR_CONF_LIST) { @@ -475,7 +476,7 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def) { size_t i; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { char boot[VIR_DOMAIN_BOOT_LAST+1]; if (xenConfigSetString(conf, "builder", "hvm") < 0) return -1; @@ -667,7 +668,7 @@ xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def) { const char *listenAddr = NULL; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { /* set others to false but may not be necessary */ if (xenConfigSetInt(conf, "sdl", 0) < 0) @@ -726,7 +727,7 @@ xenFormatXLInputDevs(virConfPtr conf, virDomainDefPtr def) const char *devtype; virConfValuePtr usbdevices = NULL, lastdev; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (VIR_ALLOC(usbdevices) < 0) goto error; diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c index ba10fb9..fafe662 100644 --- a/src/xenconfig/xen_xm.c +++ b/src/xenconfig/xen_xm.c @@ -42,7 +42,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) { size_t i; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { const char *boot; if (VIR_ALLOC(def->os.loader) < 0 || @@ -108,7 +108,7 @@ xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) { const char *str = NULL; virDomainDiskDefPtr disk = NULL; - int hvm = STREQ(def->os.type, "hvm"); + int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; virConfValuePtr list = virConfGetValue(conf, "disk"); if (list && list->type == VIR_CONF_LIST) { @@ -391,7 +391,7 @@ xenFormatXMDisks(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) { virConfValuePtr diskVal = NULL; size_t i = 0; - int hvm = STREQ(def->os.type, "hvm"); + int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; if (VIR_ALLOC(diskVal) < 0) goto cleanup; @@ -436,7 +436,7 @@ xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def) { const char *str; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0) return -1; if (str && @@ -503,7 +503,7 @@ xenFormatXMOS(virConfPtr conf, virDomainDefPtr def) { size_t i; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { char boot[VIR_DOMAIN_BOOT_LAST+1]; if (xenConfigSetString(conf, "builder", "hvm") < 0) return -1; @@ -573,7 +573,7 @@ xenFormatXMInputDevs(virConfPtr conf, virDomainDefPtr def) size_t i; const char *devtype; - if (STREQ(def->os.type, "hvm")) { + if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { for (i = 0; i < def->ninputs; i++) { if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) { if (xenConfigSetInt(conf, "usb", 1) < 0) diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index f9d1002..1414d70 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -103,11 +103,11 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED) "</domain>\n"; if (!(def = virDomainDefNew()) || - VIR_STRDUP(def->os.type, "exe") < 0 || VIR_STRDUP(def->os.init, "/sbin/init") < 0) goto cleanup; def->virtType = VIR_DOMAIN_VIRT_OPENVZ; + def->os.type = VIR_DOMAIN_OSTYPE_EXE; if (openvzReadNetworkConf(def, 1) < 0) { err = virGetLastError(); -- 2.3.5

On 18.04.2015 03:45, Cole Robinson wrote:
--- src/conf/capabilities.c | 55 ++++--------------- src/conf/capabilities.h | 10 ++-- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 115 +++++++++++++++++++-------------------- src/conf/domain_conf.h | 2 +- src/hyperv/hyperv_driver.c | 4 +- src/libvirt_private.syms | 2 + src/libxl/libxl_conf.c | 10 ++-- src/libxl/libxl_domain.c | 6 +- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/lxc/lxc_native.c | 4 +- src/openvz/openvz_conf.c | 3 +- src/openvz/openvz_driver.c | 4 +- src/parallels/parallels_driver.c | 8 +-- src/parallels/parallels_sdk.c | 6 +- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 3 +- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_command.c | 10 ++-- src/qemu/qemu_driver.c | 2 +- src/uml/uml_driver.c | 2 +- src/vbox/vbox_common.c | 15 ++--- src/vmware/vmware_driver.c | 2 +- src/vmx/vmx.c | 3 +- src/xen/xen_driver.c | 2 +- src/xen/xend_internal.c | 6 +- src/xenapi/xenapi_driver.c | 12 +--- src/xenapi/xenapi_utils.c | 4 +- src/xenconfig/xen_common.c | 29 +++++----- src/xenconfig/xen_sxpr.c | 5 +- src/xenconfig/xen_xl.c | 15 ++--- src/xenconfig/xen_xm.c | 12 ++-- tests/openvzutilstest.c | 2 +- 34 files changed, 152 insertions(+), 211 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8c37303..a587597 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -400,6 +400,8 @@ virDomainObjSetDefTransient; virDomainObjSetMetadata; virDomainObjSetState; virDomainObjTaint; +virDomainOSTypeFromString; +virDomainOSTypeToString; virDomainParseMemory; virDomainPausedReasonTypeFromString; virDomainPausedReasonTypeToString;
See? This should have been in one of the previous patches.
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index d80fe24..f7a75e0 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -184,7 +184,7 @@ parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, (dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK || dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) && !dev->data.net->model && - STREQ(def->os.type, "hvm") && + def->os.type == VIR_DOMAIN_OSTYPE_HVM && VIR_STRDUP(dev->data.net->model, "e1000") < 0) goto cleanup;
@@ -575,7 +575,7 @@ parallelsDomainGetOSType(virDomainPtr domain) goto cleanup; }
- ignore_value(VIR_STRDUP(ret, privdom->def->os.type)); + ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(privdom->def->os.type)));
cleanup: if (privdom)
This part is missing: diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index f7a75e0..a654861 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -720,7 +720,8 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int goto cleanup; } else { virReportError(VIR_ERR_INVALID_ARG, - _("Unsupported OS type: %s"), def->os.type); + _("Unsupported OS type: %s"), + virDomainOSTypeToString(def->os.type)); goto cleanup; } Michal

--- src/bhyve/bhyve_capabilities.c | 4 ++-- src/conf/capabilities.c | 28 ++++++++++++++-------------- src/conf/capabilities.h | 10 +++++----- src/conf/domain_conf.c | 17 +++++------------ src/esx/esx_driver.c | 4 ++-- src/libxl/libxl_conf.c | 2 +- src/lxc/lxc_conf.c | 4 ++-- src/openvz/openvz_conf.c | 2 +- src/parallels/parallels_driver.c | 8 ++++---- src/phyp/phyp_driver.c | 4 ++-- src/qemu/qemu_capabilities.c | 8 ++++---- src/qemu/qemu_command.c | 2 +- src/test/test_driver.c | 2 +- src/uml/uml_conf.c | 2 +- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_conf.c | 4 ++-- src/xen/xen_hypervisor.c | 2 +- src/xenapi/xenapi_driver.c | 4 ++-- src/xenconfig/xen_common.c | 4 ++-- tests/testutils.c | 4 ++-- tests/testutilslxc.c | 4 ++-- tests/testutilsqemu.c | 20 ++++++++++---------- tests/testutilsxen.c | 8 ++++---- tests/vmx2xmltest.c | 4 ++-- tests/xml2vmxtest.c | 4 ++-- 25 files changed, 75 insertions(+), 82 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 3cb6778..e6d5518 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -92,8 +92,8 @@ virBhyveCapsBuild(void) NULL, 0, NULL)) == NULL) goto error; - if (virCapabilitiesAddGuestDomain(guest, - "bhyve", NULL, NULL, 0, NULL) == NULL) + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_BHYVE, + NULL, NULL, 0, NULL) == NULL) goto error; if (virBhyveCapsInitCPU(caps, virArchFromHost()) < 0) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index deae472..9f84766 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -135,7 +135,6 @@ virCapabilitiesFreeGuestDomain(virCapsGuestDomainPtr dom) for (i = 0; i < dom->info.nmachines; i++) virCapabilitiesFreeGuestMachine(dom->info.machines[i]); VIR_FREE(dom->info.machines); - VIR_FREE(dom->type); VIR_FREE(dom); } @@ -459,7 +458,7 @@ virCapabilitiesAddGuest(virCapsPtr caps, */ virCapsGuestDomainPtr virCapabilitiesAddGuestDomain(virCapsGuestPtr guest, - const char *hvtype, + int hvtype, const char *emulator, const char *loader, int nmachines, @@ -470,8 +469,8 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest, if (VIR_ALLOC(dom) < 0) goto error; - if (VIR_STRDUP(dom->type, hvtype) < 0 || - VIR_STRDUP(dom->info.emulator, emulator) < 0 || + dom->type = hvtype; + if (VIR_STRDUP(dom->info.emulator, emulator) < 0 || VIR_STRDUP(dom->info.loader, loader) < 0) goto error; @@ -641,6 +640,7 @@ virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, * virCapabilitiesDefaultGuestArch: * @caps: capabilities to query * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE + * @domain: domain type to search for, of enum VIR_DOMAIN_VIRT * * Returns the first architecture able to run the * requested operating system type @@ -648,7 +648,7 @@ virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, extern virArch virCapabilitiesDefaultGuestArch(virCapsPtr caps, int ostype, - const char *domain) + int domain) { size_t i, j; @@ -656,7 +656,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, for (i = 0; i < caps->nguests; i++) { if (caps->guests[i]->ostype == ostype) { for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { - if (STREQ(caps->guests[i]->arch.domains[j]->type, domain) && + if (caps->guests[i]->arch.domains[j]->type == domain && caps->guests[i]->arch.id == caps->host.arch) return caps->guests[i]->arch.id; } @@ -667,7 +667,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, for (i = 0; i < caps->nguests; i++) { if (caps->guests[i]->ostype == ostype) { for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { - if (STREQ(caps->guests[i]->arch.domains[j]->type, domain)) + if (caps->guests[i]->arch.domains[j]->type == domain) return caps->guests[i]->arch.id; } } @@ -681,7 +681,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, * @caps: capabilities to query * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * @arch: architecture to search for - * @domain: domain type to search for + * @domain: domain type to search for, of enum VIR_DOMAIN_VIRT * * Returns the first machine variant associated with * the requested operating system type, architecture @@ -691,7 +691,7 @@ extern const char * virCapabilitiesDefaultGuestMachine(virCapsPtr caps, int ostype, virArch arch, - const char *domain) + int domain) { size_t i; @@ -706,7 +706,7 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps, for (j = 0; j < guest->arch.ndomains; j++) { virCapsGuestDomainPtr dom = guest->arch.domains[j]; - if (!STREQ(dom->type, domain)) + if (dom->type != domain) continue; if (!dom->info.nmachines) @@ -727,7 +727,7 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps, * @caps: capabilities to query * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE * @arch: architecture to search for - * @domain: domain type ('xen', 'qemu', 'kvm') + * @domain: domain type to search for, of enum VIR_DOMAIN_VIRT * * Returns the first emulator path associated with * the requested operating system type, architecture @@ -737,7 +737,7 @@ extern const char * virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, int ostype, virArch arch, - const char *domain) + int domain) { size_t i, j; @@ -747,7 +747,7 @@ virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, caps->guests[i]->arch.id == arch) { emulator = caps->guests[i]->arch.defaultInfo.emulator; for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { - if (STREQ(caps->guests[i]->arch.domains[j]->type, domain)) { + if (caps->guests[i]->arch.domains[j]->type == domain) { if (caps->guests[i]->arch.domains[j]->info.emulator) emulator = caps->guests[i]->arch.domains[j]->info.emulator; } @@ -970,7 +970,7 @@ virCapabilitiesFormatXML(virCapsPtr caps) for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { virBufferAsprintf(&buf, "<domain type='%s'", - caps->guests[i]->arch.domains[j]->type); + virDomainVirtTypeToString(caps->guests[i]->arch.domains[j]->type)); if (!caps->guests[i]->arch.domains[j]->info.emulator && !caps->guests[i]->arch.domains[j]->info.loader && !caps->guests[i]->arch.domains[j]->info.nmachines) { diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 8969a97..7ee834f 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -61,7 +61,7 @@ struct _virCapsGuestDomainInfo { typedef struct _virCapsGuestDomain virCapsGuestDomain; typedef virCapsGuestDomain *virCapsGuestDomainPtr; struct _virCapsGuestDomain { - char *type; + int type; virCapsGuestDomainInfo info; }; @@ -245,7 +245,7 @@ virCapabilitiesAddGuest(virCapsPtr caps, extern virCapsGuestDomainPtr virCapabilitiesAddGuestDomain(virCapsGuestPtr guest, - const char *hvtype, + int hvtype, const char *emulator, const char *loader, int nmachines, @@ -280,17 +280,17 @@ virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu, extern virArch virCapabilitiesDefaultGuestArch(virCapsPtr caps, int ostype, - const char *domain); + int domain); extern const char * virCapabilitiesDefaultGuestMachine(virCapsPtr caps, int ostype, virArch arch, - const char *domain); + int domain); extern const char * virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, int ostype, virArch arch, - const char *domain); + int domain); extern char * virCapabilitiesFormatXML(virCapsPtr caps); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 727d060..59002fd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12959,27 +12959,20 @@ char * virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) { - const char *type; const char *emulator; char *retemu; - type = virDomainVirtTypeToString(def->virtType); - if (!type) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unknown virt type")); - return NULL; - } - emulator = virCapabilitiesDefaultGuestEmulator(caps, def->os.type, def->os.arch, - type); + def->virtType); if (!emulator) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no emulator for domain %s os type %s " "on architecture %s"), - type, virDomainOSTypeToString(def->os.type), + virDomainVirtTypeToString(def->virtType), + virDomainOSTypeToString(def->os.type), virArchToString(def->os.arch)); return NULL; } @@ -14696,7 +14689,7 @@ virDomainDefParseXML(xmlDocPtr xml, def->os.arch = virCapabilitiesDefaultGuestArch(caps, def->os.type, - virDomainVirtTypeToString(def->virtType)); + def->virtType); if (!def->os.arch) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"), @@ -14709,7 +14702,7 @@ virDomainDefParseXML(xmlDocPtr xml, const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, def->os.type, def->os.arch, - virDomainVirtTypeToString(def->virtType)); + def->virtType); if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) goto error; } diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index c114861..4652b96 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -581,7 +581,7 @@ esxCapsInit(esxPrivate *priv) if (!guest) goto failure; - if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL)) goto failure; /* x86_64 */ @@ -594,7 +594,7 @@ esxCapsInit(esxPrivate *priv) if (!guest) goto failure; - if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL)) goto failure; } diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 322dd56..a39c977 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -439,7 +439,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps) machines = NULL; if (virCapabilitiesAddGuestDomain(guest, - "xen", + VIR_DOMAIN_VIRT_XEN, NULL, NULL, 0, diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 999e45f..c393cb5 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -108,7 +108,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) goto error; if (virCapabilitiesAddGuestDomain(guest, - "lxc", + VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, @@ -127,7 +127,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) goto error; if (virCapabilitiesAddGuestDomain(guest, - "lxc", + VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index a2d2da7..49d78c6 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -188,7 +188,7 @@ virCapsPtr openvzCapsInit(void) goto no_memory; if (virCapabilitiesAddGuestDomain(guest, - "openvz", + VIR_DOMAIN_VIRT_OPENVZ, NULL, NULL, 0, diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index f7a75e0..5ea8ba3 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -106,8 +106,8 @@ parallelsBuildCapabilities(void) goto error; - if (virCapabilitiesAddGuestDomain(guest, - "parallels", NULL, NULL, 0, NULL) == NULL) + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_PARALLELS, + NULL, NULL, 0, NULL) == NULL) goto error; if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, @@ -116,8 +116,8 @@ parallelsBuildCapabilities(void) NULL, 0, NULL)) == NULL) goto error; - if (virCapabilitiesAddGuestDomain(guest, - "parallels", NULL, NULL, 0, NULL) == NULL) + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_PARALLELS, + NULL, NULL, 0, NULL) == NULL) goto error; if (nodeGetInfo(&nodeinfo)) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 6e177b0..007defa 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -347,8 +347,8 @@ phypCapsInit(void) NULL, NULL, 0, NULL)) == NULL) goto no_memory; - if (virCapabilitiesAddGuestDomain(guest, - "phyp", NULL, NULL, 0, NULL) == NULL) + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_PHYP, + NULL, NULL, 0, NULL) == NULL) goto no_memory; return caps; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index afeeddf..ad50360 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -858,7 +858,7 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, goto cleanup; if (virCapabilitiesAddGuestDomain(guest, - "qemu", + VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, @@ -867,7 +867,7 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, if (haskqemu && virCapabilitiesAddGuestDomain(guest, - "kqemu", + VIR_DOMAIN_VIRT_KQEMU, NULL, NULL, 0, @@ -882,7 +882,7 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, goto cleanup; if ((dom = virCapabilitiesAddGuestDomain(guest, - "kvm", + VIR_DOMAIN_VIRT_KVM, kvmbin ? kvmbin : binary, NULL, nmachines, @@ -1899,7 +1899,7 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps, if ((binary = virCapabilitiesDefaultGuestEmulator(caps, VIR_DOMAIN_OSTYPE_HVM, hostarch, - "qemu")) == NULL) { + VIR_DOMAIN_VIRT_QEMU)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot find suitable emulator for %s"), virArchToString(hostarch)); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 886bba4..8e7b689 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -13149,7 +13149,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, virCapabilitiesDefaultGuestMachine(qemuCaps, def->os.type, def->os.arch, - virDomainVirtTypeToString(def->virtType)); + def->virtType); if (defaultMachine != NULL) if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) goto error; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 0dec75e..44f6adf 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -353,7 +353,7 @@ testBuildCapabilities(virConnectPtr conn) goto error; if (virCapabilitiesAddGuestDomain(guest, - "test", + VIR_DOMAIN_VIRT_TEST, NULL, NULL, 0, diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index d4d380a..86fbecc 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -89,7 +89,7 @@ virCapsPtr umlCapsInit(void) goto error; if (virCapabilitiesAddGuestDomain(guest, - "uml", + VIR_DOMAIN_VIRT_UML, NULL, NULL, 0, diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index b419ddc..8424713 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -331,7 +331,7 @@ static virCapsPtr vboxCapsInit(void) goto no_memory; if (virCapabilitiesAddGuestDomain(guest, - "vbox", + VIR_DOMAIN_VIRT_VBOX, NULL, NULL, 0, diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 6e274e2..5b249f8 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -79,7 +79,7 @@ vmwareCapsInit(void) goto error; if (virCapabilitiesAddGuestDomain(guest, - "vmware", + VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL) == NULL) goto error; @@ -111,7 +111,7 @@ vmwareCapsInit(void) goto error; if (virCapabilitiesAddGuestDomain(guest, - "vmware", + VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL) == NULL) goto error; } diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 82447c1..431c47a 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2158,7 +2158,7 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch, machines = NULL; if (virCapabilitiesAddGuestDomain(guest, - "xen", + VIR_DOMAIN_VIRT_XEN, NULL, NULL, 0, diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 6b2e5ee..881f5b2 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -109,13 +109,13 @@ getCapsObject(void) guest1 = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, "", "", 0, NULL); if (!guest1) goto error_cleanup; - domain1 = virCapabilitiesAddGuestDomain(guest1, "xen", "", "", 0, NULL); + domain1 = virCapabilitiesAddGuestDomain(guest1, VIR_DOMAIN_VIRT_XEN, "", "", 0, NULL); if (!domain1) goto error_cleanup; guest2 = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_X86_64, "", "", 0, NULL); if (!guest2) goto error_cleanup; - domain2 = virCapabilitiesAddGuestDomain(guest2, "xen", "", "", 0, NULL); + domain2 = virCapabilitiesAddGuestDomain(guest2, VIR_DOMAIN_VIRT_XEN, "", "", 0, NULL); if (!domain2) goto error_cleanup; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 48484d6..728b910 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -1002,7 +1002,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) def->os.arch = virCapabilitiesDefaultGuestArch(caps, def->os.type, - virDomainVirtTypeToString(def->virtType)); + def->virtType); if (!def->os.arch) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"), @@ -1013,7 +1013,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) defaultMachine = virCapabilitiesDefaultGuestMachine(caps, def->os.type, def->os.arch, - virDomainVirtTypeToString(def->virtType)); + def->virtType); if (defaultMachine != NULL) { if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) return -1; diff --git a/tests/testutils.c b/tests/testutils.c index 2e18040..aca2fd0 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -940,7 +940,7 @@ virCapsPtr virTestGenericCapsInit(void) 0, NULL)) == NULL) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "test", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, NULL, 0, NULL)) goto error; @@ -949,7 +949,7 @@ virCapsPtr virTestGenericCapsInit(void) 0, NULL)) == NULL) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "test", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, NULL, 0, NULL)) goto error; diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index c05e37c..3e4d948 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -23,7 +23,7 @@ virCapsPtr testLXCCapsInit(void) 0, NULL)) == NULL) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "lxc", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL)) goto error; @@ -33,7 +33,7 @@ virCapsPtr testLXCCapsInit(void) 0, NULL)) == NULL) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "lxc", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL)) goto error; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 579cbe2..bbf58ee 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -152,7 +152,7 @@ static int testQemuAddPPC64Guest(virCapsPtr caps) if (!guest) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) goto error; return 0; @@ -179,7 +179,7 @@ static int testQemuAddPPC64LEGuest(virCapsPtr caps) if (!guest) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) goto error; return 0; @@ -209,7 +209,7 @@ static int testQemuAddPPCGuest(virCapsPtr caps) if (!guest) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) goto error; return 0; @@ -239,7 +239,7 @@ static int testQemuAddS390Guest(virCapsPtr caps) if (!guest) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) goto error; return 0; @@ -269,7 +269,7 @@ static int testQemuAddArmGuest(virCapsPtr caps) if (!guest) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) goto error; return 0; @@ -297,7 +297,7 @@ static int testQemuAddAARCH64Guest(virCapsPtr caps) if (!guest) goto error; - if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL)) + if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) goto error; return 0; @@ -347,7 +347,7 @@ virCapsPtr testQemuCapsInit(void) machines = NULL; if (virCapabilitiesAddGuestDomain(guest, - "qemu", + VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, @@ -365,7 +365,7 @@ virCapsPtr testQemuCapsInit(void) machines = NULL; if (virCapabilitiesAddGuestDomain(guest, - "qemu", + VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, @@ -376,7 +376,7 @@ virCapsPtr testQemuCapsInit(void) goto cleanup; if (virCapabilitiesAddGuestDomain(guest, - "kvm", + VIR_DOMAIN_VIRT_KVM, "/usr/bin/kvm", NULL, nmachines, @@ -395,7 +395,7 @@ virCapsPtr testQemuCapsInit(void) machines = NULL; if (virCapabilitiesAddGuestDomain(guest, - "kvm", + VIR_DOMAIN_VIRT_KVM, "/usr/bin/kvm", NULL, 0, diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index 44b48d4..122789c 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -37,7 +37,7 @@ virCapsPtr testXenCapsInit(void) machines = NULL; if (virCapabilitiesAddGuestDomain(guest, - "xen", + VIR_DOMAIN_VIRT_XEN, NULL, NULL, 0, @@ -55,7 +55,7 @@ virCapsPtr testXenCapsInit(void) machines = NULL; if (virCapabilitiesAddGuestDomain(guest, - "xen", + VIR_DOMAIN_VIRT_XEN, NULL, NULL, 0, @@ -98,7 +98,7 @@ testXLInitCaps(void) nmachines, machines)) == NULL) goto cleanup; machines = NULL; - if (virCapabilitiesAddGuestDomain(guest, "xen", NULL, + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL, NULL, 0, NULL) == NULL) goto cleanup; nmachines = ARRAY_CARDINALITY(xen_machines); @@ -113,7 +113,7 @@ testXLInitCaps(void) goto cleanup; machines = NULL; - if (virCapabilitiesAddGuestDomain(guest, "xen", NULL, + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL, NULL, 0, NULL) == NULL) goto cleanup; return caps; diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index caef2f7..69d2b43 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -41,7 +41,7 @@ testCapsInit(void) if (guest == NULL) goto failure; - if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL) == NULL) { goto failure; } @@ -55,7 +55,7 @@ testCapsInit(void) if (guest == NULL) goto failure; - if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL) == NULL) { goto failure; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 9bc6ae8..19d62d3 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -42,7 +42,7 @@ testCapsInit(void) if (guest == NULL) goto failure; - if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL) == NULL) { goto failure; } @@ -56,7 +56,7 @@ testCapsInit(void) if (guest == NULL) goto failure; - if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, + if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL) == NULL) { goto failure; } -- 2.3.5

This is a helper function to look up all capabilities data for all the OS bits that are relevant to <domain>. This is - os type - arch - domain type - emulator - machine type This will be used to replace several functions in later commits. --- src/conf/capabilities.c | 163 +++++++++++++++++++++++++++++++++++- src/conf/capabilities.h | 18 ++++ src/libvirt_private.syms | 1 + tests/Makefile.am | 8 +- tests/vircapstest.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 393 insertions(+), 6 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 9f84766..8d3d2a3 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -225,7 +225,6 @@ virCapabilitiesDispose(void *object) virCPUDefFree(caps->host.cpu); } - /** * virCapabilitiesAddHostFeature: * @caps: capabilities to extend @@ -568,6 +567,168 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel, return -1; } +static bool +virCapsDomainDataCompare(virCapsGuestPtr guest, + virCapsGuestDomainPtr domain, + virCapsGuestMachinePtr machine, + int ostype, + virArch arch, + int domaintype, + const char *emulator, + const char *machinetype) +{ + char *check_emulator = NULL; + + if (ostype != -1 && guest->ostype != ostype) + return false; + if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch)) + return false; + + if (domaintype != -1 && (!domain || domain->type != domaintype)) + return false; + + if (emulator) { + if (domain) + check_emulator = domain->info.emulator; + if (!check_emulator) + check_emulator = guest->arch.defaultInfo.emulator; + if (!check_emulator || STRNEQ(check_emulator, emulator)) + return false; + } + + if (machinetype) { + if (!machine) + return false; + if (STRNEQ(machine->name, machinetype) && + (!machine->canonical || STRNEQ(machine->canonical, machinetype))) + return false; + } + + return true; +} + +/** + * virCapabilitiesDomainDataLookup: + * @caps: capabilities to query + * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE + * @arch: Architecture to search for + * @domaintype: domain type to search for, of enum VIR_DOMAIN_VIRT + * @emulator: Emulator path to search for + * @machinetype: Machine type to search for + * + * Search capabilities for the passed values, and if found return + * virCapabilitiesDomainDataLookup filled in with the default values + */ +virCapsDomainDataPtr +virCapabilitiesDomainDataLookup(virCapsPtr caps, + int ostype, + virArch arch, + int domaintype, + const char *emulator, + const char *machinetype) +{ + virCapsGuestPtr foundguest = NULL; + virCapsGuestDomainPtr founddomain = NULL; + virCapsGuestMachinePtr foundmachine = NULL; + virCapsDomainDataPtr ret = NULL; + size_t i, j, k; + + for (i = 0; i < caps->nguests; i++) { + virCapsGuestPtr guest = caps->guests[i]; + + for (j = 0; j < guest->arch.ndomains; j++) { + virCapsGuestDomainPtr domain = guest->arch.domains[j]; + virCapsGuestMachinePtr *machinelist; + int nmachines; + + if (domain->info.nmachines) { + nmachines = domain->info.nmachines; + machinelist = domain->info.machines; + } else { + nmachines = guest->arch.defaultInfo.nmachines; + machinelist = guest->arch.defaultInfo.machines; + } + + for (k = 0; k < nmachines; k++) { + virCapsGuestMachinePtr machine = machinelist[k]; + if (!virCapsDomainDataCompare(guest, domain, machine, + ostype, arch, domaintype, + emulator, machinetype)) + continue; + + foundmachine = machine; + break; + } + + if (!foundmachine) { + if (!virCapsDomainDataCompare(guest, domain, NULL, + ostype, arch, domaintype, + emulator, machinetype)) + continue; + } + + founddomain = domain; + break; + } + + if (!founddomain) { + if (!virCapsDomainDataCompare(guest, NULL, NULL, + ostype, arch, domaintype, + emulator, machinetype)) + continue; + } + + foundguest = guest; + break; + } + + /* XXX check default_emulator, see how it uses this */ + if (!foundguest) { + virBuffer buf = VIR_BUFFER_INITIALIZER; + if (ostype) + virBufferAsprintf(&buf, "ostype=%s ", + virDomainOSTypeToString(ostype)); + if (arch) + virBufferAsprintf(&buf, "arch=%s ", virArchToString(arch)); + if (domaintype) + virBufferAsprintf(&buf, "domaintype=%s ", + virDomainVirtTypeToString(domaintype)); + if (emulator) + virBufferAsprintf(&buf, "emulator=%s ", emulator); + if (machinetype) + virBufferAsprintf(&buf, "machine=%s ", machinetype); + if (virBufferCurrentContent(&buf) && + !virBufferCurrentContent(&buf)[0]) + virBufferAsprintf(&buf, "%s", _("any configuration")); + if (virBufferCheckError(&buf) < 0) { + virBufferContentAndReset(&buf); + goto error; + } + + virReportError(VIR_ERR_INVALID_ARG, + _("could not find capabilities for %s"), + virBufferContentAndReset(&buf)); + goto error; + } + + if (VIR_ALLOC(ret) < 0) + goto error; + + ret->ostype = foundguest->ostype; + ret->arch = foundguest->arch.id; + if (founddomain) { + ret->domaintype = founddomain->type; + ret->emulator = founddomain->info.emulator; + } + if (!ret->emulator) + ret->emulator = foundguest->arch.defaultInfo.emulator; + if (foundmachine) + ret->machinetype = foundmachine->name; + + error: + return ret; +} + /** * virCapabilitiesSupportsGuestArch: * @caps: capabilities to query diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 7ee834f..87acf39 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -192,6 +192,16 @@ struct _virCaps { virCapsGuestPtr *guests; }; +typedef struct _virCapsDomainData virCapsDomainData; +typedef virCapsDomainData *virCapsDomainDataPtr; +struct _virCapsDomainData { + int ostype; + int arch; + int domaintype; + char *emulator; + char *machinetype; +}; + extern virCapsPtr virCapabilitiesNew(virArch hostarch, @@ -262,6 +272,14 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel, const char *type, const char *label); +virCapsDomainDataPtr +virCapabilitiesDomainDataLookup(virCapsPtr caps, + int ostype, + virArch arch, + int domaintype, + const char *emulator, + const char *machinetype); + extern int virCapabilitiesSupportsGuestArch(virCapsPtr caps, virArch arch); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a587597..5843061 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -54,6 +54,7 @@ virCapabilitiesClearHostNUMACellCPUTopology; virCapabilitiesDefaultGuestArch; virCapabilitiesDefaultGuestEmulator; virCapabilitiesDefaultGuestMachine; +virCapabilitiesDomainDataLookup; virCapabilitiesFormatXML; virCapabilitiesFreeMachines; virCapabilitiesFreeNUMAInfo; diff --git a/tests/Makefile.am b/tests/Makefile.am index 5f88b18..c6d60cd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -877,8 +877,12 @@ virkmodtest_SOURCES = \ virkmodtest_LDADD = $(LDADDS) vircapstest_SOURCES = \ - vircapstest.c testutils.h testutils.c -vircapstest_LDADD = $(LDADDS) + vircapstest.c testutils.h testutils.c \ + testutilsqemu.c testutilsqemu.h \ + testutilslxc.c testutilslxc.h \ + testutilsxen.c testutilsxen.h \ + $(NULL) +vircapstest_LDADD = $(qemu_LDADDS) $(LDADDS) vircaps2xmltest_SOURCES = \ vircaps2xmltest.c testutils.h testutils.c diff --git a/tests/vircapstest.c b/tests/vircapstest.c index deabc7a..3e5038b 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -21,6 +21,9 @@ #include <stdlib.h> #include "testutils.h" +#include "testutilslxc.h" +#include "testutilsxen.h" +#include "testutilsqemu.h" #include "capabilities.h" #include "virbitmap.h" @@ -66,8 +69,8 @@ buildNUMATopology(int seq) if (virCapabilitiesAddHostNUMACell(caps, cell_id + seq, MAX_MEM_IN_CELL, MAX_CPUS_IN_CELL, cell_cpus, - 0, NULL, - 0, NULL) < 0) + VIR_ARCH_NONE, NULL, + VIR_ARCH_NONE, NULL) < 0) goto error; cell_cpus = NULL; @@ -101,7 +104,7 @@ test_virCapabilitiesGetCpusForNodemask(const void *data ATTRIBUTE_UNUSED) if (!(caps = buildNUMATopology(3))) goto error; - if (virBitmapParse(nodestr, 0, &nodemask, mask_size) < 0) + if (virBitmapParse(nodestr, VIR_ARCH_NONE, &nodemask, mask_size) < 0) goto error; if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, nodemask))) @@ -118,6 +121,197 @@ test_virCapabilitiesGetCpusForNodemask(const void *data ATTRIBUTE_UNUSED) } +static bool +doCapsExpectFailure(virCapsPtr caps, + int ostype, + virArch arch, + int domaintype, + const char *emulator, + const char *machinetype) +{ + virCapsDomainDataPtr data = virCapabilitiesDomainDataLookup(caps, ostype, + arch, domaintype, emulator, machinetype); + + if (data) { + VIR_FREE(data); + return false; + } + + return true; +} + +static bool +doCapsCompare(virCapsPtr caps, + int ostype, + virArch arch, + int domaintype, + const char *emulator, + const char *machinetype, + int expect_ostype, + virArch expect_arch, + int expect_domaintype, + const char *expect_emulator, + const char *expect_machinetype) +{ + bool ret = false; + virCapsDomainDataPtr data = virCapabilitiesDomainDataLookup(caps, ostype, + arch, domaintype, emulator, machinetype); + + if (!data) + goto error; + + if (data->ostype != expect_ostype) { + fprintf(stderr, "data->ostype=%s doesn't match expect_ostype=%s\n", + virDomainOSTypeToString(data->ostype), + virDomainOSTypeToString(expect_ostype)); + goto error; + } + + if (data->arch != expect_arch) { + fprintf(stderr, "data->arch=%s doesn't match expect_arch=%s\n", + virArchToString(data->arch), + virArchToString(expect_arch)); + goto error; + } + + if (data->domaintype != expect_domaintype) { + fprintf(stderr, "data->domaintype=%s doesn't match " + "expect_domaintype=%s\n", + virDomainVirtTypeToString(data->domaintype), + virDomainVirtTypeToString(expect_domaintype)); + goto error; + } + + if (STRNEQ(data->emulator, expect_emulator)) { + fprintf(stderr, "data->emulator=%s doesn't match expect_emulator=%s\n", + data->emulator, expect_emulator); + goto error; + } + + if (data->machinetype != expect_machinetype && + STRNEQ(data->machinetype, expect_machinetype)) { + fprintf(stderr, "data->machinetype=%s doesn't match " + "expect_machinetype=%s\n", + data->machinetype, expect_machinetype); + goto error; + } + + ret = true; + error: + VIR_FREE(data); + return ret; +} + +#define CAPSCOMP(o, a, d, e, m, fo, fa, fd, fe, fm) \ + if (!doCapsCompare(caps, o, a, d, e, m, fo, fa, fd, fe, fm)) \ + ret = 1; + +#define CAPS_EXPECT_ERR(o, a, d, e, m) \ + if (!doCapsExpectFailure(caps, o, a, d, e, m)) \ + ret = 1; + +static int +test_virCapsDomainDataLookupQEMU(const void *data ATTRIBUTE_UNUSED) +{ + int ret = 0; + virCapsPtr caps = NULL; + + if (!(caps = testQemuCapsInit())) { + ret = -1; + goto out; + } + + /* Checking each parameter individually */ + CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, NULL, + VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, + VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu", "pc"); + CAPSCOMP(VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_NONE, -1, NULL, NULL, + VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686, + VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu", "pc"); + CAPSCOMP(-1, VIR_ARCH_AARCH64, -1, 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, + 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", + 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", + 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", + VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64LE, + VIR_DOMAIN_VIRT_QEMU, "/usr/bin/qemu-system-ppc64", "pseries"); + + CAPS_EXPECT_ERR(VIR_DOMAIN_OSTYPE_AIX, 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(-1, VIR_ARCH_AARCH64, VIR_DOMAIN_VIRT_KVM, + "/usr/bin/qemu-system-aarch64", NULL); + CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, -1, + "/usr/bin/qemu-system-aarch64", "pc"); + CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc"); + + out: + virObjectUnref(caps); + return ret; +} + +static int +test_virCapsDomainDataLookupXen(const void *data ATTRIBUTE_UNUSED) +{ + int ret = -1; + virCapsPtr caps = NULL; + + if (!(caps = testXenCapsInit())) { + ret = -1; + goto out; + } + + CAPSCOMP(-1, VIR_ARCH_NONE, -1, 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, + 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"); + + ret = 0; + out: + virObjectUnref(caps); + return ret; +} + +static int +test_virCapsDomainDataLookupLXC(const void *data ATTRIBUTE_UNUSED) +{ + int ret = 0; + virCapsPtr caps = NULL; + + if (!(caps = testLXCCapsInit())) { + ret = -1; + goto out; + } + + CAPSCOMP(-1, VIR_ARCH_NONE, -1, NULL, NULL, + VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_I686, + VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); + CAPSCOMP(-1, VIR_ARCH_X86_64, -1, NULL, NULL, + VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64, + VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); + + out: + virObjectUnref(caps); + return ret; +} + static int mymain(void) { @@ -126,6 +320,15 @@ mymain(void) if (virtTestRun("virCapabilitiesGetCpusForNodemask", test_virCapabilitiesGetCpusForNodemask, NULL) < 0) ret = -1; + if (virtTestRun("virCapsDomainDataLookupQEMU", + test_virCapsDomainDataLookupQEMU, NULL) < 0) + ret = -1; + if (virtTestRun("virCapsDomainDataLookupXen", + test_virCapsDomainDataLookupXen, NULL) < 0) + ret = -1; + if (virtTestRun("virCapsDomainDataLookupLXC", + test_virCapsDomainDataLookupLXC, NULL) < 0) + ret = -1; return ret; } -- 2.3.5

On 18.04.2015 03:45, Cole Robinson wrote:
This is a helper function to look up all capabilities data for all the OS bits that are relevant to <domain>. This is
- os type - arch - domain type - emulator - machine type
This will be used to replace several functions in later commits. --- src/conf/capabilities.c | 163 +++++++++++++++++++++++++++++++++++- src/conf/capabilities.h | 18 ++++ src/libvirt_private.syms | 1 + tests/Makefile.am | 8 +- tests/vircapstest.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 393 insertions(+), 6 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 9f84766..8d3d2a3 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -225,7 +225,6 @@ virCapabilitiesDispose(void *object) virCPUDefFree(caps->host.cpu); }
- /** * virCapabilitiesAddHostFeature: * @caps: capabilities to extend @@ -568,6 +567,168 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel, return -1; }
+static bool +virCapsDomainDataCompare(virCapsGuestPtr guest, + virCapsGuestDomainPtr domain, + virCapsGuestMachinePtr machine, + int ostype, + virArch arch, + int domaintype, + const char *emulator, + const char *machinetype) +{ + char *check_emulator = NULL;
const char please to make it obvious we don't modify it.
+ + if (ostype != -1 && guest->ostype != ostype) + return false; + if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch)) + return false; + + if (domaintype != -1 && (!domain || domain->type != domaintype)) + return false; + + if (emulator) { + if (domain) + check_emulator = domain->info.emulator; + if (!check_emulator) + check_emulator = guest->arch.defaultInfo.emulator; + if (!check_emulator || STRNEQ(check_emulator, emulator))
or STRNEQ_NULLABLE()
+ return false; + } + + if (machinetype) { + if (!machine) + return false; + if (STRNEQ(machine->name, machinetype) && + (!machine->canonical || STRNEQ(machine->canonical, machinetype)))
and here as well.
+ return false; + } + + return true; +} +
/** * virCapabilitiesSupportsGuestArch: * @caps: capabilities to query diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 7ee834f..87acf39 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -192,6 +192,16 @@ struct _virCaps { virCapsGuestPtr *guests; };
+typedef struct _virCapsDomainData virCapsDomainData; +typedef virCapsDomainData *virCapsDomainDataPtr; +struct _virCapsDomainData { + int ostype; + int arch; + int domaintype; + char *emulator; + char *machinetype;
const char to both please. You are copying over the pointer to live data so we must discourage people to free any of the pair. I know that 'const' is not a sufficient protection, but it's at least something.
+}; +
Michal

Just move this code to where we parse virtType. Lots of things depend on os.type values so it should be handled early like virtType. --- src/conf/domain_conf.c | 182 ++++++++++++++++++++++++------------------------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 59002fd..db0079b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13685,6 +13685,97 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } + def->os.bootloader = virXPathString("string(./bootloader)", ctxt); + def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt); + + tmp = virXPathString("string(./os/type[1])", ctxt); + if (!tmp) { + if (def->os.bootloader) { + def->os.type = VIR_DOMAIN_OSTYPE_XEN; + } else { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("an os <type> must be specified")); + goto error; + } + } else { + if ((def->os.type = virDomainOSTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown OS type '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + } + + /* + * HACK: For xen driver we previously used bogus 'linux' as the + * os type for paravirt, whereas capabilities declare it to + * be 'xen'. So we accept the former and convert + */ + if (def->os.type == VIR_DOMAIN_OSTYPE_LINUX && + def->virtType == VIR_DOMAIN_VIRT_XEN) { + def->os.type = VIR_DOMAIN_OSTYPE_XEN; + } + + tmp = virXPathString("string(./os/type[1]/@arch)", ctxt); + if (tmp && !(def->os.arch = virArchFromString(tmp))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown architecture %s"), + tmp); + goto error; + } + VIR_FREE(tmp); + + def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt); + def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); + + if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) { + if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no support found for os <type> '%s'"), + virDomainOSTypeToString(def->os.type)); + goto error; + } + + if (def->os.arch) { + if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No guest options available for arch '%s'"), + virArchToString(def->os.arch)); + goto error; + } + + if (!virCapabilitiesSupportsGuestOSTypeArch(caps, + def->os.type, + def->os.arch)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No os type '%s' available for arch '%s'"), + virDomainOSTypeToString(def->os.type), + virArchToString(def->os.arch)); + goto error; + } + } else { + def->os.arch = + virCapabilitiesDefaultGuestArch(caps, + def->os.type, + def->virtType); + if (!def->os.arch) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no supported architecture for os type '%s'"), + virDomainOSTypeToString(def->os.type)); + goto error; + } + } + + if (!def->os.machine) { + const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, + def->os.type, + def->os.arch, + def->virtType); + if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) + goto error; + } + } + /* Extract domain name */ if (!(def->name = virXPathString("string(./name[1])", ctxt))) { virReportError(VIR_ERR_NO_NAME, NULL); @@ -14618,96 +14709,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); - def->os.bootloader = virXPathString("string(./bootloader)", ctxt); - def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt); - - tmp = virXPathString("string(./os/type[1])", ctxt); - if (!tmp) { - if (def->os.bootloader) { - def->os.type = VIR_DOMAIN_OSTYPE_XEN; - } else { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("an os <type> must be specified")); - goto error; - } - } else { - if ((def->os.type = virDomainOSTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown OS type '%s'"), tmp); - goto error; - } - VIR_FREE(tmp); - } - - /* - * HACK: For xen driver we previously used bogus 'linux' as the - * os type for paravirt, whereas capabilities declare it to - * be 'xen'. So we accept the former and convert - */ - if (def->os.type == VIR_DOMAIN_OSTYPE_LINUX && - def->virtType == VIR_DOMAIN_VIRT_XEN) { - def->os.type = VIR_DOMAIN_OSTYPE_XEN; - } - - tmp = virXPathString("string(./os/type[1]/@arch)", ctxt); - if (tmp && !(def->os.arch = virArchFromString(tmp))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown architecture %s"), - tmp); - goto error; - } - VIR_FREE(tmp); - - def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt); - - if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) { - if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("no support found for os <type> '%s'"), - virDomainOSTypeToString(def->os.type)); - goto error; - } - - if (def->os.arch) { - if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No guest options available for arch '%s'"), - virArchToString(def->os.arch)); - goto error; - } - - if (!virCapabilitiesSupportsGuestOSTypeArch(caps, - def->os.type, - def->os.arch)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No os type '%s' available for arch '%s'"), - virDomainOSTypeToString(def->os.type), - virArchToString(def->os.arch)); - goto error; - } - } else { - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - def->virtType); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - virDomainOSTypeToString(def->os.type)); - goto error; - } - } - - if (!def->os.machine) { - const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - def->virtType); - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto error; - } - } - /* * Booting options for different OS types.... @@ -14771,7 +14772,6 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } - def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); /* analysis of the disk devices */ if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0) -- 2.3.5

The strange logic here is just to duplicate the previous behavior, which parts of the test suite are currently relying on. --- src/conf/capabilities.c | 68 ------------------------------------------------- src/conf/capabilities.h | 11 -------- src/conf/domain_conf.c | 61 ++++++++++++++------------------------------ 3 files changed, 19 insertions(+), 121 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 8d3d2a3..a2b6451 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -730,74 +730,6 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, } /** - * virCapabilitiesSupportsGuestArch: - * @caps: capabilities to query - * @arch: Architecture to search for - * - * Returns non-zero if the capabilities support the - * requested architecture - */ -extern int -virCapabilitiesSupportsGuestArch(virCapsPtr caps, - virArch arch) -{ - size_t i; - for (i = 0; i < caps->nguests; i++) { - if (caps->guests[i]->arch.id == arch) - return 1; - } - return 0; -} - - -/** - * virCapabilitiesSupportsGuestOSType: - * @caps: capabilities to query - * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE - * - * Returns non-zero if the capabilities support the - * requested operating system type - */ -extern int -virCapabilitiesSupportsGuestOSType(virCapsPtr caps, - int ostype) -{ - size_t i; - - for (i = 0; i < caps->nguests; i++) { - if (caps->guests[i]->ostype == ostype) - return 1; - } - return 0; -} - - -/** - * virCapabilitiesSupportsGuestOSTypeArch: - * @caps: capabilities to query - * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE - * @arch: Architecture to search for - * - * Returns non-zero if the capabilities support the - * requested operating system type - */ -extern int -virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, - int ostype, - virArch arch) -{ - size_t i; - - for (i = 0; i < caps->nguests; i++) { - if (caps->guests[i]->ostype == ostype && - caps->guests[i]->arch.id == arch) - return 1; - } - return 0; -} - - -/** * virCapabilitiesDefaultGuestArch: * @caps: capabilities to query * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 87acf39..948a1a5 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -280,17 +280,6 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, const char *emulator, const char *machinetype); -extern int -virCapabilitiesSupportsGuestArch(virCapsPtr caps, - virArch arch); -extern int -virCapabilitiesSupportsGuestOSType(virCapsPtr caps, - int ostype); -extern int -virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, - int ostype, - virArch arch); - void virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu, size_t ncpus); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index db0079b..4d9d4b5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13729,51 +13729,28 @@ virDomainDefParseXML(xmlDocPtr xml, def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) { - if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("no support found for os <type> '%s'"), - virDomainOSTypeToString(def->os.type)); - goto error; - } + /* 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); + virCapsDomainDataPtr capsdata = NULL; - if (def->os.arch) { - if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No guest options available for arch '%s'"), - virArchToString(def->os.arch)); - goto error; - } - - if (!virCapabilitiesSupportsGuestOSTypeArch(caps, - def->os.type, - def->os.arch)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No os type '%s' available for arch '%s'"), - virDomainOSTypeToString(def->os.type), - virArchToString(def->os.arch)); - goto error; - } - } else { - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - def->virtType); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - virDomainOSTypeToString(def->os.type)); - goto error; - } - } + if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, + def->os.arch, use_virttype ? def->virtType : -1, + NULL, NULL))) + goto error; - if (!def->os.machine) { - const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - def->virtType); - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto error; + if (!def->os.arch) + def->os.arch = capsdata->arch; + if ((!def->os.machine && + VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0)) { + VIR_FREE(capsdata); + goto error; } + VIR_FREE(capsdata); } /* Extract domain name */ -- 2.3.5

This revealed that GuestDefaultEmulator was a bit buggy, capable of returning an emulator that didn't match the passed domain type. Fix up the test suite input to continue to pass. --- src/conf/capabilities.c | 122 ----------------------------- src/conf/capabilities.h | 15 ---- src/conf/domain_conf.c | 21 ++--- src/libvirt_private.syms | 3 - src/qemu/qemu_capabilities.c | 13 +-- src/qemu/qemu_command.c | 19 +++-- src/xenconfig/xen_common.c | 37 ++++----- tests/securityselinuxlabeldata/chardev.xml | 2 +- tests/securityselinuxlabeldata/disks.xml | 2 +- tests/securityselinuxlabeldata/kernel.xml | 2 +- tests/securityselinuxlabeldata/nfs.xml | 2 +- 11 files changed, 43 insertions(+), 195 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index a2b6451..c9e5a64 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -729,128 +729,6 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, return ret; } -/** - * virCapabilitiesDefaultGuestArch: - * @caps: capabilities to query - * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE - * @domain: domain type to search for, of enum VIR_DOMAIN_VIRT - * - * Returns the first architecture able to run the - * requested operating system type - */ -extern virArch -virCapabilitiesDefaultGuestArch(virCapsPtr caps, - int ostype, - int domain) -{ - size_t i, j; - - /* First try to find one matching host arch */ - for (i = 0; i < caps->nguests; i++) { - if (caps->guests[i]->ostype == ostype) { - for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { - if (caps->guests[i]->arch.domains[j]->type == domain && - caps->guests[i]->arch.id == caps->host.arch) - return caps->guests[i]->arch.id; - } - } - } - - /* Otherwise find the first match */ - for (i = 0; i < caps->nguests; i++) { - if (caps->guests[i]->ostype == ostype) { - for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { - if (caps->guests[i]->arch.domains[j]->type == domain) - return caps->guests[i]->arch.id; - } - } - } - - return VIR_ARCH_NONE; -} - -/** - * virCapabilitiesDefaultGuestMachine: - * @caps: capabilities to query - * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE - * @arch: architecture to search for - * @domain: domain type to search for, of enum VIR_DOMAIN_VIRT - * - * Returns the first machine variant associated with - * the requested operating system type, architecture - * and domain type - */ -extern const char * -virCapabilitiesDefaultGuestMachine(virCapsPtr caps, - int ostype, - virArch arch, - int domain) -{ - size_t i; - - for (i = 0; i < caps->nguests; i++) { - virCapsGuestPtr guest = caps->guests[i]; - size_t j; - - if (guest->ostype != ostype || - guest->arch.id != arch) - continue; - - for (j = 0; j < guest->arch.ndomains; j++) { - virCapsGuestDomainPtr dom = guest->arch.domains[j]; - - if (dom->type != domain) - continue; - - if (!dom->info.nmachines) - break; - - return dom->info.machines[0]->name; - } - - if (guest->arch.defaultInfo.nmachines) - return caps->guests[i]->arch.defaultInfo.machines[0]->name; - } - - return NULL; -} - -/** - * virCapabilitiesDefaultGuestEmulator: - * @caps: capabilities to query - * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE - * @arch: architecture to search for - * @domain: domain type to search for, of enum VIR_DOMAIN_VIRT - * - * Returns the first emulator path associated with - * the requested operating system type, architecture - * and domain type - */ -extern const char * -virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, - int ostype, - virArch arch, - int domain) -{ - size_t i, j; - - for (i = 0; i < caps->nguests; i++) { - char *emulator; - if (caps->guests[i]->ostype == ostype && - caps->guests[i]->arch.id == arch) { - emulator = caps->guests[i]->arch.defaultInfo.emulator; - for (j = 0; j < caps->guests[i]->arch.ndomains; j++) { - if (caps->guests[i]->arch.domains[j]->type == domain) { - if (caps->guests[i]->arch.domains[j]->info.emulator) - emulator = caps->guests[i]->arch.domains[j]->info.emulator; - } - } - return emulator; - } - } - return NULL; -} - static int virCapabilitiesFormatNUMATopology(virBufferPtr buf, size_t ncells, diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 948a1a5..2a3a8f0 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -284,21 +284,6 @@ void virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu, size_t ncpus); -extern virArch -virCapabilitiesDefaultGuestArch(virCapsPtr caps, - int ostype, - int domain); -extern const char * -virCapabilitiesDefaultGuestMachine(virCapsPtr caps, - int ostype, - virArch arch, - int domain); -extern const char * -virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, - int ostype, - virArch arch, - int domain); - extern char * virCapabilitiesFormatXML(virCapsPtr caps); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4d9d4b5..911cee3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12959,25 +12959,18 @@ char * virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) { - const char *emulator; char *retemu; + virCapsDomainDataPtr capsdata; - emulator = virCapabilitiesDefaultGuestEmulator(caps, - def->os.type, - def->os.arch, - def->virtType); + if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, + def->os.arch, def->virtType, NULL, NULL))) + return NULL; - if (!emulator) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no emulator for domain %s os type %s " - "on architecture %s"), - virDomainVirtTypeToString(def->virtType), - virDomainOSTypeToString(def->os.type), - virArchToString(def->os.arch)); + if (VIR_STRDUP(retemu, capsdata->emulator) < 0) { + VIR_FREE(capsdata); return NULL; } - - ignore_value(VIR_STRDUP(retemu, emulator)); + VIR_FREE(capsdata); return retemu; } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5843061..48785d1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -51,9 +51,6 @@ virCapabilitiesAddHostMigrateTransport; virCapabilitiesAddHostNUMACell; virCapabilitiesAllocMachines; virCapabilitiesClearHostNUMACellCPUTopology; -virCapabilitiesDefaultGuestArch; -virCapabilitiesDefaultGuestEmulator; -virCapabilitiesDefaultGuestMachine; virCapabilitiesDomainDataLookup; virCapabilitiesFormatXML; virCapabilitiesFreeMachines; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ad50360..01ed1e2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1888,25 +1888,26 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps, virQEMUCapsCachePtr capsCache, unsigned int *version) { - const char *binary; virQEMUCapsPtr qemucaps; virArch hostarch; + virCapsDomainDataPtr capsdata; if (*version > 0) return 0; hostarch = virArchFromHost(); - if ((binary = virCapabilitiesDefaultGuestEmulator(caps, - VIR_DOMAIN_OSTYPE_HVM, - hostarch, - VIR_DOMAIN_VIRT_QEMU)) == NULL) { + if (!(capsdata = virCapabilitiesDomainDataLookup(caps, + VIR_DOMAIN_OSTYPE_HVM, hostarch, VIR_DOMAIN_VIRT_QEMU, + NULL, NULL))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot find suitable emulator for %s"), virArchToString(hostarch)); return -1; } - if (!(qemucaps = virQEMUCapsCacheLookup(capsCache, binary))) + qemucaps = virQEMUCapsCacheLookup(capsCache, capsdata->emulator); + VIR_FREE(capsdata); + if (!qemucaps) return -1; *version = virQEMUCapsGetVersion(qemucaps); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8e7b689..29b876e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -13145,14 +13145,17 @@ qemuParseCommandLine(virCapsPtr qemuCaps, } if (!def->os.machine) { - const char *defaultMachine = - virCapabilitiesDefaultGuestMachine(qemuCaps, - def->os.type, - def->os.arch, - def->virtType); - if (defaultMachine != NULL) - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - goto error; + virCapsDomainDataPtr capsdata; + + if (!(capsdata = virCapabilitiesDomainDataLookup(qemuCaps, def->os.type, + def->os.arch, def->virtType, NULL, NULL))) + goto error; + + if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0) { + VIR_FREE(capsdata); + goto error; + } + VIR_FREE(capsdata); } if (!nographics && def->ngraphics == 0) { diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 728b910..0dfe60e 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -983,15 +983,15 @@ xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def) static int xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) { - const char *defaultMachine; + virCapsDomainDataPtr capsdata = NULL; const char *str; - int hvm = 0; + int hvm = 0, ret = -1; if (xenConfigCopyString(conf, "name", &def->name) < 0) - return -1; + goto out; if (xenConfigGetUUID(conf, "uuid", def->uuid) < 0) - return -1; + goto out; if ((xenConfigGetString(conf, "builder", &str, "linux") == 0) && STREQ(str, "hvm")) @@ -999,27 +999,18 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN); - def->os.arch = - virCapabilitiesDefaultGuestArch(caps, - def->os.type, - def->virtType); - if (!def->os.arch) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - virDomainOSTypeToString(def->os.type)); - return -1; - } + if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, + VIR_ARCH_NONE, def->virtType, NULL, NULL))) + goto out; - defaultMachine = virCapabilitiesDefaultGuestMachine(caps, - def->os.type, - def->os.arch, - def->virtType); - if (defaultMachine != NULL) { - if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) - return -1; - } + def->os.arch = capsdata->arch; + if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0) + goto out; - return 0; + ret = 0; + out: + VIR_FREE(capsdata); + return ret; } diff --git a/tests/securityselinuxlabeldata/chardev.xml b/tests/securityselinuxlabeldata/chardev.xml index 64b6b5f..33002e4 100644 --- a/tests/securityselinuxlabeldata/chardev.xml +++ b/tests/securityselinuxlabeldata/chardev.xml @@ -3,7 +3,7 @@ <uuid>c7b3edbd-edaf-9455-926a-d65c16db1800</uuid> <memory unit='KiB'>219200</memory> <os> - <type arch='i686' machine='pc-1.0'>hvm</type> + <type arch='x86_64' machine='pc-1.0'>hvm</type> <boot dev='cdrom'/> </os> <devices> diff --git a/tests/securityselinuxlabeldata/disks.xml b/tests/securityselinuxlabeldata/disks.xml index 33e8763..08f0587 100644 --- a/tests/securityselinuxlabeldata/disks.xml +++ b/tests/securityselinuxlabeldata/disks.xml @@ -3,7 +3,7 @@ <uuid>c7b3edbd-edaf-9455-926a-d65c16db1800</uuid> <memory unit='KiB'>219200</memory> <os> - <type arch='i686' machine='pc-1.0'>hvm</type> + <type arch='x86_64' machine='pc-1.0'>hvm</type> <boot dev='cdrom'/> </os> <devices> diff --git a/tests/securityselinuxlabeldata/kernel.xml b/tests/securityselinuxlabeldata/kernel.xml index 0fd551d..1e0cd15 100644 --- a/tests/securityselinuxlabeldata/kernel.xml +++ b/tests/securityselinuxlabeldata/kernel.xml @@ -3,7 +3,7 @@ <uuid>c7b3edbd-edaf-9455-926a-d65c16db1800</uuid> <memory unit='KiB'>219200</memory> <os> - <type arch='i686' machine='pc-1.0'>hvm</type> + <type arch='x86_64' machine='pc-1.0'>hvm</type> <kernel>/vmlinuz.raw</kernel> <initrd>/initrd.raw</initrd> </os> diff --git a/tests/securityselinuxlabeldata/nfs.xml b/tests/securityselinuxlabeldata/nfs.xml index 46a1440..cac12dd 100644 --- a/tests/securityselinuxlabeldata/nfs.xml +++ b/tests/securityselinuxlabeldata/nfs.xml @@ -3,7 +3,7 @@ <uuid>c7b3edbd-edaf-9455-926a-d65c16db1800</uuid> <memory unit='KiB'>219200</memory> <os> - <type arch='i686' machine='pc-1.0'>hvm</type> + <type arch='x86_64' machine='pc-1.0'>hvm</type> <boot dev='cdrom'/> </os> <devices> -- 2.3.5

This needs to specified in way too many places for a simple validation check. The ostype/arch/virttype validation checks later in DomainDefParseXML should catch most of the cases that this was covering. --- src/bhyve/bhyve_driver.c | 5 --- src/conf/domain_conf.c | 79 +++++---------------------------------- src/conf/domain_conf.h | 6 --- src/conf/snapshot_conf.c | 14 ++----- src/conf/snapshot_conf.h | 2 - src/esx/esx_driver.c | 4 +- src/libxl/libxl_domain.c | 1 - src/libxl/libxl_driver.c | 6 --- src/libxl/libxl_migration.c | 2 - src/lxc/lxc_controller.c | 1 - src/lxc/lxc_driver.c | 5 --- src/openvz/openvz_driver.c | 3 -- src/parallels/parallels_driver.c | 1 - src/phyp/phyp_driver.c | 1 - src/qemu/qemu_domain.c | 1 - src/qemu/qemu_domain.h | 6 --- src/qemu/qemu_driver.c | 12 ------ src/qemu/qemu_migration.c | 5 +-- src/test/test_driver.c | 7 ---- src/uml/uml_driver.c | 4 -- src/vbox/vbox_common.c | 4 +- src/vmware/vmware_driver.c | 2 - src/xen/xen_driver.c | 3 -- tests/domainconftest.c | 3 +- tests/domainsnapshotxml2xmltest.c | 1 - tests/lxcxml2xmltest.c | 1 - tests/qemuagenttest.c | 1 - tests/qemuhotplugtest.c | 1 - tests/qemuxml2argvtest.c | 1 - tests/qemuxml2xmltest.c | 3 +- tests/qemuxmlnstest.c | 1 - tests/securityselinuxlabeltest.c | 4 +- tests/xlconfigtest.c | 1 - tests/xmconfigtest.c | 1 - tests/xml2sexprtest.c | 1 - tests/xml2vmxtest.c | 1 - 36 files changed, 19 insertions(+), 175 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 21db277..edbf1e4 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -507,7 +507,6 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag return NULL; if ((def = virDomainDefParseString(xml, caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_BHYVE, parse_flags)) == NULL) goto cleanup; @@ -695,7 +694,6 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, goto cleanup; if (!(def = virDomainDefParseString(xmlData, caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_BHYVE, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; @@ -910,7 +908,6 @@ bhyveDomainCreateXML(virConnectPtr conn, return NULL; if ((def = virDomainDefParseString(xml, caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_BHYVE, parse_flags)) == NULL) goto cleanup; @@ -1220,7 +1217,6 @@ bhyveStateInitialize(bool privileged, NULL, 1, bhyve_driver->caps, bhyve_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_BHYVE, NULL, NULL) < 0) goto cleanup; @@ -1229,7 +1225,6 @@ bhyveStateInitialize(bool privileged, BHYVE_AUTOSTART_DIR, 0, bhyve_driver->caps, bhyve_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_BHYVE, NULL, NULL) < 0) goto cleanup; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 911cee3..63b65b9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26,7 +26,6 @@ #include <dirent.h> #include <fcntl.h> -#include <strings.h> #include <sys/stat.h> #include <unistd.h> @@ -61,11 +60,6 @@ VIR_LOG_INIT("conf.domain_conf"); -/* virDomainVirtType is used to set bits in the expectedVirtTypes bitmask, - * verify that it doesn't overflow an unsigned int when shifting */ -verify(VIR_DOMAIN_VIRT_LAST <= 32); - - struct _virDomainObjList { virObjectLockable parent; @@ -13590,7 +13584,6 @@ virDomainDefParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { xmlNodePtr *nodes = NULL, node = NULL; @@ -13642,42 +13635,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(tmp); - if ((expectedVirtTypes & (1 << def->virtType)) == 0) { - if (count_one_bits(expectedVirtTypes) == 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected domain type %s, expecting %s"), - virDomainVirtTypeToString(def->virtType), - virDomainVirtTypeToString(ffs(expectedVirtTypes) - 1)); - } else { - virBuffer buffer = VIR_BUFFER_INITIALIZER; - char *string; - - for (i = 0; i < VIR_DOMAIN_VIRT_LAST; ++i) { - if ((expectedVirtTypes & (1 << i)) != 0) { - if (virBufferUse(&buffer) > 0) - virBufferAddLit(&buffer, ", "); - - virBufferAdd(&buffer, virDomainVirtTypeToString(i), -1); - } - } - - if (virBufferCheckError(&buffer) < 0) - goto error; - - string = virBufferContentAndReset(&buffer); - - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected domain type %s, " - "expecting one of these: %s"), - virDomainVirtTypeToString(def->virtType), - string); - - VIR_FREE(string); - } - - goto error; - } - def->os.bootloader = virXPathString("string(./bootloader)", ctxt); def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt); @@ -15472,7 +15429,6 @@ virDomainObjParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { char *tmp = NULL; @@ -15497,8 +15453,7 @@ virDomainObjParseXML(xmlDocPtr xml, oldnode = ctxt->node; ctxt->node = config; - obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlopt, - expectedVirtTypes, flags); + obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlopt, flags); ctxt->node = oldnode; if (!obj->def) goto error; @@ -15571,7 +15526,6 @@ virDomainDefParse(const char *xmlStr, const char *filename, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { xmlDocPtr xml; @@ -15580,7 +15534,7 @@ virDomainDefParse(const char *xmlStr, if ((xml = virXMLParse(filename, xmlStr, _("(domain_definition)")))) { def = virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps, - xmlopt, expectedVirtTypes, flags); + xmlopt, flags); xmlFreeDoc(xml); } @@ -15592,22 +15546,18 @@ virDomainDefPtr virDomainDefParseString(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(xmlStr, NULL, caps, xmlopt, - expectedVirtTypes, flags); + return virDomainDefParse(xmlStr, NULL, caps, xmlopt, flags); } virDomainDefPtr virDomainDefParseFile(const char *filename, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(NULL, filename, caps, xmlopt, - expectedVirtTypes, flags); + return virDomainDefParse(NULL, filename, caps, xmlopt, flags); } @@ -15616,7 +15566,6 @@ virDomainDefParseNode(xmlDocPtr xml, xmlNodePtr root, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { xmlXPathContextPtr ctxt = NULL; @@ -15637,8 +15586,7 @@ virDomainDefParseNode(xmlDocPtr xml, } ctxt->node = root; - def = virDomainDefParseXML(xml, root, ctxt, caps, xmlopt, - expectedVirtTypes, flags); + def = virDomainDefParseXML(xml, root, ctxt, caps, xmlopt, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -15651,7 +15599,6 @@ virDomainObjParseNode(xmlDocPtr xml, xmlNodePtr root, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { xmlXPathContextPtr ctxt = NULL; @@ -15671,7 +15618,7 @@ virDomainObjParseNode(xmlDocPtr xml, } ctxt->node = root; - obj = virDomainObjParseXML(xml, ctxt, caps, xmlopt, expectedVirtTypes, flags); + obj = virDomainObjParseXML(xml, ctxt, caps, xmlopt, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -15683,7 +15630,6 @@ virDomainObjPtr virDomainObjParseFile(const char *filename, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { xmlDocPtr xml; @@ -15692,8 +15638,7 @@ virDomainObjParseFile(const char *filename, if ((xml = virXMLParseFile(filename))) { obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml), - caps, xmlopt, - expectedVirtTypes, flags); + caps, xmlopt, flags); xmlFreeDoc(xml); } @@ -21548,7 +21493,6 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, const char *configDir, const char *autostartDir, const char *name, - unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) { @@ -21561,7 +21505,6 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; if (!(def = virDomainDefParseFile(configFile, caps, xmlopt, - expectedVirtTypes, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS))) goto error; @@ -21598,7 +21541,6 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, const char *name, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) { @@ -21609,7 +21551,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) goto error; - if (!(obj = virDomainObjParseFile(statusFile, caps, xmlopt, expectedVirtTypes, + if (!(obj = virDomainObjParseFile(statusFile, caps, xmlopt, VIR_DOMAIN_DEF_PARSE_STATUS | VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES | @@ -21648,7 +21590,6 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, int liveStatus, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) { @@ -21687,7 +21628,6 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, entry->d_name, caps, xmlopt, - expectedVirtTypes, notify, opaque); else @@ -21697,7 +21637,6 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, configDir, autostartDir, entry->d_name, - expectedVirtTypes, notify, opaque); if (dom) { @@ -22148,7 +22087,7 @@ virDomainDefCopy(virDomainDefPtr src, if (!(xml = virDomainDefFormat(src, format_flags))) return NULL; - ret = virDomainDefParseString(xml, caps, xmlopt, -1, parse_flags); + ret = virDomainDefParseString(xml, caps, xmlopt, parse_flags); VIR_FREE(xml); return ret; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3c99019..25d3ee6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2577,29 +2577,24 @@ virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr, virDomainDefPtr virDomainDefParseString(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseFile(const char *filename, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc, xmlNodePtr root, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags); virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml, xmlNodePtr root, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags); virDomainObjPtr virDomainObjParseFile(const char *filename, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags); bool virDomainDefCheckABIStability(virDomainDefPtr src, @@ -2803,7 +2798,6 @@ int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, int liveStatus, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index e725a23..ea511ec 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -196,13 +196,12 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, /* flags is bitwise-or of virDomainSnapshotParseFlags. * If flags does not include VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE, then - * caps and expectedVirtTypes are ignored. + * caps are ignored. */ static virDomainSnapshotDefPtr virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { virDomainSnapshotDefPtr def = NULL; @@ -282,8 +281,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, goto cleanup; } def->dom = virDomainDefParseNode(ctxt->node->doc, domainNode, - caps, xmlopt, - expectedVirtTypes, domainflags); + caps, xmlopt, domainflags); if (!def->dom) goto cleanup; } else { @@ -387,7 +385,6 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml, xmlNodePtr root, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { xmlXPathContextPtr ctxt = NULL; @@ -405,8 +402,7 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml, } ctxt->node = root; - def = virDomainSnapshotDefParse(ctxt, caps, xmlopt, - expectedVirtTypes, flags); + def = virDomainSnapshotDefParse(ctxt, caps, xmlopt, flags); cleanup: xmlXPathFreeContext(ctxt); return def; @@ -416,7 +412,6 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags) { virDomainSnapshotDefPtr ret = NULL; @@ -426,8 +421,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, if ((xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)")))) { xmlKeepBlanksDefault(keepBlanksDefault); ret = virDomainSnapshotDefParseNode(xml, xmlDocGetRootElement(xml), - caps, xmlopt, - expectedVirtTypes, flags); + caps, xmlopt, flags); xmlFreeDoc(xml); } xmlKeepBlanksDefault(keepBlanksDefault); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 167b27f..4f0d096 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -104,13 +104,11 @@ typedef enum { virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags); virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(xmlDocPtr xml, xmlNodePtr root, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - unsigned int expectedVirtTypes, unsigned int flags); void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def); char *virDomainSnapshotDefFormat(const char *domain_uuid, diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 4652b96..bf51213 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2841,7 +2841,6 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, return NULL; def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!def) @@ -3056,7 +3055,6 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) /* Parse domain XML */ def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_VMWARE, parse_flags); if (!def) @@ -4188,7 +4186,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, return NULL; def = virDomainSnapshotDefParseString(xmlDesc, priv->caps, - priv->xmlopt, 0, 0); + priv->xmlopt, 0); if (!def) return NULL; diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index f33df42..3039427 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -607,7 +607,6 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver, } if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto error; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 1271149..7254428 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -605,7 +605,6 @@ libxlStateInitialize(bool privileged, 1, cfg->caps, libxl_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, NULL, NULL) < 0) goto error; @@ -618,7 +617,6 @@ libxlStateInitialize(bool privileged, 0, cfg->caps, libxl_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, NULL, NULL) < 0) goto error; @@ -658,7 +656,6 @@ libxlStateReload(void) 1, cfg->caps, libxl_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, NULL, libxl_driver); virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain, @@ -879,7 +876,6 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml, parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE; if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, parse_flags))) goto cleanup; @@ -2520,7 +2516,6 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, if (!(def = virDomainDefParseString(domainXml, cfg->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; @@ -2647,7 +2642,6 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE; if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, parse_flags))) goto cleanup; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 4010506..51993c6 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -239,7 +239,6 @@ libxlDomainMigrationBegin(virConnectPtr conn, if (xmlin) { if (!(tmpdef = virDomainDefParseString(xmlin, cfg->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto endjob; @@ -285,7 +284,6 @@ libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver, } if (!(def = virDomainDefParseString(dom_xml, cfg->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 2b5c9da..e144c2d 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -181,7 +181,6 @@ static virLXCControllerPtr virLXCControllerNew(const char *name) if ((ctrl->vm = virDomainObjParseFile(configFile, caps, xmlopt, - 1 << VIR_DOMAIN_VIRT_LXC, 0)) == NULL) goto error; ctrl->def = ctrl->vm->def; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b491f34..38d9bed 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -467,7 +467,6 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) goto cleanup; if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_LXC, parse_flags))) goto cleanup; @@ -1213,7 +1212,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, goto cleanup; if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_LXC, parse_flags))) goto cleanup; @@ -1661,7 +1659,6 @@ static int lxcStateInitialize(bool privileged, NULL, 1, caps, lxc_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_LXC, NULL, NULL) < 0) goto cleanup; @@ -1673,7 +1670,6 @@ static int lxcStateInitialize(bool privileged, cfg->autostartDir, 0, caps, lxc_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_LXC, NULL, NULL) < 0) goto cleanup; @@ -1738,7 +1734,6 @@ lxcStateReload(void) cfg->autostartDir, 0, caps, lxc_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_LXC, lxcNotifyLoadDomain, lxc_driver); virObjectUnref(caps); virObjectUnref(cfg); diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index f07337a..1bb8973 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -999,7 +999,6 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla openvzDriverLock(driver); if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_OPENVZ, parse_flags)) == NULL) goto cleanup; @@ -1096,7 +1095,6 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, openvzDriverLock(driver); if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_OPENVZ, parse_flags)) == NULL) goto cleanup; @@ -2331,7 +2329,6 @@ openvzDomainMigratePrepare3Params(virConnectPtr dconn, } if (!(def = virDomainDefParseString(dom_xml, driver->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_OPENVZ, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto error; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 5ea8ba3..843969b 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -705,7 +705,6 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int parallelsDriverLock(privconn); if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_PARALLELS, parse_flags)) == NULL) goto cleanup; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 007defa..e9a31d0 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3568,7 +3568,6 @@ phypDomainCreateXML(virConnectPtr conn, if (!(def = virDomainDefParseString(xml, phyp_driver->caps, phyp_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_PHYP, parse_flags))) goto err; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 603360f..1368386 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1788,7 +1788,6 @@ qemuDomainDefCopy(virQEMUDriverPtr driver, goto cleanup; if (!(ret = virDomainDefParseString(xml, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3225abb..6bea7c7 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -35,12 +35,6 @@ # include "qemu_capabilities.h" # include "virchrdev.h" -# define QEMU_EXPECTED_VIRT_TYPES \ - ((1 << VIR_DOMAIN_VIRT_QEMU) | \ - (1 << VIR_DOMAIN_VIRT_KQEMU) | \ - (1 << VIR_DOMAIN_VIRT_KVM) | \ - (1 << VIR_DOMAIN_VIRT_XEN)) - # define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \ (VIR_DOMAIN_XML_SECURE | \ VIR_DOMAIN_XML_UPDATE_CPU) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0f16678..6fc9696 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -517,7 +517,6 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, def = virDomainSnapshotDefParseString(xmlStr, caps, qemu_driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, flags); if (def == NULL) { /* Nothing we can do here, skip this one */ @@ -847,7 +846,6 @@ qemuStateInitialize(bool privileged, NULL, 1, qemu_driver->caps, qemu_driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, NULL, NULL) < 0) goto error; @@ -870,7 +868,6 @@ qemuStateInitialize(bool privileged, cfg->autostartDir, 0, qemu_driver->caps, qemu_driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, NULL, NULL) < 0) goto error; @@ -952,7 +949,6 @@ qemuStateReload(void) cfg->configDir, cfg->autostartDir, 0, caps, qemu_driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, qemuNotifyLoadDomain, qemu_driver); cleanup: virObjectUnref(cfg); @@ -1692,7 +1688,6 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn, goto cleanup; if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, parse_flags))) goto cleanup; @@ -3210,7 +3205,6 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, virDomainDefPtr def = NULL; if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) { goto endjob; } @@ -6371,7 +6365,6 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver, goto cleanup; if (!(newdef = virDomainDefParseString(newxml, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; @@ -6528,7 +6521,6 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, /* Create a domain from this XML */ if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto error; @@ -7108,7 +7100,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, goto cleanup; def = virDomainDefParseString(xmlData, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!def) goto cleanup; @@ -7437,7 +7428,6 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml goto cleanup; if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, parse_flags))) goto cleanup; @@ -14704,7 +14694,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE; if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, parse_flags))) goto cleanup; @@ -14782,7 +14771,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, * conversion in and back out of xml. */ if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) || !(def->dom = virDomainDefParseString(xml, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto endjob; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 611f53a..9344382 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1246,7 +1246,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, } mig->persistent = virDomainDefParseNode(doc, nodes[0], caps, driver->xmlopt, - -1, VIR_DOMAIN_DEF_PARSE_INACTIVE); + VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!mig->persistent) { /* virDomainDefParseNode already reported * an error for us */ @@ -2704,7 +2704,6 @@ static char if (xmlin) { if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; @@ -2907,7 +2906,6 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout); newdef = virDomainDefParseString(xmlout, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!newdef) goto cleanup; @@ -3393,7 +3391,6 @@ qemuMigrationPrepareDef(virQEMUDriverPtr driver, return NULL; if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 44f6adf..133805c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -758,7 +758,6 @@ testOpenDefault(virConnectPtr conn) if (!(domdef = virDomainDefParseString(defaultDomainXML, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto error; @@ -1024,7 +1023,6 @@ testParseDomainSnapshots(testConnPtr privconn, def = virDomainSnapshotDefParseNode(ctxt->doc, node, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL | VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE); @@ -1082,7 +1080,6 @@ testParseDomains(testConnPtr privconn, def = virDomainDefParseNode(ctxt->doc, node, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!def) goto error; @@ -1754,7 +1751,6 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, testDriverLock(privconn); if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, parse_flags)) == NULL) goto cleanup; @@ -2367,7 +2363,6 @@ testDomainRestoreFlags(virConnectPtr conn, xml[len] = '\0'; def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (!def) goto cleanup; @@ -2952,7 +2947,6 @@ static virDomainPtr testDomainDefineXMLFlags(virConnectPtr conn, testDriverLock(privconn); if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, parse_flags)) == NULL) goto cleanup; @@ -6716,7 +6710,6 @@ testDomainSnapshotCreateXML(virDomainPtr domain, if (!(def = virDomainSnapshotDefParseString(xmlDesc, privconn->caps, privconn->xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, parse_flags))) goto cleanup; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 6744702..9cee541 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -588,7 +588,6 @@ umlStateInitialize(bool privileged, uml_driver->autostartDir, 0, uml_driver->caps, uml_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_UML, NULL, NULL) < 0) goto error; @@ -657,7 +656,6 @@ umlStateReload(void) uml_driver->autostartDir, 0, uml_driver->caps, uml_driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_UML, umlNotifyLoadDomain, uml_driver); umlDriverUnlock(uml_driver); @@ -1620,7 +1618,6 @@ static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml, virNWFilterReadLockFilterUpdates(); umlDriverLock(driver); if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_UML, parse_flags))) goto cleanup; @@ -2100,7 +2097,6 @@ umlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) umlDriverLock(driver); if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_UML, parse_flags))) goto cleanup; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 8424713..0bb5d29 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1868,7 +1868,6 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags VBOX_IID_INITIALIZE(&mchiid); if (!(def = virDomainDefParseString(xml, data->caps, data->xmlopt, - 1 << VIR_DOMAIN_VIRT_VBOX, parse_flags))) { goto cleanup; } @@ -5335,7 +5334,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT, NULL); if (!(def = virDomainSnapshotDefParseString(xmlDesc, data->caps, - data->xmlopt, -1, + data->xmlopt, VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE))) goto cleanup; @@ -6756,7 +6755,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) def = virDomainSnapshotDefParseString(defXml, data->caps, data->xmlopt, - -1, VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE); if (!def) { diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 6967dbc..ec74fe3 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -385,7 +385,6 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla vmwareDriverLock(driver); if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_VMWARE, parse_flags)) == NULL) goto cleanup; @@ -677,7 +676,6 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, vmwareDriverLock(driver); if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, - 1 << VIR_DOMAIN_VIRT_VMWARE, parse_flags)) == NULL) goto cleanup; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 6cd3b76..7711f33 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -783,7 +783,6 @@ xenUnifiedDomainCreateXML(virConnectPtr conn, parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE; if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, parse_flags))) goto cleanup; @@ -1695,7 +1694,6 @@ xenUnifiedConnectDomainXMLToNative(virConnectPtr conn, } if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; @@ -1905,7 +1903,6 @@ xenUnifiedDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE; if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, parse_flags))) goto cleanup; diff --git a/tests/domainconftest.c b/tests/domainconftest.c index 3d6ebe1..b27dd14 100644 --- a/tests/domainconftest.c +++ b/tests/domainconftest.c @@ -56,8 +56,7 @@ static int testGetFilesystem(const void *opaque) if (virtTestLoadFile(filename, &xmlData) < 0) goto cleanup; - if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, - 1 << VIR_DOMAIN_VIRT_TEST, 0))) + if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, 0))) goto cleanup; fsdef = virDomainGetFilesystemForTarget(def, diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c index 845d52f..3955a19 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -97,7 +97,6 @@ testCompareXMLToXMLFiles(const char *inxml, if (!(def = virDomainSnapshotDefParseString(inXmlData, driver.caps, driver.xmlopt, - QEMU_EXPECTED_VIRT_TYPES, flags))) goto cleanup; diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index e372dcd..37997f5 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -37,7 +37,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) goto fail; if (!(def = virDomainDefParseString(inXmlData, caps, xmlopt, - 1 << VIR_DOMAIN_VIRT_LXC, live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index d8d1e41..4410ffe 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -186,7 +186,6 @@ testQemuAgentGetFSInfo(const void *data) goto cleanup; if (!(def = virDomainDefParseString(domain_xml, caps, xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index ea2cf77..08f764b 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -68,7 +68,6 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, if (!((*vm)->def = virDomainDefParseString(domxml, driver.caps, driver.xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8d0a4aa..bf3396a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -274,7 +274,6 @@ static int testCompareXMLToArgvFiles(const char *xml, goto out; if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) { if (!virtTestOOMActive() && (flags & FLAG_EXPECT_PARSE_ERROR)) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index c615d8e..bce04b2 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -55,7 +55,7 @@ testXML2XMLHelper(const char *inxml, format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE; if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt, - QEMU_EXPECTED_VIRT_TYPES, parse_flags))) + parse_flags))) goto fail; if (!virDomainDefCheckABIStability(def, def)) { @@ -177,7 +177,6 @@ testCompareStatusXMLToXMLFiles(const void *opaque) if (!(xml = virXMLParseString(source, "(domain_status_test_XML)")) || !(obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml), driver.caps, driver.xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_STATUS | VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES | diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 09b3d31..97a809a 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -55,7 +55,6 @@ static int testCompareXMLToArgvFiles(const char *xml, expectargv[len - 1] = '\0'; if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, - QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index 8106c77..c5e96e2 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -193,9 +193,7 @@ testSELinuxLoadDef(const char *testname) if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0) goto cleanup; - if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, - QEMU_EXPECTED_VIRT_TYPES, - 0))) + if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, 0))) goto cleanup; for (i = 0; i < def->ndisks; i++) { diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index bef8d75..8806566 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -70,7 +70,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) goto fail; if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 00a05ee..2db012e 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -73,7 +73,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) conn->privateData = &priv; if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index f65eaef..c706914 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -36,7 +36,6 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) goto fail; if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 19d62d3..b576f83 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -85,7 +85,6 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) goto failure; def = virDomainDefParseString(xmlData, caps, xmlopt, - 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (def == NULL) -- 2.3.5

On 18.04.2015 03:45, Cole Robinson wrote:
This needs to specified in way too many places for a simple validation check. The ostype/arch/virttype validation checks later in DomainDefParseXML should catch most of the cases that this was covering. --- src/bhyve/bhyve_driver.c | 5 --- src/conf/domain_conf.c | 79 +++++---------------------------------- src/conf/domain_conf.h | 6 --- src/conf/snapshot_conf.c | 14 ++----- src/conf/snapshot_conf.h | 2 - src/esx/esx_driver.c | 4 +- src/libxl/libxl_domain.c | 1 - src/libxl/libxl_driver.c | 6 --- src/libxl/libxl_migration.c | 2 - src/lxc/lxc_controller.c | 1 - src/lxc/lxc_driver.c | 5 --- src/openvz/openvz_driver.c | 3 -- src/parallels/parallels_driver.c | 1 - src/phyp/phyp_driver.c | 1 - src/qemu/qemu_domain.c | 1 - src/qemu/qemu_domain.h | 6 --- src/qemu/qemu_driver.c | 12 ------ src/qemu/qemu_migration.c | 5 +-- src/test/test_driver.c | 7 ---- src/uml/uml_driver.c | 4 -- src/vbox/vbox_common.c | 4 +- src/vmware/vmware_driver.c | 2 - src/xen/xen_driver.c | 3 -- tests/domainconftest.c | 3 +- tests/domainsnapshotxml2xmltest.c | 1 - tests/lxcxml2xmltest.c | 1 - tests/qemuagenttest.c | 1 - tests/qemuhotplugtest.c | 1 - tests/qemuxml2argvtest.c | 1 - tests/qemuxml2xmltest.c | 3 +- tests/qemuxmlnstest.c | 1 - tests/securityselinuxlabeltest.c | 4 +- tests/xlconfigtest.c | 1 - tests/xmconfigtest.c | 1 - tests/xml2sexprtest.c | 1 - tests/xml2vmxtest.c | 1 - 36 files changed, 19 insertions(+), 175 deletions(-)
This is missing: diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 63b65b9..479b4c2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -36,7 +36,6 @@ #include "domain_conf.h" #include "snapshot_conf.h" #include "viralloc.h" -#include "verify.h" #include "virxml.h" #include "viruuid.h" #include "virbuffer.h" diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 37867cf..35423b5 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -745,7 +745,6 @@ get_definition(vahControl * ctl, const char *xmlStr) ctl->def = virDomainDefParseString(xmlStr, ctl->caps, ctl->xmlopt, - -1, VIR_DOMAIN_DEF_PARSE_INACTIVE); if (ctl->def == NULL) { vah_error(ctl, 0, _("could not parse XML")); diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 881f5b2..11f6e91 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -565,7 +565,6 @@ xenapiDomainCreateXML(virConnectPtr conn, virDomainDefPtr defPtr = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, parse_flags); if (!defPtr) return NULL; @@ -1740,7 +1739,6 @@ xenapiDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla return NULL; virDomainDefPtr defPtr = virDomainDefParseString(xml, priv->caps, priv->xmlopt, - 1 << VIR_DOMAIN_VIRT_XEN, parse_flags); if (!defPtr) return NULL; Michal

On 18.04.2015 03:45, Cole Robinson wrote:
First two patches are straight bug fixes.
The rest is a bunch of internal cleanup I felt compelled to do. Summary is
- Switch caps and domain to use an enum for os.type value (hvm, xen, exe, ...) - Switch caps to use VIR_DOMAIN_VIRT* internally - Add a single function for looking up domain XML relevant values from capabilities, and test the crap out of it. - Use that function to simplfy and improve a lot of code.
Thanks, Cole
Cole Robinson (11): domain: conf: Better errors on bad os <type> values domain: conf: Don't validate VM ostype/arch at daemon startup caps: Use an enum internally for ostype value caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value domain: Convert os.type to VIR_DOMAIN_OSTYPE enum caps: Convert to use VIR_DOMAIN_VIRT internally caps: Add virCapabilitiesDomainDataLookup domain: conf: Do ostype/arch/machine parsing earlier domain: conf: Use CapabilitiesDomainDataLookup for caps validation caps: Use DomainDataLookup to replace GuestDefault* domain: conf: Drop expectedVirtTypes
src/bhyve/bhyve_capabilities.c | 6 +- src/bhyve/bhyve_driver.c | 5 - src/conf/capabilities.c | 307 ++++++++++++-------------- src/conf/capabilities.h | 50 ++--- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 331 +++++++++++------------------ src/conf/domain_conf.h | 25 ++- src/conf/snapshot_conf.c | 18 +- src/conf/snapshot_conf.h | 2 - src/esx/esx_driver.c | 12 +- src/hyperv/hyperv_driver.c | 4 +- src/libvirt_private.syms | 6 +- src/libxl/libxl_conf.c | 14 +- src/libxl/libxl_domain.c | 7 +- src/libxl/libxl_driver.c | 8 +- src/libxl/libxl_migration.c | 2 - src/lxc/lxc_conf.c | 8 +- src/lxc/lxc_controller.c | 1 - src/lxc/lxc_driver.c | 7 +- src/lxc/lxc_native.c | 4 +- src/openvz/openvz_conf.c | 7 +- src/openvz/openvz_driver.c | 7 +- src/parallels/parallels_driver.c | 23 +- src/parallels/parallels_sdk.c | 6 +- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 10 +- src/qemu/qemu_capabilities.c | 21 +- src/qemu/qemu_command.c | 29 +-- src/qemu/qemu_domain.c | 1 - src/qemu/qemu_domain.h | 6 - src/qemu/qemu_driver.c | 14 +- src/qemu/qemu_migration.c | 5 +- src/security/virt-aa-helper.c | 9 +- src/test/test_driver.c | 12 +- src/uml/uml_conf.c | 4 +- src/uml/uml_driver.c | 6 +- src/util/virerror.c | 5 +- src/vbox/vbox_common.c | 23 +- src/vmware/vmware_conf.c | 8 +- src/vmware/vmware_driver.c | 4 +- src/vmx/vmx.c | 3 +- src/xen/xen_driver.c | 5 +- src/xen/xen_hypervisor.c | 4 +- src/xen/xend_internal.c | 6 +- src/xenapi/xenapi_driver.c | 20 +- src/xenapi/xenapi_utils.c | 4 +- src/xenconfig/xen_common.c | 64 +++--- src/xenconfig/xen_sxpr.c | 5 +- src/xenconfig/xen_xl.c | 17 +- src/xenconfig/xen_xm.c | 12 +- tests/Makefile.am | 8 +- tests/domainconftest.c | 3 +- tests/domainsnapshotxml2xmltest.c | 1 - tests/lxcxml2xmltest.c | 1 - tests/openvzutilstest.c | 2 +- tests/qemuagenttest.c | 1 - tests/qemuhotplugtest.c | 1 - tests/qemuxml2argvtest.c | 1 - tests/qemuxml2xmltest.c | 3 +- tests/qemuxmlnstest.c | 1 - tests/securityselinuxlabeldata/chardev.xml | 2 +- tests/securityselinuxlabeldata/disks.xml | 2 +- tests/securityselinuxlabeldata/kernel.xml | 2 +- tests/securityselinuxlabeldata/nfs.xml | 2 +- tests/securityselinuxlabeltest.c | 4 +- tests/testutils.c | 8 +- tests/testutilslxc.c | 10 +- tests/testutilsqemu.c | 38 ++-- tests/testutilsxen.c | 18 +- tests/vircapstest.c | 209 +++++++++++++++++- tests/vmx2xmltest.c | 8 +- tests/xlconfigtest.c | 1 - tests/xmconfigtest.c | 1 - tests/xml2sexprtest.c | 1 - tests/xml2vmxtest.c | 9 +- 75 files changed, 742 insertions(+), 756 deletions(-)
ACK to series but see my comments before pushing. Michal

On 04/20/2015 09:52 AM, Michal Privoznik wrote:
On 18.04.2015 03:45, Cole Robinson wrote:
First two patches are straight bug fixes.
The rest is a bunch of internal cleanup I felt compelled to do. Summary is
- Switch caps and domain to use an enum for os.type value (hvm, xen, exe, ...) - Switch caps to use VIR_DOMAIN_VIRT* internally - Add a single function for looking up domain XML relevant values from capabilities, and test the crap out of it. - Use that function to simplfy and improve a lot of code.
Thanks, Cole
Cole Robinson (11): domain: conf: Better errors on bad os <type> values domain: conf: Don't validate VM ostype/arch at daemon startup caps: Use an enum internally for ostype value caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value domain: Convert os.type to VIR_DOMAIN_OSTYPE enum caps: Convert to use VIR_DOMAIN_VIRT internally caps: Add virCapabilitiesDomainDataLookup domain: conf: Do ostype/arch/machine parsing earlier domain: conf: Use CapabilitiesDomainDataLookup for caps validation caps: Use DomainDataLookup to replace GuestDefault* domain: conf: Drop expectedVirtTypes
src/bhyve/bhyve_capabilities.c | 6 +- src/bhyve/bhyve_driver.c | 5 - src/conf/capabilities.c | 307 ++++++++++++-------------- src/conf/capabilities.h | 50 ++--- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 331 +++++++++++------------------ src/conf/domain_conf.h | 25 ++- src/conf/snapshot_conf.c | 18 +- src/conf/snapshot_conf.h | 2 - src/esx/esx_driver.c | 12 +- src/hyperv/hyperv_driver.c | 4 +- src/libvirt_private.syms | 6 +- src/libxl/libxl_conf.c | 14 +- src/libxl/libxl_domain.c | 7 +- src/libxl/libxl_driver.c | 8 +- src/libxl/libxl_migration.c | 2 - src/lxc/lxc_conf.c | 8 +- src/lxc/lxc_controller.c | 1 - src/lxc/lxc_driver.c | 7 +- src/lxc/lxc_native.c | 4 +- src/openvz/openvz_conf.c | 7 +- src/openvz/openvz_driver.c | 7 +- src/parallels/parallels_driver.c | 23 +- src/parallels/parallels_sdk.c | 6 +- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 10 +- src/qemu/qemu_capabilities.c | 21 +- src/qemu/qemu_command.c | 29 +-- src/qemu/qemu_domain.c | 1 - src/qemu/qemu_domain.h | 6 - src/qemu/qemu_driver.c | 14 +- src/qemu/qemu_migration.c | 5 +- src/security/virt-aa-helper.c | 9 +- src/test/test_driver.c | 12 +- src/uml/uml_conf.c | 4 +- src/uml/uml_driver.c | 6 +- src/util/virerror.c | 5 +- src/vbox/vbox_common.c | 23 +- src/vmware/vmware_conf.c | 8 +- src/vmware/vmware_driver.c | 4 +- src/vmx/vmx.c | 3 +- src/xen/xen_driver.c | 5 +- src/xen/xen_hypervisor.c | 4 +- src/xen/xend_internal.c | 6 +- src/xenapi/xenapi_driver.c | 20 +- src/xenapi/xenapi_utils.c | 4 +- src/xenconfig/xen_common.c | 64 +++--- src/xenconfig/xen_sxpr.c | 5 +- src/xenconfig/xen_xl.c | 17 +- src/xenconfig/xen_xm.c | 12 +- tests/Makefile.am | 8 +- tests/domainconftest.c | 3 +- tests/domainsnapshotxml2xmltest.c | 1 - tests/lxcxml2xmltest.c | 1 - tests/openvzutilstest.c | 2 +- tests/qemuagenttest.c | 1 - tests/qemuhotplugtest.c | 1 - tests/qemuxml2argvtest.c | 1 - tests/qemuxml2xmltest.c | 3 +- tests/qemuxmlnstest.c | 1 - tests/securityselinuxlabeldata/chardev.xml | 2 +- tests/securityselinuxlabeldata/disks.xml | 2 +- tests/securityselinuxlabeldata/kernel.xml | 2 +- tests/securityselinuxlabeldata/nfs.xml | 2 +- tests/securityselinuxlabeltest.c | 4 +- tests/testutils.c | 8 +- tests/testutilslxc.c | 10 +- tests/testutilsqemu.c | 38 ++-- tests/testutilsxen.c | 18 +- tests/vircapstest.c | 209 +++++++++++++++++- tests/vmx2xmltest.c | 8 +- tests/xlconfigtest.c | 1 - tests/xmconfigtest.c | 1 - tests/xml2sexprtest.c | 1 - tests/xml2vmxtest.c | 9 +- 75 files changed, 742 insertions(+), 756 deletions(-)
ACK to series but see my comments before pushing.
Thanks for the review, and catching all those build issues in drivers I don't have enabled :) Pushed now with your suggested changes - Cole
participants (3)
-
Christophe Fergeau
-
Cole Robinson
-
Michal Privoznik