/*
* datatypes.h: management of structs for public data types
*
- * Copyright (C) 2006-2008, 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
(VIR_IS_SNAPSHOT(obj) && VIR_IS_DOMAIN((obj)->domain))
+/* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This
+ * assumes you pass fewer than 15 arguments to VIR_DOMAIN_DEBUG, but
+ * can easily be expanded if needed.
+ *
+ * Note that gcc provides extensions of "define a(b...) b" or
+ * "define a(b,...) b,##__VA_ARGS__" as a means of eliding a comma
+ * when no var-args are present, but we don't want to require gcc.
+ */
+# define VIR_ARG15(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \
+ _11, _12, _13, _14, _15, ...) _15
+# define VIR_HAS_COMMA(...) VIR_ARG15(__VA_ARGS__, \
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
+
+/* Form the name VIR_DOMAIN_DEBUG_[01], then call that macro,
+ * according to how many arguments are present. Two-phase due to
+ * macro expansion rules. */
+# define VIR_DOMAIN_DEBUG_EXPAND(a, b, ...) \
+ VIR_DOMAIN_DEBUG_PASTE(a, b, __VA_ARGS__)
+# define VIR_DOMAIN_DEBUG_PASTE(a, b, ...) \
+ a##b(__VA_ARGS__)
+
+/* Internal use only, when VIR_DOMAIN_DEBUG has one argument. */
+# define VIR_DOMAIN_DEBUG_0(dom) \
+ VIR_DOMAIN_DEBUG_2(dom, "%s", "")
+
+/* Internal use only, when VIR_DOMAIN_DEBUG has three or more arguments. */
+# define VIR_DOMAIN_DEBUG_1(dom, fmt, ...) \
+ VIR_DOMAIN_DEBUG_2(dom, ", " fmt, __VA_ARGS__)
+
+/* Internal use only, with final format. */
+# define VIR_DOMAIN_DEBUG_2(dom, fmt, ...) \
+ do { \
+ char _uuidstr[VIR_UUID_STRING_BUFLEN]; \
+ const char *_domname = NULL; \
+ \
+ if (!VIR_IS_DOMAIN(dom)) { \
+ memset(_uuidstr, 0, sizeof(_uuidstr)); \
+ } else { \
+ virUUIDFormat((dom)->uuid, _uuidstr); \
+ _domname = (dom)->name; \
+ } \
+ \
+ VIR_DEBUG("dom=%p, (VM: name=%s, uuid=%s)" fmt, \
+ dom, NULLSTR(_domname), _uuidstr, __VA_ARGS__); \
+ } while (0)
+
+/**
+ * VIR_DOMAIN_DEBUG:
+ * @dom: domain
+ * @fmt: optional format for additional information
+ * @...: optional arguments corresponding to @fmt.
+ */
+# define VIR_DOMAIN_DEBUG(...) \
+ VIR_DOMAIN_DEBUG_EXPAND(VIR_DOMAIN_DEBUG_, \
+ VIR_HAS_COMMA(__VA_ARGS__), \
+ __VA_ARGS__)
+
+
typedef struct _virConnectCloseCallbackData virConnectCloseCallbackData;
typedef virConnectCloseCallbackData *virConnectCloseCallbackDataPtr;
* libvirt-lxc.c: Interfaces for the libvirt library to handle lxc-specific
* APIs.
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "virfile.h"
#include "virlog.h"
#include "virprocess.h"
+#include "viruuid.h"
#include "datatypes.h"
#ifdef WITH_SELINUX
# include <selinux/selinux.h>
{
virConnectPtr conn;
- VIR_DEBUG("domain=%p, fdlist=%p flags=%x",
- domain, fdlist, flags);
+ VIR_DOMAIN_DEBUG(domain, "fdlist=%p flags=%x", fdlist, flags);
virResetLastError();
* libvirt-qemu.c: Interfaces for the libvirt library to handle qemu-specific
* APIs.
*
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "virerror.h"
#include "virlog.h"
+#include "viruuid.h"
#include "datatypes.h"
#define VIR_FROM_THIS VIR_FROM_NONE
{
virConnectPtr conn;
- VIR_DEBUG("domain=%p, cmd=%s, result=%p, flags=%x",
- domain, cmd, result, flags);
+ VIR_DOMAIN_DEBUG(domain, "cmd=%s, result=%p, flags=%x",
+ cmd, result, flags);
virResetLastError();
virConnectPtr conn;
char *ret;
- VIR_DEBUG("domain=%p, cmd=%s, timeout=%d, flags=%x",
- domain, cmd, timeout, flags);
+ VIR_DOMAIN_DEBUG(domain, "cmd=%s, timeout=%d, flags=%x",
+ cmd, timeout, flags);
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
};
#endif /* WITH_GNUTLS_GCRYPT */
-/* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This
- * assumes you pass fewer than 15 arguments to VIR_DOMAIN_DEBUG, but
- * can easily be expanded if needed.
- *
- * Note that gcc provides extensions of "define a(b...) b" or
- * "define a(b,...) b,##__VA_ARGS__" as a means of eliding a comma
- * when no var-args are present, but we don't want to require gcc.
- */
-#define VIR_ARG15(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) _15
-#define VIR_HAS_COMMA(...) VIR_ARG15(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
-
-/* Form the name VIR_DOMAIN_DEBUG_[01], then call that macro,
- * according to how many arguments are present. Two-phase due to
- * macro expansion rules. */
-#define VIR_DOMAIN_DEBUG_EXPAND(a, b, ...) \
- VIR_DOMAIN_DEBUG_PASTE(a, b, __VA_ARGS__)
-#define VIR_DOMAIN_DEBUG_PASTE(a, b, ...) \
- a##b(__VA_ARGS__)
-
-/* Internal use only, when VIR_DOMAIN_DEBUG has one argument. */
-#define VIR_DOMAIN_DEBUG_0(dom) \
- VIR_DOMAIN_DEBUG_2(dom, "%s", "")
-
-/* Internal use only, when VIR_DOMAIN_DEBUG has three or more arguments. */
-#define VIR_DOMAIN_DEBUG_1(dom, fmt, ...) \
- VIR_DOMAIN_DEBUG_2(dom, ", " fmt, __VA_ARGS__)
-
-/* Internal use only, with final format. */
-#define VIR_DOMAIN_DEBUG_2(dom, fmt, ...) \
- do { \
- char _uuidstr[VIR_UUID_STRING_BUFLEN]; \
- const char *_domname = NULL; \
- \
- if (!VIR_IS_DOMAIN(dom)) { \
- memset(_uuidstr, 0, sizeof(_uuidstr)); \
- } else { \
- virUUIDFormat((dom)->uuid, _uuidstr); \
- _domname = (dom)->name; \
- } \
- \
- VIR_DEBUG("dom=%p, (VM: name=%s, uuid=%s)" fmt, \
- dom, NULLSTR(_domname), _uuidstr, __VA_ARGS__); \
- } while (0)
-
-/**
- * VIR_DOMAIN_DEBUG:
- * @dom: domain
- * @fmt: optional format for additional information
- * @...: optional arguments corresponding to @fmt.
- */
-#define VIR_DOMAIN_DEBUG(...) \
- VIR_DOMAIN_DEBUG_EXPAND(VIR_DOMAIN_DEBUG_, \
- VIR_HAS_COMMA(__VA_ARGS__), \
- __VA_ARGS__)
-
-/**
- * VIR_UUID_DEBUG:
- * @conn: connection
- * @uuid: possibly null UUID array
- */
-#define VIR_UUID_DEBUG(conn, uuid) \
- do { \
- if (uuid) { \
- char _uuidstr[VIR_UUID_STRING_BUFLEN]; \
- virUUIDFormat(uuid, _uuidstr); \
- VIR_DEBUG("conn=%p, uuid=%s", conn, _uuidstr); \
- } else { \
- VIR_DEBUG("conn=%p, uuid=(null)", conn); \
- } \
- } while (0)
-
static bool virGlobalError = false;
static virOnceControl virGlobalOnce = VIR_ONCE_CONTROL_INITIALIZER;
/*
* viruuid.h: helper APIs for dealing with UUIDs
*
- * Copyright (C) 2007, 2011, 2012 Red Hat, Inc.
+ * Copyright (C) 2007, 2011-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
# include "internal.h"
+
+/**
+ * VIR_UUID_DEBUG:
+ * @conn: connection
+ * @uuid: possibly null UUID array
+ */
+# define VIR_UUID_DEBUG(conn, uuid) \
+ do { \
+ if (uuid) { \
+ char _uuidstr[VIR_UUID_STRING_BUFLEN]; \
+ virUUIDFormat(uuid, _uuidstr); \
+ VIR_DEBUG("conn=%p, uuid=%s", conn, _uuidstr); \
+ } else { \
+ VIR_DEBUG("conn=%p, uuid=(null)", conn); \
+ } \
+ } while (0)
+
+
int virSetHostUUIDStr(const char *host_uuid);
int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1);