return -1;
}
-static bool
-virCapsDomainDataCompare(virCapsGuestPtr guest,
- virCapsGuestDomainPtr domain,
- virCapsGuestMachinePtr machine,
- int ostype,
- virArch arch,
- virDomainVirtType domaintype,
- const char *emulator,
- const char *machinetype)
-{
- const 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 != VIR_DOMAIN_VIRT_NONE &&
- (!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 (STRNEQ_NULLABLE(check_emulator, emulator))
- return false;
- }
-
- if (machinetype) {
- if (!machine)
- return false;
- if (STRNEQ(machine->name, machinetype) &&
- (STRNEQ_NULLABLE(machine->canonical, machinetype)))
- return false;
- }
-
- return true;
-}
static virCapsDomainDataPtr
virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
virCapsDomainDataPtr ret = NULL;
size_t i, j, k;
+ VIR_DEBUG("Lookup ostype=%d arch=%d domaintype=%d emulator=%s machine=%s",
+ ostype, arch, domaintype, NULLSTR(emulator), NULLSTR(machinetype));
for (i = 0; i < caps->nguests; i++) {
virCapsGuestPtr guest = caps->guests[i];
+ if (ostype != -1 && guest->ostype != ostype) {
+ VIR_DEBUG("Skip os type want=%d vs got=%d", ostype, guest->ostype);
+ continue;
+ }
+ VIR_DEBUG("Match os type %d", ostype);
+
+ if ((arch != VIR_ARCH_NONE) && (guest->arch.id != arch)) {
+ VIR_DEBUG("Skip arch want=%d vs got=%d", arch, guest->arch.id);
+ continue;
+ }
+ VIR_DEBUG("Match arch %d", arch);
+
for (j = 0; j < guest->arch.ndomains; j++) {
virCapsGuestDomainPtr domain = guest->arch.domains[j];
virCapsGuestMachinePtr *machinelist;
int nmachines;
+ const char *check_emulator = NULL;
+
+ if (domaintype != VIR_DOMAIN_VIRT_NONE &&
+ (domain->type != domaintype)) {
+ VIR_DEBUG("Skip domain type want=%d vs got=%d", domaintype, domain->type);
+ continue;
+ }
+ VIR_DEBUG("Match domain type %d", domaintype);
+
+ check_emulator = domain->info.emulator;
+ if (!check_emulator)
+ check_emulator = guest->arch.defaultInfo.emulator;
+ if (emulator && STRNEQ_NULLABLE(check_emulator, emulator)) {
+ VIR_DEBUG("Skip emulator got=%s vs want=%s",
+ emulator, NULLSTR(check_emulator));
+ continue;
+ }
+ VIR_DEBUG("Match emulator %s", NULLSTR(emulator));
if (domain->info.nmachines) {
nmachines = domain->info.nmachines;
for (k = 0; k < nmachines; k++) {
virCapsGuestMachinePtr machine = machinelist[k];
- if (!virCapsDomainDataCompare(guest, domain, machine,
- ostype, arch, domaintype,
- emulator, machinetype))
+
+ if (machinetype &&
+ STRNEQ(machine->name, machinetype) &&
+ STRNEQ_NULLABLE(machine->canonical, machinetype)) {
+ VIR_DEBUG("Skip machine type want=%s vs got=%s got=%s",
+ machinetype, machine->name, NULLSTR(machine->canonical));
continue;
+ }
+ VIR_DEBUG("Match machine type machine %s\n", NULLSTR(machinetype));
foundmachine = machine;
break;
}
- if (!foundmachine) {
- if (!virCapsDomainDataCompare(guest, domain, NULL,
- ostype, arch, domaintype,
- emulator, machinetype))
- continue;
- }
+ if (!foundmachine && nmachines)
+ continue;
founddomain = domain;
break;
}
- if (!founddomain) {
- if (!virCapsDomainDataCompare(guest, NULL, NULL,
- ostype, arch, domaintype,
- emulator, machinetype))
- continue;
- }
+ if (!founddomain)
+ continue;
foundguest = guest;
break;