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:
parent
510fa47c2a
commit
9b516aa31b
@ -1081,7 +1081,6 @@ virArgvToString;
|
|||||||
virAsprintf;
|
virAsprintf;
|
||||||
virBuildPathInternal;
|
virBuildPathInternal;
|
||||||
virDirCreate;
|
virDirCreate;
|
||||||
virEmitXMLWarning;
|
|
||||||
virEnumFromString;
|
virEnumFromString;
|
||||||
virEnumToString;
|
virEnumToString;
|
||||||
virEventAddHandle;
|
virEventAddHandle;
|
||||||
|
@ -2472,42 +2472,3 @@ bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
|
||||||
}
|
|
||||||
|
@ -238,8 +238,4 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
|
|||||||
|
|
||||||
bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
|
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__ */
|
#endif /* __VIR_UTIL_H__ */
|
||||||
|
@ -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 {
|
struct virXMLRewritFileData {
|
||||||
const char *warnName;
|
const char *warnName;
|
||||||
const char *warnCommand;
|
const char *warnCommand;
|
||||||
@ -813,7 +854,7 @@ virXMLRewriteFile(int fd, void *opaque)
|
|||||||
struct virXMLRewritFileData *data = opaque;
|
struct virXMLRewritFileData *data = opaque;
|
||||||
|
|
||||||
if (data->warnName && data->warnCommand) {
|
if (data->warnName && data->warnCommand) {
|
||||||
if (virEmitXMLWarning(fd, data->warnName, data->warnCommand) < 0)
|
if (virXMLEmitWarning(fd, data->warnName, data->warnCommand) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user