From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> The virEmitXMLWarning function should always have been in the xml.[hc] files, and should use virXML as its name prefix * src/util/util.c, src/util/util.h: Remove virEmitXMLWarning * src/util/xml.c, src/util/xml.h: Add virXMLEmitWarning --- src/util/util.c | 39 --------------------------------------- src/util/util.h | 4 ---- src/util/xml.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/util/xml.h | 5 +++++ 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/util/util.c b/src/util/util.c index baa0f12..09062f6 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -2472,42 +2472,3 @@ bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED) return false; } #endif - -int virEmitXMLWarning(int fd, - const char *name, - const char *cmd) { - size_t len; - const char *prologue = "<!--\n\ -WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE \n\ -OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:\n\ - virsh "; - const char *epilogue = "\n\ -or other application using the libvirt API.\n\ --->\n\n"; - - if (fd < 0 || !name || !cmd) { - errno = EINVAL; - return -1; - } - - len = strlen(prologue); - if (safewrite(fd, prologue, len) != len) - return -1; - - len = strlen(cmd); - if (safewrite(fd, cmd, len) != len) - return -1; - - if (safewrite(fd, " ", 1) != 1) - return -1; - - len = strlen(name); - if (safewrite(fd, name, len) != len) - return -1; - - len = strlen(epilogue); - if (safewrite(fd, epilogue, len) != len) - return -1; - - return 0; -} diff --git a/src/util/util.h b/src/util/util.h index 96491e5..f62cb42 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -238,8 +238,4 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL; bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); -int virEmitXMLWarning(int fd, - const char *name, - const char *cmd) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); - #endif /* __VIR_UTIL_H__ */ diff --git a/src/util/xml.c b/src/util/xml.c index 2909e85..b7fd06a 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -813,7 +813,7 @@ virXMLRewriteFile(int fd, void *opaque) struct virXMLRewritFileData *data = opaque; if (data->warnName && data->warnCommand) { - if (virEmitXMLWarning(fd, data->warnName, data->warnCommand) < 0) + if (virXMLEmitWarning(fd, data->warnName, data->warnCommand) < 0) return -1; } @@ -853,3 +853,42 @@ virXMLChildElementCount(xmlNodePtr node) } return ret; } + +int virXMLEmitWarning(int fd, + const char *name, + const char *cmd) { + size_t len; + const char *prologue = "<!--\n\ +WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE \n\ +OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:\n\ + virsh "; + const char *epilogue = "\n\ +or other application using the libvirt API.\n\ +-->\n\n"; + + if (fd < 0 || !name || !cmd) { + errno = EINVAL; + return -1; + } + + len = strlen(prologue); + if (safewrite(fd, prologue, len) != len) + return -1; + + len = strlen(cmd); + if (safewrite(fd, cmd, len) != len) + return -1; + + if (safewrite(fd, " ", 1) != 1) + return -1; + + len = strlen(name); + if (safewrite(fd, name, len) != len) + return -1; + + len = strlen(epilogue); + if (safewrite(fd, epilogue, len) != len) + return -1; + + return 0; +} diff --git a/src/util/xml.h b/src/util/xml.h index a3750fa..94a5cf4 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -144,4 +144,9 @@ int virXMLSaveFile(const char *path, const char *warnCommand, const char *xml); +int virXMLEmitWarning(int fd, + const char *name, + const char *cmd) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + + #endif /* __VIR_XML_H__ */ -- 1.7.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list