1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

Move virEmitXMLWarning into xml.h

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
This commit is contained in:
Daniel P. Berrange 2012-01-27 17:35:09 +00:00
parent 510fa47c2a
commit 9b516aa31b
4 changed files with 42 additions and 45 deletions

View File

@ -1081,7 +1081,6 @@ virArgvToString;
virAsprintf;
virBuildPathInternal;
virDirCreate;
virEmitXMLWarning;
virEnumFromString;
virEnumToString;
virEventAddHandle;

View File

@ -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;
}

View File

@ -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__ */

View File

@ -801,6 +801,47 @@ error:
}
static 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;
}
struct virXMLRewritFileData {
const char *warnName;
const char *warnCommand;
@ -813,7 +854,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;
}