Actually, I'm turning this function into a macro as filename,
function name and line number needs to be passed. The new
function virAsprintfInternal is introduced with the extended set
of arguments.
---
cfg.mk | 2 +-
src/conf/domain_audit.c | 36 ++++++++++-----------
src/driver.c | 4 +--
src/libvirt_private.syms | 4 +--
src/util/virerror.c | 2 +-
src/util/virlog.c | 16 +++++-----
src/util/virstring.c | 36 ++++++++++++---------
src/util/virstring.h | 67 +++++++++++++++++++++++++++++++++++----
tests/domainsnapshotxml2xmltest.c | 2 ++
tests/fchosttest.c | 2 ++
tests/interfacexml2xmltest.c | 2 ++
tests/lxcxml2xmltest.c | 2 ++
tests/networkxml2xmltest.c | 2 ++
tests/nodedevxml2xmltest.c | 2 ++
tests/nodeinfotest.c | 2 ++
tests/nwfilterxml2xmltest.c | 2 ++
tests/qemuargv2xmltest.c | 2 ++
tests/qemuhelptest.c | 2 ++
tests/qemuxml2xmltest.c | 2 ++
tests/sexpr2xmltest.c | 2 ++
tests/storagepoolxml2xmltest.c | 2 ++
tests/storagevolxml2argvtest.c | 2 ++
tests/storagevolxml2xmltest.c | 2 ++
tests/sysinfotest.c | 2 ++
tests/virbuftest.c | 2 ++
tests/virhashtest.c | 2 ++
tests/virshtest.c | 2 ++
tests/xencapstest.c | 2 ++
tests/xml2sexprtest.c | 2 ++
tools/virt-host-validate-common.c | 2 ++
30 files changed, 158 insertions(+), 53 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index bbe84b3..1b118a9 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -899,7 +899,7 @@ exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
^python/(libvirt-(lxc-|qemu-)?override|typewrappers)\.c$$
exclude_file_name_regexp--sc_prohibit_asprintf = \
-
^(bootstrap.conf$$|src/util/virstring\.c$$|examples/domain-events/events-c/event-test\.c$$|tests/vircgroupmock\.c$$)
+
^(bootstrap.conf$$|src/util/virstring\.[ch]$$|examples/domain-events/events-c/event-test\.c$$|tests/vircgroupmock\.c$$)
exclude_file_name_regexp--sc_prohibit_strdup = \
^(docs/|examples/|python/|src/util/virstring\.c$$)
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 97e71f7..e53daf8 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -46,7 +46,7 @@ virDomainAuditGetRdev(const char *path)
(S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode))) {
int maj = major(sb.st_rdev);
int min = minor(sb.st_rdev);
- ignore_value(virAsprintf(&ret, "%02X:%02X", maj, min));
+ ignore_value(virAsprintfQuiet(&ret, "%02X:%02X", maj, min));
}
return ret;
}
@@ -382,29 +382,29 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr
hostdev,
case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
switch (hostdev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
- if (virAsprintf(&address, "%.4x:%.2x:%.2x.%.1x",
- hostdev->source.subsys.u.pci.addr.domain,
- hostdev->source.subsys.u.pci.addr.bus,
- hostdev->source.subsys.u.pci.addr.slot,
- hostdev->source.subsys.u.pci.addr.function) < 0) {
+ if (virAsprintfQuiet(&address, "%.4x:%.2x:%.2x.%.1x",
+ hostdev->source.subsys.u.pci.addr.domain,
+ hostdev->source.subsys.u.pci.addr.bus,
+ hostdev->source.subsys.u.pci.addr.slot,
+ hostdev->source.subsys.u.pci.addr.function) < 0)
{
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
- if (virAsprintf(&address, "%.3d.%.3d",
- hostdev->source.subsys.u.usb.bus,
- hostdev->source.subsys.u.usb.device) < 0) {
+ if (virAsprintfQuiet(&address, "%.3d.%.3d",
+ hostdev->source.subsys.u.usb.bus,
+ hostdev->source.subsys.u.usb.device) < 0) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
- if (virAsprintf(&address, "%s:%d:%d:%d",
- hostdev->source.subsys.u.scsi.adapter,
- hostdev->source.subsys.u.scsi.bus,
- hostdev->source.subsys.u.scsi.target,
- hostdev->source.subsys.u.scsi.unit) < 0) {
+ if (virAsprintfQuiet(&address, "%s:%d:%d:%d",
+ hostdev->source.subsys.u.scsi.adapter,
+ hostdev->source.subsys.u.scsi.bus,
+ hostdev->source.subsys.u.scsi.target,
+ hostdev->source.subsys.u.scsi.unit) < 0) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
@@ -654,8 +654,8 @@ virDomainAuditCgroupMajor(virDomainObjPtr vm, virCgroupPtr cgroup,
{
char *extra;
- if (virAsprintf(&extra, "major category=%s maj=%02X acl=%s",
- name, maj, perms) < 0) {
+ if (virAsprintfQuiet(&extra, "major category=%s maj=%02X acl=%s",
+ name, maj, perms) < 0) {
VIR_WARN("OOM while encoding audit message");
return;
}
@@ -693,8 +693,8 @@ virDomainAuditCgroupPath(virDomainObjPtr vm, virCgroupPtr cgroup,
rdev = virDomainAuditGetRdev(path);
if (!(detail = virAuditEncode("path", path)) ||
- virAsprintf(&extra, "path %s rdev=%s acl=%s",
- detail, VIR_AUDIT_STR(rdev), perms) < 0) {
+ virAsprintfQuiet(&extra, "path %s rdev=%s acl=%s",
+ detail, VIR_AUDIT_STR(rdev), perms) < 0) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
diff --git a/src/driver.c b/src/driver.c
index c35fcd2..a08dd34 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -65,7 +65,7 @@ virDriverLoadModule(const char *name)
VIR_DEBUG("Module load %s", name);
- if (virAsprintf(&modfile, "%s/libvirt_driver_%s.so", moddir, name) <
0)
+ if (virAsprintfQuiet(&modfile, "%s/libvirt_driver_%s.so", moddir, name)
< 0)
return NULL;
if (access(modfile, R_OK) < 0) {
@@ -79,7 +79,7 @@ virDriverLoadModule(const char *name)
goto cleanup;
}
- if (virAsprintf(®func, "%sRegister", name) < 0) {
+ if (virAsprintfQuiet(®func, "%sRegister", name) < 0) {
goto cleanup;
}
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6df5500..59583ec 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1871,7 +1871,7 @@ virStorageFileResize;
# util/virstring.h
virArgvToString;
-virAsprintf;
+virAsprintfInternal;
virSkipSpaces;
virSkipSpacesAndBackslash;
virSkipSpacesBackwards;
@@ -1892,7 +1892,7 @@ virStrToLong_ui;
virStrToLong_ul;
virStrToLong_ull;
virTrimSpaces;
-virVasprintf;
+virVasprintfInternal;
# util/virsysinfo.h
diff --git a/src/util/virerror.c b/src/util/virerror.c
index e238dce..ce3ab85 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -674,7 +674,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
} else {
va_list ap;
va_start(ap, fmt);
- ignore_value(virVasprintf(&str, fmt, ap));
+ ignore_value(virVasprintfQuiet(&str, fmt, ap));
va_end(ap);
}
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 20af4ce..1efa65d 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -711,13 +711,13 @@ virLogFormatString(char **msg,
* to just grep for it to find the right place.
*/
if ((funcname != NULL)) {
- ret = virAsprintf(msg, "%llu: %s : %s:%d : %s\n",
- virThreadSelfID(), virLogPriorityString(priority),
- funcname, linenr, str);
+ ret = virAsprintfQuiet(msg, "%llu: %s : %s:%d : %s\n",
+ virThreadSelfID(), virLogPriorityString(priority),
+ funcname, linenr, str);
} else {
- ret = virAsprintf(msg, "%llu: %s : %s\n",
- virThreadSelfID(), virLogPriorityString(priority),
- str);
+ ret = virAsprintfQuiet(msg, "%llu: %s : %s\n",
+ virThreadSelfID(), virLogPriorityString(priority),
+ str);
}
return ret;
}
@@ -833,7 +833,7 @@ virLogVMessage(virLogSource source,
/*
* serialize the error message, add level and timestamp
*/
- if (virVasprintf(&str, fmt, vargs) < 0) {
+ if (virVasprintfQuiet(&str, fmt, vargs) < 0) {
goto cleanup;
}
@@ -945,7 +945,7 @@ virLogOutputToFd(virLogSource source ATTRIBUTE_UNUSED,
if (fd < 0)
return;
- if (virAsprintf(&msg, "%s: %s", timestamp, str) < 0)
+ if (virAsprintfQuiet(&msg, "%s: %s", timestamp, str) < 0)
return;
ignore_value(safewrite(fd, msg, strlen(msg)));
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 1937f82..6fc015b 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -321,35 +321,41 @@ virStrToDouble(char const *s,
return 0;
}
-/**
- * virVasprintf
- *
- * like glibc's vasprintf but makes sure *strp == NULL on failure
- */
int
-virVasprintf(char **strp, const char *fmt, va_list list)
+virVasprintfInternal(bool report,
+ int domcode,
+ const char *filename,
+ const char *funcname,
+ size_t linenr,
+ char **strp,
+ const char *fmt,
+ va_list list)
{
int ret;
- if ((ret = vasprintf(strp, fmt, list)) == -1)
+ if ((ret = vasprintf(strp, fmt, list)) == -1) {
+ if (report)
+ virReportOOMErrorFull(domcode, filename, funcname, linenr);
*strp = NULL;
-
+ }
return ret;
}
-/**
- * virAsprintf
- *
- * like glibc's_asprintf but makes sure *strp == NULL on failure
- */
int
-virAsprintf(char **strp, const char *fmt, ...)
+virAsprintfInternal(bool report,
+ int domcode,
+ const char *filename,
+ const char *funcname,
+ size_t linenr,
+ char **strp,
+ const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
- ret = virVasprintf(strp, fmt, ap);
+ ret = virVasprintfInternal(report, domcode, filename,
+ funcname, linenr, strp, fmt, ap);
va_end(ap);
return ret;
}
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 34ffae1..8b66b23 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -76,12 +76,6 @@ void virTrimSpaces(char *str, char **endp) ATTRIBUTE_NONNULL(1);
void virSkipSpacesBackwards(const char *str, char **endp)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-int virAsprintf(char **strp, const char *fmt, ...)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 3)
- ATTRIBUTE_RETURN_CHECK;
-int virVasprintf(char **strp, const char *fmt, va_list list)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 0)
- ATTRIBUTE_RETURN_CHECK;
char *virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)
ATTRIBUTE_RETURN_CHECK;
char *virStrcpy(char *dest, const char *src, size_t destbytes)
@@ -96,6 +90,16 @@ int virStrdup(char **dest, const char *src, bool report, int domcode,
int virStrndup(char **dest, const char *src, ssize_t n, bool report, int domcode,
const char *filename, const char *funcname, size_t linenr)
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1);
+int virAsprintfInternal(bool report, int domcode, const char *filename,
+ const char *funcname, size_t linenr, char **strp,
+ const char *fmt, ...)
+ ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(7) ATTRIBUTE_FMT_PRINTF(7, 8)
+ ATTRIBUTE_RETURN_CHECK;
+int virVasprintfInternal(bool report, int domcode, const char *filename,
+ const char *funcname, size_t linenr, char **strp,
+ const char *fmt, va_list list)
+ ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(7) ATTRIBUTE_FMT_PRINTF(7, 0)
+ ATTRIBUTE_RETURN_CHECK;
/**
* VIR_STRDUP:
@@ -166,4 +170,55 @@ int virStrndup(char **dest, const char *src, ssize_t n, bool report,
int domcode
size_t virStringListLength(char **strings);
+/**
+ * virVasprintf
+ *
+ * Like glibc's vasprintf but makes sure *strp == NULL on failure, in which
+ * case the OOM error is reported too.
+ *
+ * Returns -1 on failure (with OOM error reported), 0 on success.
+ */
+# define virVasprintf(strp, fmt, list) \
+ virVasprintfInternal(true, VIR_FROM_THIS, __FILE__, __FUNCTION__, \
+ __LINE__, strp, fmt, list)
+
+/**
+ * virVasprintfQuiet
+ *
+ * Like glibc's vasprintf but makes sure *strp == NULL on failure.
+ *
+ * Returns -1 on failure, 0 on success.
+ */
+# define virVasprintfQuiet(strp, fmt, list) \
+ virVasprintfInternal(false, 0, NULL, NULL, 0, strp, fmt, list)
+
+/**
+ * virAsprintf:
+ * @strp: variable to hold result (char **)
+ * @fmt: printf format
+ *
+ * Like glibc's_asprintf but makes sure *strp == NULL on failure, in which case
+ * the OOM error is reported too.
+ *
+ * Returns -1 on failure (with OOM error reported), 0 on success.
+ */
+
+# define virAsprintf(strp, ...) \
+ virAsprintfInternal(true, VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__, \
+ strp, __VA_ARGS__)
+
+/**
+ * virAsprintfQuiet:
+ * @strp: variable to hold result (char **)
+ * @fmt: printf format
+ *
+ * Like glibc's_asprintf but makes sure *strp == NULL on failure.
+ *
+ * Returns -1 on failure, 0 on success.
+ */
+
+# define virAsprintfQuiet(strp, ...) \
+ virAsprintfInternal(false, 0, NULL, NULL, 0, \
+ strp, __VA_ARGS__)
+
#endif /* __VIR_STRING_H__ */
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 9eddf45..defa955 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -18,6 +18,8 @@
# include "testutilsqemu.h"
# include "virstring.h"
+# define VIR_FROM_THIS VIR_FROM_NONE
+
static virQEMUDriver driver;
static int
diff --git a/tests/fchosttest.c b/tests/fchosttest.c
index 76d1795..05ff20b 100644
--- a/tests/fchosttest.c
+++ b/tests/fchosttest.c
@@ -23,6 +23,8 @@
#include "virutil.h"
#include "testutils.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static char *fchost_prefix;
#define TEST_FC_HOST_PREFIX fchost_prefix
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c
index 9d86198..8092a59 100644
--- a/tests/interfacexml2xmltest.c
+++ b/tests/interfacexml2xmltest.c
@@ -14,6 +14,8 @@
#include "testutilsqemu.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static int
testCompareXMLToXMLFiles(const char *xml)
{
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 97f792c..ca05d29 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -17,6 +17,8 @@
# include "testutilslxc.h"
# include "virstring.h"
+# define VIR_FROM_THIS VIR_FROM_NONE
+
static virCapsPtr caps;
static virDomainXMLOptionPtr xmlopt;
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index 5eca143..0dfed16 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -14,6 +14,8 @@
#include "testutilsqemu.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
unsigned int flags)
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index ed49857..d4f7ee7 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -14,6 +14,8 @@
#include "testutilsqemu.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static int
testCompareXMLToXMLFiles(const char *xml)
{
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index bce56f3..def366c 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -11,6 +11,8 @@
#include "virfile.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
#if ! (defined __linux__ && (defined(__x86_64__) || \
defined(__amd64__) || \
defined(__i386__) || \
diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c
index 158bc9f..5476284 100644
--- a/tests/nwfilterxml2xmltest.c
+++ b/tests/nwfilterxml2xmltest.c
@@ -17,6 +17,8 @@
#include "testutilsqemu.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
bool expect_error)
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 652cd09..5cf7828 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -17,6 +17,8 @@
# include "testutilsqemu.h"
# include "virstring.h"
+# define VIR_FROM_THIS VIR_FROM_NONE
+
static virQEMUDriver driver;
static int blankProblemElements(char *data)
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 2a3b019..3826849 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -11,6 +11,8 @@
# include "viralloc.h"
# include "virstring.h"
+# define VIR_FROM_THIS VIR_FROM_NONE
+
struct testInfo {
const char *name;
virQEMUCapsPtr flags;
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index f8daff9..76570c5 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -18,6 +18,8 @@
# include "testutilsqemu.h"
# include "virstring.h"
+# define VIR_FROM_THIS VIR_FROM_NONE
+
static virQEMUDriver driver;
static int
diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
index f4d119e..eafefda 100644
--- a/tests/sexpr2xmltest.c
+++ b/tests/sexpr2xmltest.c
@@ -14,6 +14,8 @@
#include "testutilsxen.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static virCapsPtr caps;
static int
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index 0376e63..53a7f83 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -14,6 +14,8 @@
#include "testutilsqemu.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 6a6c8e3..89c233f 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -7,6 +7,8 @@
#include "testutilsqemu.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
const char create_tool[] = "qemu-img";
static int
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index e87b016..05d2306 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -14,6 +14,8 @@
#include "testutilsqemu.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static int
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
const char *outxml)
diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c
index dc0451b..ba57a7a 100644
--- a/tests/sysinfotest.c
+++ b/tests/sysinfotest.c
@@ -36,6 +36,8 @@
#include "virfile.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
#if defined (__linux__)
# if defined(__s390__) || defined(__s390x__) || \
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index 3938f0d..febe6e4 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -10,6 +10,8 @@
#include "viralloc.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
#define TEST_ERROR(...) \
do { \
if (virTestGetDebug()) \
diff --git a/tests/virhashtest.c b/tests/virhashtest.c
index f36fc76..9b7fcbb 100644
--- a/tests/virhashtest.c
+++ b/tests/virhashtest.c
@@ -13,6 +13,8 @@
#include "virlog.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
#define testError(...) \
do { \
char *str; \
diff --git a/tests/virshtest.c b/tests/virshtest.c
index fad6774..ca35bb0 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -9,6 +9,8 @@
#include "testutils.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
#ifdef WIN32
int
diff --git a/tests/xencapstest.c b/tests/xencapstest.c
index 8bdd6cd..9de3919 100644
--- a/tests/xencapstest.c
+++ b/tests/xencapstest.c
@@ -12,6 +12,8 @@
#include "virfile.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static int
testCompareFiles(virArch hostmachine, const char *xml_rel,
const char *cpuinfo_rel, const char *capabilities_rel)
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
index ec196c4..87ac2c3 100644
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -16,6 +16,8 @@
#include "testutilsxen.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static virCapsPtr caps;
static virDomainXMLOptionPtr xmlopt;
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index c17c257..496324e 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -33,6 +33,8 @@
#include "virt-host-validate-common.h"
#include "virstring.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
static bool quiet;
void virHostMsgSetQuiet(bool quietFlag)
--
1.8.1.5