libvirt/tests/testutilslxc.c
Michal Privoznik c8238579fb lib: Drop internal virXXXPtr typedefs
Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-13 17:00:38 +02:00

90 lines
2.0 KiB
C

#include <config.h>
#ifdef WITH_LXC
# include "testutilslxc.h"
# include "testutils.h"
# include "viralloc.h"
# include "domain_conf.h"
# define VIR_FROM_THIS VIR_FROM_LXC
virCaps *
testLXCCapsInit(void)
{
virCaps *caps;
virCapsGuest *guest;
if ((caps = virCapabilitiesNew(VIR_ARCH_X86_64,
false, false)) == NULL)
return NULL;
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
VIR_ARCH_I686,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
goto error;
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
VIR_ARCH_X86_64,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
goto error;
if (virTestGetDebug()) {
char *caps_str;
caps_str = virCapabilitiesFormatXML(caps);
if (!caps_str)
goto error;
VIR_TEST_DEBUG("LXC driver capabilities:\n%s", caps_str);
VIR_FREE(caps_str);
}
return caps;
error:
virObjectUnref(caps);
return NULL;
}
virLXCDriver *
testLXCDriverInit(void)
{
virLXCDriver *driver = g_new0(virLXCDriver, 1);
if (virMutexInit(&driver->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", "cannot initialize mutex");
g_free(driver);
return NULL;
}
driver->caps = testLXCCapsInit();
driver->xmlopt = lxcDomainXMLConfInit(driver, NULL);
return driver;
}
void
testLXCDriverFree(virLXCDriver *driver)
{
virObjectUnref(driver->xmlopt);
virObjectUnref(driver->caps);
virMutexDestroy(&driver->lock);
g_free(driver);
}
#endif