mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
lib: Don't check for virCapabilitiesAddGuestDomain() retval
The virCapabilitiesAddGuestDomain() function can't fail. It aborts on OOM. Therefore, there's no need to check for its return value. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c18d9e23fa
commit
2996a94dd0
@ -54,18 +54,13 @@ virBhyveCapsBuild(void)
|
||||
VIR_ARCH_X86_64, "bhyve",
|
||||
NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_BHYVE,
|
||||
NULL, NULL, 0, NULL) == NULL)
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_BHYVE,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (!(caps->host.cpu = virCPUProbeHost(caps->host.arch)))
|
||||
VIR_WARN("Failed to get host CPU");
|
||||
|
||||
return caps;
|
||||
|
||||
error:
|
||||
virObjectUnref(caps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -68,14 +68,8 @@ virCaps *virCHDriverCapsInit(void)
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
||||
caps->host.arch, NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_KVM,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
|
||||
NULL, NULL, 0, NULL);
|
||||
return caps;
|
||||
|
||||
cleanup:
|
||||
|
@ -567,8 +567,8 @@ esxCapsInit(esxPrivate *priv)
|
||||
NULL, NULL, 0,
|
||||
NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL))
|
||||
goto failure;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
/* x86_64 */
|
||||
if (supportsLongMode == esxVI_Boolean_True) {
|
||||
@ -577,8 +577,8 @@ esxCapsInit(esxPrivate *priv)
|
||||
NULL, NULL,
|
||||
0, NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0, NULL))
|
||||
goto failure;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
return caps;
|
||||
|
@ -277,15 +277,15 @@ hypervCapsInit(hypervPrivate *priv)
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HYPERV, NULL, NULL, 0, NULL))
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HYPERV,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
/* x86_64 caps */
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HYPERV, NULL, NULL, 0, NULL))
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HYPERV,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
return caps;
|
||||
|
||||
|
@ -486,13 +486,8 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCaps *caps)
|
||||
machines);
|
||||
machines = NULL;
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_XEN,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL)
|
||||
return -1;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (guest_archs[i].pae)
|
||||
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_PAE);
|
||||
|
@ -100,26 +100,16 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver)
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
|
||||
caps->host.arch, lxc_path, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_LXC,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL)
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
/* On 64-bit hosts, we can use personality() to request a 32bit process */
|
||||
if ((altArch = lxcContainerGetAlt32bitArch(caps->host.arch)) != VIR_ARCH_NONE) {
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
|
||||
altArch, lxc_path, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_LXC,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL)
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC,
|
||||
NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if (driver) {
|
||||
|
@ -159,13 +159,8 @@ virCaps *openvzCapsInit(void)
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
|
||||
caps->host.arch, NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_OPENVZ,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL)
|
||||
return NULL;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_OPENVZ,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
return g_steal_pointer(&caps);
|
||||
}
|
||||
|
@ -1065,25 +1065,13 @@ virQEMUCapsInitGuestFromBinary(virCaps *caps,
|
||||
true, false);
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG)) {
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_KVM,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL) {
|
||||
goto cleanup;
|
||||
}
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
|
||||
NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64))
|
||||
|
@ -650,15 +650,8 @@ get_definition(vahControl * ctl, const char *xmlStr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
virtType,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL) {
|
||||
vah_error(ctl, 0, _("could not allocate memory"));
|
||||
return -1;
|
||||
}
|
||||
virCapabilitiesAddGuestDomain(guest, virtType,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
ctl->def = virDomainDefParseString(xmlStr,
|
||||
ctl->xmlopt, NULL,
|
||||
|
@ -348,13 +348,8 @@ testBuildCapabilities(virConnectPtr conn)
|
||||
guest = virCapabilitiesAddGuest(caps, guest_types[i], VIR_ARCH_I686,
|
||||
TEST_EMULATOR, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_TEST,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL)
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_PAE);
|
||||
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_NONPAE);
|
||||
|
@ -104,13 +104,8 @@ vboxCapsInit(void)
|
||||
caps->host.arch, NULL, NULL, 0, NULL);
|
||||
return NULL;
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_VBOX,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL) == NULL)
|
||||
return NULL;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VBOX,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
return g_steal_pointer(&caps);
|
||||
}
|
||||
|
@ -81,10 +81,8 @@ vmwareCapsInit(void)
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
||||
VIR_ARCH_I686, NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL) == NULL)
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
guest = NULL;
|
||||
|
||||
if (!(caps->host.cpu = virCPUProbeHost(caps->host.arch)))
|
||||
@ -103,10 +101,8 @@ vmwareCapsInit(void)
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
||||
VIR_ARCH_X86_64, NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL) == NULL)
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
guest = NULL;
|
||||
}
|
||||
|
||||
|
@ -88,9 +88,7 @@ vzCapsAddGuestDomain(virCaps *caps,
|
||||
return -1;
|
||||
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, virt_type,
|
||||
NULL, NULL, 0, NULL) == NULL)
|
||||
return -1;
|
||||
virCapabilitiesAddGuestDomain(guest, virt_type, NULL, NULL, 0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -906,27 +906,22 @@ virTestGenericCapsInit(void)
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
|
||||
"/usr/bin/acme-virt", NULL, 0, NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, NULL, 0, NULL))
|
||||
return NULL;
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL, NULL, 0, NULL))
|
||||
return NULL;
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
|
||||
NULL, NULL, 0, NULL))
|
||||
return NULL;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST,
|
||||
NULL, NULL, 0, NULL);
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL, NULL, 0, NULL);
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
|
||||
"/usr/bin/acme-virt", NULL, 0, NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, NULL, 0, NULL))
|
||||
return NULL;
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL, NULL, 0, NULL))
|
||||
return NULL;
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
|
||||
NULL, NULL, 0, NULL))
|
||||
return NULL;
|
||||
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST,
|
||||
NULL, NULL, 0, NULL);
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL, NULL, 0, NULL);
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (virTestGetDebug() > 1) {
|
||||
g_autofree char *caps_str = NULL;
|
||||
|
@ -23,18 +23,14 @@ testLXCCapsInit(void)
|
||||
"/usr/libexec/libvirt_lxc", NULL,
|
||||
0, NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
|
||||
goto error;
|
||||
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL);
|
||||
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
|
||||
VIR_ARCH_X86_64,
|
||||
"/usr/libexec/libvirt_lxc", NULL,
|
||||
0, NULL);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
|
||||
goto error;
|
||||
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL);
|
||||
|
||||
if (virTestGetDebug()) {
|
||||
g_autofree char *caps_str = NULL;
|
||||
|
@ -176,13 +176,8 @@ testQemuAddGuest(virCaps *caps,
|
||||
arch == VIR_ARCH_X86_64)
|
||||
virCapabilitiesAddGuestFeature(guest, VIR_CAPS_GUEST_FEATURE_TYPE_CPUSELECTION);
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL))
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (kvm_machines[emu_arch] != NULL) {
|
||||
nmachines = g_strv_length((char **)kvm_machines[emu_arch]);
|
||||
@ -191,13 +186,9 @@ testQemuAddGuest(virCaps *caps,
|
||||
if (machines == NULL)
|
||||
goto error;
|
||||
|
||||
if (!virCapabilitiesAddGuestDomain(guest,
|
||||
VIR_DOMAIN_VIRT_KVM,
|
||||
qemu_emulators[emu_arch],
|
||||
NULL,
|
||||
nmachines,
|
||||
machines))
|
||||
goto error;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM,
|
||||
qemu_emulators[emu_arch],
|
||||
NULL, nmachines, machines);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -40,9 +40,8 @@ testXLInitCaps(void)
|
||||
"/usr/lib/xen/boot/hvmloader",
|
||||
nmachines, machines);
|
||||
machines = NULL;
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
||||
NULL, 0, NULL) == NULL)
|
||||
goto cleanup;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN,
|
||||
NULL, NULL, 0, NULL);
|
||||
nmachines = G_N_ELEMENTS(xen_machines);
|
||||
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
||||
goto cleanup;
|
||||
@ -54,9 +53,8 @@ testXLInitCaps(void)
|
||||
nmachines, machines);
|
||||
machines = NULL;
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
||||
NULL, 0, NULL) == NULL)
|
||||
goto cleanup;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN,
|
||||
NULL, NULL, 0, NULL);
|
||||
nmachines = G_N_ELEMENTS(pvh_machines);
|
||||
if ((machines = virCapabilitiesAllocMachines(pvh_machines, nmachines)) == NULL)
|
||||
goto cleanup;
|
||||
@ -68,9 +66,8 @@ testXLInitCaps(void)
|
||||
nmachines, machines);
|
||||
machines = NULL;
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
||||
NULL, 0, NULL) == NULL)
|
||||
goto cleanup;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN,
|
||||
NULL, NULL, 0, NULL);
|
||||
return caps;
|
||||
|
||||
cleanup:
|
||||
|
@ -35,26 +35,16 @@ testCapsInit(void)
|
||||
VIR_ARCH_I686,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0,
|
||||
NULL) == NULL) {
|
||||
goto failure;
|
||||
}
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
/* x86_64 guest */
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
||||
VIR_ARCH_X86_64,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0,
|
||||
NULL) == NULL) {
|
||||
goto failure;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
failure:
|
||||
virObjectUnref(caps);
|
||||
caps = NULL;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -36,27 +36,16 @@ testCapsInit(void)
|
||||
VIR_ARCH_I686,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0,
|
||||
NULL) == NULL) {
|
||||
goto failure;
|
||||
}
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
/* x86_64 guest */
|
||||
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
||||
VIR_ARCH_X86_64,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE, NULL, NULL, 0,
|
||||
NULL) == NULL) {
|
||||
goto failure;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
failure:
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlopt);
|
||||
caps = NULL;
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VMWARE,
|
||||
NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user