[Libvir] [patch 3/3] Do not inline xstrtol functions
by Mark McLoughlin
Our strtol() variants are all marked "static inline"
and with gcc 4.3 we get:
internal.h:272: error: inlining failed in call to 'xstrtol_i': call is unlikely and code size would grow
This patch renames them to virStrToLong() and exports
them from the library as private symbols.
Alternative is to not build with -Winline.
Signed-off-by: Mark McLoughlin <markmc(a)redhat.com>
Index: libvirt/src/internal.h
===================================================================
--- libvirt.orig/src/internal.h
+++ libvirt/src/internal.h
@@ -261,85 +261,6 @@ int __virDomainMigratePrepare (virConnec
int __virDomainMigratePerform (virDomainPtr domain, const char *cookie, int cookielen, const char *uri, unsigned long flags, const char *dname, unsigned long bandwidth);
virDomainPtr __virDomainMigrateFinish (virConnectPtr dconn, const char *dname, const char *cookie, int cookielen, const char *uri, unsigned long flags);
-/* Like strtol, but produce an "int" result, and check more carefully.
- Return 0 upon success; return -1 to indicate failure.
- When END_PTR is NULL, the byte after the final valid digit must be NUL.
- Otherwise, it's like strtol and lets the caller check any suffix for
- validity. This function is careful to return -1 when the string S
- represents a number that is not representable as an "int". */
-static inline int
-xstrtol_i(char const *s, char **end_ptr, int base, int *result)
-{
- long int val;
- char *p;
- int err;
-
- errno = 0;
- val = strtol(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (int) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
-
-/* Just like xstrtol_i, above, but produce an "unsigned int" value. */
-static inline int
-xstrtol_ui(char const *s, char **end_ptr, int base, unsigned int *result)
-{
- unsigned long int val;
- char *p;
- int err;
-
- errno = 0;
- val = strtoul(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (unsigned int) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
-
-static inline int
-xstrtol_ll(char const *s, char **end_ptr, int base, long long *result)
-{
- long long val;
- char *p;
- int err;
-
- errno = 0;
- val = strtoll(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (long long) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
-
-/* Just like xstrtol_i, above, but produce an "unsigned long long" value. */
-static inline int
-xstrtol_ull(char const *s, char **end_ptr, int base, unsigned long long *result)
-{
- unsigned long long val;
- char *p;
- int err;
-
- errno = 0;
- val = strtoull(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (unsigned long long) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
#ifdef __cplusplus
}
#endif /* __cplusplus */
Index: libvirt/src/util.c
===================================================================
--- libvirt.orig/src/util.c
+++ libvirt/src/util.c
@@ -549,6 +549,87 @@ int virFileBuildPath(const char *dir,
return 0;
}
+/* Like strtol, but produce an "int" result, and check more carefully.
+ Return 0 upon success; return -1 to indicate failure.
+ When END_PTR is NULL, the byte after the final valid digit must be NUL.
+ Otherwise, it's like strtol and lets the caller check any suffix for
+ validity. This function is careful to return -1 when the string S
+ represents a number that is not representable as an "int". */
+int
+__virStrToLong_i(char const *s, char **end_ptr, int base, int *result)
+{
+ long int val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtol(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (int) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
+/* Just like virStrToLong_i, above, but produce an "unsigned int" value. */
+int
+__virStrToLong_ui(char const *s, char **end_ptr, int base, unsigned int *result)
+{
+ unsigned long int val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtoul(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (unsigned int) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
+/* Just like virStrToLong_i, above, but produce an "long long" value. */
+int
+__virStrToLong_ll(char const *s, char **end_ptr, int base, long long *result)
+{
+ long long val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtoll(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (long long) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
+/* Just like virStrToLong_i, above, but produce an "unsigned long long" value. */
+int
+__virStrToLong_ull(char const *s, char **end_ptr, int base, unsigned long long *result)
+{
+ unsigned long long val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtoull(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (unsigned long long) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
/*
* Local variables:
* indent-tabs-mode: nil
Index: libvirt/src/util.h
===================================================================
--- libvirt.orig/src/util.h
+++ libvirt/src/util.h
@@ -56,4 +56,28 @@ int virFileBuildPath(const char *dir,
unsigned int buflen);
+int __virStrToLong_i(char const *s,
+ char **end_ptr,
+ int base,
+ int *result);
+#define virStrToLong_i(s,e,b,r) __virStrToLong_i((s),(e),(b),(r))
+
+int __virStrToLong_ui(char const *s,
+ char **end_ptr,
+ int base,
+ unsigned int *result);
+#define virStrToLong_ui(s,e,b,r) __virStrToLong_ui((s),(e),(b),(r))
+
+int __virStrToLong_ll(char const *s,
+ char **end_ptr,
+ int base,
+ long long *result);
+#define virStrToLong_ll(s,e,b,r) __virStrToLong_ll((s),(e),(b),(r))
+
+int __virStrToLong_ull(char const *s,
+ char **end_ptr,
+ int base,
+ unsigned long long *result);
+#define virStrToLong_ull(s,e,b,r) __virStrToLong_ull((s),(e),(b),(r))
+
#endif /* __VIR_UTIL_H__ */
Index: libvirt/src/nodeinfo.c
===================================================================
--- libvirt.orig/src/nodeinfo.c
+++ libvirt/src/nodeinfo.c
@@ -35,6 +35,7 @@
#include "nodeinfo.h"
#include "physmem.h"
+#include "util.h"
#ifdef __linux__
#define CPUINFO_PATH "/proc/cpuinfo"
@@ -79,7 +80,7 @@ int linuxNodeInfoCPUPopulate(virConnectP
"parsing cpuinfo cpu MHz");
return -1;
}
- if (xstrtol_ui(buf+1, &p, 10, &ui) == 0
+ if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
/* Accept trailing fractional part. */
&& (*p == '\0' || *p == '.' || isspace(*p)))
nodeinfo->mhz = ui;
@@ -95,7 +96,7 @@ int linuxNodeInfoCPUPopulate(virConnectP
"parsing cpuinfo cpu cores %c", *buf);
return -1;
}
- if (xstrtol_ui(buf+1, &p, 10, &id) == 0
+ if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
&& (*p == '\0' || isspace(*p))
&& id > nodeinfo->cores)
nodeinfo->cores = id;
Index: libvirt/src/stats_linux.c
===================================================================
--- libvirt.orig/src/stats_linux.c
+++ libvirt/src/stats_linux.c
@@ -24,7 +24,7 @@
#include <xs.h>
#endif
-#include "internal.h"
+#include "util.h"
#include "xen_unified.h"
#include "stats_linux.h"
@@ -263,7 +263,7 @@ xenLinuxDomainDeviceID(virConnectPtr con
if (path[4] != '\0') {
if (!isdigit(path[4]) || path[4] == '0' ||
- xstrtol_i(path+4, NULL, 10, &part) < 0 ||
+ virStrToLong_i(path+4, NULL, 10, &part) < 0 ||
part < 1 || part > 15) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, partition numbers for xvdN must be in range 1 - 15",
@@ -307,7 +307,7 @@ xenLinuxDomainDeviceID(virConnectPtr con
p = path + 3;
}
if (p && (!isdigit(*p) || *p == '0' ||
- xstrtol_i(p, NULL, 10, &part) < 0 ||
+ virStrToLong_i(p, NULL, 10, &part) < 0 ||
part < 1 || part > 15)) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, partition numbers for sdN must be in range 1 - 15",
@@ -333,7 +333,7 @@ xenLinuxDomainDeviceID(virConnectPtr con
if (path[3] != '\0') {
if (!isdigit(path[3]) || path[3] == '0' ||
- xstrtol_i(path+3, NULL, 10, &part) < 0 ||
+ virStrToLong_i(path+3, NULL, 10, &part) < 0 ||
part < 1 || part > 63) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, partition numbers for hdN must be in range 1 - 63",
Index: libvirt/src/virsh.c
===================================================================
--- libvirt.orig/src/virsh.c
+++ libvirt/src/virsh.c
@@ -46,7 +46,6 @@
#include <readline/history.h>
#endif
-#include "internal.h"
#include "console.h"
#include "util.h"
@@ -2914,7 +2913,7 @@ cmdVNCDisplay(vshControl * ctl, vshCmd *
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
goto cleanup;
}
- if (xstrtol_i((const char *)obj->stringval, NULL, 10, &port) || port < 0)
+ if (virStrToLong_i((const char *)obj->stringval, NULL, 10, &port) || port < 0)
goto cleanup;
xmlXPathFreeObject(obj);
@@ -3959,7 +3958,7 @@ vshCommandOptDomainBy(vshControl * ctl,
/* try it by ID */
if (flag & VSH_BYID) {
- if (xstrtol_i(n, NULL, 10, &id) == 0 && id >= 0) {
+ if (virStrToLong_i(n, NULL, 10, &id) == 0 && id >= 0) {
vshDebug(ctl, 5, "%s: <%s> seems like domain ID\n",
cmd->def->name, optname);
dom = virDomainLookupByID(ctl->conn, id);
Index: libvirt/src/xend_internal.c
===================================================================
--- libvirt.orig/src/xend_internal.c
+++ libvirt/src/xend_internal.c
@@ -35,7 +35,7 @@
#include "libvirt/libvirt.h"
#include "driver.h"
-#include "internal.h"
+#include "util.h"
#include "sexpr.h"
#include "xml.h"
#include "buf.h"
@@ -3049,7 +3049,7 @@ xenDaemonDomainGetVcpus(virDomainPtr dom
(t->u.s.car->u.s.cdr->kind == SEXPR_CONS)) {
for (t = t->u.s.car->u.s.cdr->u.s.car; t->kind == SEXPR_CONS; t = t->u.s.cdr)
if (t->u.s.car->kind == SEXPR_VALUE
- && xstrtol_i(t->u.s.car->u.value, NULL, 10, &cpu) == 0
+ && virStrToLong_i(t->u.s.car->u.value, NULL, 10, &cpu) == 0
&& cpu >= 0
&& (VIR_CPU_MAPLEN(cpu+1) <= maplen)) {
VIR_USE_CPU(cpumap, cpu);
Index: libvirt/qemud/qemud.c
===================================================================
--- libvirt.orig/qemud/qemud.c
+++ libvirt/qemud/qemud.c
@@ -52,7 +52,7 @@
#include "internal.h"
#include "getaddrinfo.h"
-#include "../src/internal.h"
+#include "../src/util.h"
#include "../src/remote_internal.h"
#include "../src/conf.h"
#include "event.h"
@@ -1889,7 +1889,7 @@ remoteReadConfigFile (struct qemud_serve
GET_CONF_STR (conf, filename, unix_sock_ro_perms);
if (unix_sock_ro_perms) {
- if (xstrtol_i (unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) {
+ if (virStrToLong_i (unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) {
qemudLog (QEMUD_ERR, "Failed to parse mode '%s'",
unix_sock_ro_perms);
goto free_and_fail;
@@ -1900,7 +1900,7 @@ remoteReadConfigFile (struct qemud_serve
GET_CONF_STR (conf, filename, unix_sock_rw_perms);
if (unix_sock_rw_perms) {
- if (xstrtol_i (unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) {
+ if (virStrToLong_i (unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) {
qemudLog (QEMUD_ERR, "Failed to parse mode '%s'",
unix_sock_rw_perms);
goto free_and_fail;
@@ -2045,7 +2045,7 @@ int main(int argc, char **argv) {
break;
case 't':
- if (xstrtol_i(optarg, &tmp, 10, &timeout) != 0
+ if (virStrToLong_i(optarg, &tmp, 10, &timeout) != 0
|| timeout <= 0
/* Ensure that we can multiply by 1000 without overflowing. */
|| timeout > INT_MAX / 1000)
Index: libvirt/src/libvirt_sym.version
===================================================================
--- libvirt.orig/src/libvirt_sym.version
+++ libvirt/src/libvirt_sym.version
@@ -133,5 +133,10 @@
__virFileReadAll;
+ __virStrToLong_i;
+ __virStrToLong_ui;
+ __virStrToLong_ll;
+ __virStrToLong_ull;
+
local: *;
};
Index: libvirt/src/nodeinfo.h
===================================================================
--- libvirt.orig/src/nodeinfo.h
+++ libvirt/src/nodeinfo.h
@@ -24,7 +24,7 @@
#ifndef __VIR_NODEINFO_H__
#define __VIR_NODEINFO_H__
-#include "internal.h"
+#include "libvirt/libvirt.h"
#ifdef __cplusplus
extern "C" {
--
16 years, 10 months
[Libvir] [patch 2/3] Fix subscript typo when calling hypervisor domainDestroy
by Mark McLoughlin
Fixes:
xen_unified.c: In function 'xenUnifiedDomainDestroy':
xen_unified.c:697: error: array subscript is above array bounds
Signed-off-by: Mark McLoughlin <markmc(a)redhat.com>
Index: libvirt/src/xen_unified.c
===================================================================
--- libvirt.orig/src/xen_unified.c
+++ libvirt/src/xen_unified.c
@@ -694,7 +694,7 @@ xenUnifiedDomainDestroy (virDomainPtr do
drivers[i]->domainDestroy (dom) == 0)
return 0;
- if (priv->opened[i] &&
+ if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy (dom) == 0)
return 0;
--
16 years, 10 months
[Libvir] [patch 1/3] Move static function prototype from header
by Mark McLoughlin
Fixes:
xm_internal.h:64: error: 'xenXMDomainAttachDevice' declared 'static' but never defined
xm_internal.h:65: error: 'xenXMDomainDetachDevice' declared 'static' but never defined
Signed-off-by: Mark McLoughlin <markmc(a)redhat.com>
Index: libvirt/src/xm_internal.c
===================================================================
--- libvirt.orig/src/xm_internal.c
+++ libvirt/src/xm_internal.c
@@ -77,6 +77,8 @@ static int xenXMAttachDisk(virDomainPtr
xmlNodePtr node, xenXMConfCachePtr entry);
static int xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
xmlNodePtr node, xenXMConfCachePtr entry);
+static int xenXMDomainAttachDevice(virDomainPtr domain, const char *xml);
+static int xenXMDomainDetachDevice(virDomainPtr domain, const char *xml);
#define XM_REFRESH_INTERVAL 10
Index: libvirt/src/xm_internal.h
===================================================================
--- libvirt.orig/src/xm_internal.h
+++ libvirt/src/xm_internal.h
@@ -61,9 +61,6 @@ int xenXMDomainUndefine(virDomainPtr dom
virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml);
char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf);
-static int xenXMDomainAttachDevice(virDomainPtr domain, const char *xml);
-static int xenXMDomainDetachDevice(virDomainPtr domain, const char *xml);
-
#ifdef __cplusplus
}
#endif
--
16 years, 10 months
[Libvir] [patch 0/3] Fix some gcc 4.3.0 warnings
by Mark McLoughlin
Hi,
With gcc-4.3.0 (from Fedora rawhide), some new warnings are
thrown up.
The following three patches fixes them. The first two are
straightforward, I think, but perhaps people might prefer to remove
-Winline from our warning flags rather than apply the last patch.
Cheers,
Mark.
--
16 years, 10 months
[Libvir] Re: libvirt on mingw
by Richard W.M. Jones
Brecht Sanders wrote:
> Hello again,
> Note that I am using gcc (mingw) 3.4.5, and not 4 as you recommend.
> The attached patch got rid of the warnings though.
> Maybe there is a compiler switch to fix it in a cleaner way though.
> Anyway, with the attached patch it does compile.
> Basically it casts to void* before converting to a different type.
> Regards
Yes thanks, that patch does indeed fix it. I'll apply it and release a
new version shortly.
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
16 years, 10 months
[Libvir] [PATCH] change a Disk/Nic of inactive domain
by S.Sakamoto
Hi
The libvirt on Xen-3.03 does not have the function
that add/change/delete a Disk/NIC of inactive domain.
So, I made a patch which enabled add/change/delete of Disk/NIC of inactive domain.
This patch will be able to change "disk" or "vif" parameter in configuration file
with "attach-disk","attach-interface", "attach-device",
"detach-disk", "detach-interface" and "detach-device" command, like "setmem" or "setvcpus".
Thanks,
Shigeki Sakamoto.
16 years, 10 months
[Libvir] [PATCH] add missing qemudReportError
by Guido Guenther
Hi,
without this qemudParseVMDef might return NULL when the boot dev
configuration is invalid but virGetLastError returns NULL either since
no error has been set, this leads to a segfault in qemudLoadConfig when
trying to print the error message.
Cheers,
-- Guido
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 6dc08e0..48ccc60 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -1193,6 +1193,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
} else if (!strcmp((char *)prop, "network")) {
def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_NET;
} else {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "unknown boot dev \'%s\'", (char*)prop);
goto error;
}
xmlFree(prop);
16 years, 10 months
[Libvir] don't use virBufferAdd with string literals
by Jim Meyering
I noticed a little glitch here:
src/xml.c: virBufferAdd(buf, "(usbdevice tablet)", 13);
src/xml.c: virBufferAdd(buf, "(usbdevice tablet)", 18);
So I mounted a campaign to remove all such uses of virBufferAdd
and make sure no more sneak back in.
First, I added this definition:
#define virBufferAddLit(buf_, literal_string_) \
virBufferAdd (buf_, "" literal_string_ "", sizeof literal_string_ - 1)
The empty double quotes ensure that you get a syntax error if you
pass anything other than a string literal in the 2nd parameter.
The idea being to change, e.g., the above examples to this:
virBufferAddLit(buf, "(usbdevice tablet)");
FYI, I converted almost all of the uses of virBufferAdd like this:
git grep -l -w virBufferAdd|xargs perl -pi -e \
's/virBufferAdd( *\([^,]+, *"[^"]*"), *-?\d+ *\)/virBufferAddLit$1)/'
About 20 more uses spanned two or more lines. I did them manually.
Here's the complete change:
Eliminate all uses of virBufferAdd with string literals.
* Makefile.maint (sc_prohibit_virBufferAdd_with_string_literal):
New rule.
* src/buf.h (virBufferAddLit): Define.
* src/conf.c (virConfSaveValue): Use virBufferAddLit, in place
of virBufferAdd everywhere possible.
(virConfSaveEntry): Likewise.
* src/qemu_conf.c (qemudGenerateXML, qemudGenerateNetworkXML): Likewise.
* src/qemu_driver.c (qemudGetFeatures, qemudGetCapabilities): Likewise.
* src/test.c (testDomainDumpXML, testNetworkDumpXML): Likewise.
* src/xen_internal.c (xenHypervisorMakeCapabilitiesXML): Likewise.
* src/xend_internal.c (xend_parse_sexp_desc_os): Likewise.
(xend_parse_sexp_desc, sexpr_to_xend_topology_xml): Likewise.
* src/xm_internal.c (xenXMDomainFormatXML, xenXMDomainPinVcpu): Likewise.
* src/xml.c (virSaveCpuSet, virParseXenCpuTopology): Likewise.
(virDomainParseXMLGraphicsDescImage): Likewise.
(virDomainParseXMLGraphicsDescVFB, virDomainParseXMLOSDescHVM): Likewise.
(virDomainParseXMLOSDescPV, virDomainParseXMLDiskDesc): Likewise.
(virDomainParseXMLIfDesc, virDomainParseXMLDesc): Likewise.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 5 +++
src/buf.h | 5 ++-
src/conf.c | 14 ++++----
src/qemu_conf.c | 50 +++++++++++++++---------------
src/qemu_driver.c | 34 ++++++++++----------
src/test.c | 14 ++++----
src/xen_internal.c | 42 +++++++++++++-------------
src/xend_internal.c | 70 +++++++++++++++++++++---------------------
src/xm_internal.c | 64 +++++++++++++++++++-------------------
src/xml.c | 84 +++++++++++++++++++++++++-------------------------
10 files changed, 195 insertions(+), 187 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 356ca73..923c422 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -304,6 +304,11 @@ sc_unmarked_diagnostics:
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
+sc_prohibit_virBufferAdd_with_string_literal:
+ @grep -nE '\<virBufferAdd *\([^,]+, *"[^"]' $$($(CVS_LIST_EXCEPT)) && \
+ { echo '$(ME): use virBufferAddLit, not virBufferAdd,' \
+ 'with a string literal' 1>&2; exit 1; } || :
+
# Avoid useless parentheses like those in this example:
# #if defined (SYMBOL) || defined (SYM2)
sc_useless_cpp_parens:
diff --git a/src/buf.h b/src/buf.h
index 8826617..275cd40 100644
--- a/src/buf.h
+++ b/src/buf.h
@@ -1,7 +1,7 @@
/*
* buf.h: buffers for libvirt
*
- * Copyright (C) 2005-2007 Red Hat, Inc.
+ * Copyright (C) 2005-2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -37,4 +37,7 @@ int virBufferStrcat(virBufferPtr buf, ...);
int virBufferEscapeString(virBufferPtr buf, const char *format, const char *str);
int virBufferURIEncodeString (virBufferPtr buf, const char *str);
+#define virBufferAddLit(buf_, literal_string_) \
+ virBufferAdd (buf_, "" literal_string_ "", sizeof literal_string_ - 1)
+
#endif /* __VIR_BUFFER_H__ */
diff --git a/src/conf.c b/src/conf.c
index d4e5227..67c9c6e 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -264,17 +264,17 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr val)
virConfValuePtr cur;
cur = val->list;
- virBufferAdd(buf, "[ ", 2);
+ virBufferAddLit(buf, "[ ");
if (cur != NULL) {
virConfSaveValue(buf, cur);
cur = cur->next;
while (cur != NULL) {
- virBufferAdd(buf, ", ", 2);
+ virBufferAddLit(buf, ", ");
virConfSaveValue(buf, cur);
cur = cur->next;
}
}
- virBufferAdd(buf, " ]", 2);
+ virBufferAddLit(buf, " ]");
break;
}
default:
@@ -297,17 +297,17 @@ virConfSaveEntry(virBufferPtr buf, virConfEntryPtr cur)
{
if (cur->name != NULL) {
virBufferAdd(buf, cur->name, -1);
- virBufferAdd(buf, " = ", 3);
+ virBufferAddLit(buf, " = ");
virConfSaveValue(buf, cur->value);
if (cur->comment != NULL) {
- virBufferAdd(buf, " #", 2);
+ virBufferAddLit(buf, " #");
virBufferAdd(buf, cur->comment, -1);
}
} else if (cur->comment != NULL) {
- virBufferAdd(buf, "#", 1);
+ virBufferAddLit(buf, "#");
virBufferAdd(buf, cur->comment, -1);
}
- virBufferAdd(buf, "\n", 1);
+ virBufferAddLit(buf, "\n");
return(0);
}
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 6dc08e0..d6e3b77 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -2714,7 +2714,7 @@ char *qemudGenerateXML(virConnectPtr conn,
if (virBufferVSprintf(buf, " <vcpu>%d</vcpu>\n", def->vcpus) < 0)
goto no_memory;
- if (virBufferAdd(buf, " <os>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <os>\n") < 0)
goto no_memory;
if (def->virtType == QEMUD_VIRT_QEMU) {
@@ -2756,33 +2756,33 @@ char *qemudGenerateXML(virConnectPtr conn,
goto no_memory;
}
- if (virBufferAdd(buf, " </os>\n", -1) < 0)
+ if (virBufferAddLit(buf, " </os>\n") < 0)
goto no_memory;
if (def->features & QEMUD_FEATURE_ACPI) {
- if (virBufferAdd(buf, " <features>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <features>\n") < 0)
goto no_memory;
- if (virBufferAdd(buf, " <acpi/>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <acpi/>\n") < 0)
goto no_memory;
- if (virBufferAdd(buf, " </features>\n", -1) < 0)
+ if (virBufferAddLit(buf, " </features>\n") < 0)
goto no_memory;
}
virBufferVSprintf(buf, " <clock offset='%s'/>\n", def->localtime ? "localtime" : "utc");
- if (virBufferAdd(buf, " <on_poweroff>destroy</on_poweroff>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <on_poweroff>destroy</on_poweroff>\n") < 0)
goto no_memory;
if (def->noReboot) {
- if (virBufferAdd(buf, " <on_reboot>destroy</on_reboot>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <on_reboot>destroy</on_reboot>\n") < 0)
goto no_memory;
} else {
- if (virBufferAdd(buf, " <on_reboot>restart</on_reboot>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <on_reboot>restart</on_reboot>\n") < 0)
goto no_memory;
}
- if (virBufferAdd(buf, " <on_crash>destroy</on_crash>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <on_crash>destroy</on_crash>\n") < 0)
goto no_memory;
- if (virBufferAdd(buf, " <devices>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <devices>\n") < 0)
goto no_memory;
if (virBufferVSprintf(buf, " <emulator>%s</emulator>\n", def->os.binary) < 0)
@@ -2814,7 +2814,7 @@ char *qemudGenerateXML(virConnectPtr conn,
goto no_memory;
if (disk->readonly)
- if (virBufferAdd(buf, " <readonly/>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <readonly/>\n") < 0)
goto no_memory;
if (virBufferVSprintf(buf, " </disk>\n") < 0)
@@ -2904,12 +2904,12 @@ char *qemudGenerateXML(virConnectPtr conn,
}
/* If graphics is enable, add implicit mouse */
if (def->graphicsType != QEMUD_GRAPHICS_NONE)
- if (virBufferAdd(buf, " <input type='mouse' bus='ps2'/>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <input type='mouse' bus='ps2'/>\n") < 0)
goto no_memory;
switch (def->graphicsType) {
case QEMUD_GRAPHICS_VNC:
- if (virBufferAdd(buf, " <graphics type='vnc'", -1) < 0)
+ if (virBufferAddLit(buf, " <graphics type='vnc'") < 0)
goto no_memory;
if (def->vncPort &&
@@ -2927,12 +2927,12 @@ char *qemudGenerateXML(virConnectPtr conn,
def->keymap) < 0)
goto no_memory;
- if (virBufferAdd(buf, "/>\n", -1) < 0)
+ if (virBufferAddLit(buf, "/>\n") < 0)
goto no_memory;
break;
case QEMUD_GRAPHICS_SDL:
- if (virBufferAdd(buf, " <graphics type='sdl'/>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <graphics type='sdl'/>\n") < 0)
goto no_memory;
break;
@@ -2944,11 +2944,11 @@ char *qemudGenerateXML(virConnectPtr conn,
if (def->graphicsType == QEMUD_GRAPHICS_VNC) {
}
- if (virBufferAdd(buf, " </devices>\n", -1) < 0)
+ if (virBufferAddLit(buf, " </devices>\n") < 0)
goto no_memory;
- if (virBufferAdd(buf, "</domain>\n", -1) < 0)
+ if (virBufferAddLit(buf, "</domain>\n") < 0)
goto no_memory;
return virBufferContentAndFree (buf);
@@ -2989,11 +2989,11 @@ char *qemudGenerateNetworkXML(virConnectPtr conn,
virBufferVSprintf(buf, " <forward dev='%s'/>\n",
def->forwardDev);
} else {
- virBufferAdd(buf, " <forward/>\n", -1);
+ virBufferAddLit(buf, " <forward/>\n");
}
}
- virBufferAdd(buf, " <bridge", -1);
+ virBufferAddLit(buf, " <bridge");
if (qemudIsActiveNetwork(network)) {
if (virBufferVSprintf(buf, " name='%s'", network->bridge) < 0)
goto no_memory;
@@ -3007,7 +3007,7 @@ char *qemudGenerateNetworkXML(virConnectPtr conn,
goto no_memory;
if (def->ipAddress[0] || def->netmask[0]) {
- if (virBufferAdd(buf, " <ip", -1) < 0)
+ if (virBufferAddLit(buf, " <ip") < 0)
goto no_memory;
if (def->ipAddress[0] &&
@@ -3018,12 +3018,12 @@ char *qemudGenerateNetworkXML(virConnectPtr conn,
virBufferVSprintf(buf, " netmask='%s'", def->netmask) < 0)
goto no_memory;
- if (virBufferAdd(buf, ">\n", -1) < 0)
+ if (virBufferAddLit(buf, ">\n") < 0)
goto no_memory;
if (def->ranges) {
struct qemud_dhcp_range_def *range = def->ranges;
- if (virBufferAdd(buf, " <dhcp>\n", -1) < 0)
+ if (virBufferAddLit(buf, " <dhcp>\n") < 0)
goto no_memory;
while (range) {
if (virBufferVSprintf(buf, " <range start='%s' end='%s' />\n",
@@ -3031,15 +3031,15 @@ char *qemudGenerateNetworkXML(virConnectPtr conn,
goto no_memory;
range = range->next;
}
- if (virBufferAdd(buf, " </dhcp>\n", -1) < 0)
+ if (virBufferAddLit(buf, " </dhcp>\n") < 0)
goto no_memory;
}
- if (virBufferAdd(buf, " </ip>\n", -1) < 0)
+ if (virBufferAddLit(buf, " </ip>\n") < 0)
goto no_memory;
}
- if (virBufferAdd(buf, "</network>\n", -1) < 0)
+ if (virBufferAddLit(buf, "</network>\n") < 0)
goto no_memory;
return virBufferContentAndFree (buf);
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index f80a121..3151574 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1,7 +1,7 @@
/*
* driver.c: core driver methods for managing qemu guests
*
- * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -1459,19 +1459,19 @@ static int qemudGetFeatures(virBufferPtr xml,
if (flags == NULL)
return 0;
- r = virBufferAdd(xml, "\
- <features>\n", -1);
+ r = virBufferAddLit(xml, "\
+ <features>\n");
if (r == -1) return r;
for (i = 0; flags[i].name; ++i) {
if (STREQ(flags[i].name, "pae")) {
int pae = flags[i].default_on || flags[i].toggle;
int nonpae = flags[i].toggle;
if (pae) {
- r = virBufferAdd(xml, " <pae/>\n", -1);
+ r = virBufferAddLit(xml, " <pae/>\n");
if (r == -1) return r;
}
if (nonpae) {
- r = virBufferAdd(xml, " <nonpae/>\n", -1);
+ r = virBufferAddLit(xml, " <nonpae/>\n");
if (r == -1) return r;
}
} else {
@@ -1482,7 +1482,7 @@ static int qemudGetFeatures(virBufferPtr xml,
if (r == -1) return r;
}
}
- r = virBufferAdd(xml, " </features>\n", -1);
+ r = virBufferAddLit(xml, " </features>\n");
return r;
}
@@ -1550,26 +1550,26 @@ static char *qemudGetCapabilities(virConnectPtr conn ATTRIBUTE_UNUSED) {
}
if (have_kqemu) {
- r = virBufferAdd (xml,
+ r = virBufferAddLit (xml,
"\
- <domain type=\"kqemu\"/>\n", -1);
+ <domain type=\"kqemu\"/>\n");
if (r == -1) goto vir_buffer_failed;
}
if (have_kvm) {
- r = virBufferAdd (xml,
+ r = virBufferAddLit (xml,
"\
<domain type=\"kvm\">\n\
<emulator>/usr/bin/qemu-kvm</emulator>\n\
- </domain>\n", -1);
+ </domain>\n");
if (r == -1) goto vir_buffer_failed;
}
- r = virBufferAdd (xml, " </arch>\n", -1);
+ r = virBufferAddLit (xml, " </arch>\n");
if (r == -1) goto vir_buffer_failed;
r = qemudGetFeatures(xml, qemudArchs[i].fflags);
if (r == -1) goto vir_buffer_failed;
- r = virBufferAdd (xml, " </guest>\n", -1);
+ r = virBufferAddLit (xml, " </guest>\n");
if (r == -1) goto vir_buffer_failed;
/* The "other" PC architecture needs emulation. */
@@ -1594,7 +1594,7 @@ static char *qemudGetCapabilities(virConnectPtr conn ATTRIBUTE_UNUSED) {
qemudArchs[i].machines[j]);
if (r == -1) goto vir_buffer_failed;
}
- r = virBufferAdd (xml, " </arch>\n </guest>\n", -1);
+ r = virBufferAddLit (xml, " </arch>\n </guest>\n");
if (r == -1) goto vir_buffer_failed;
}
@@ -1620,20 +1620,20 @@ static char *qemudGetCapabilities(virConnectPtr conn ATTRIBUTE_UNUSED) {
qemudArchs[i].machines[j]);
if (r == -1) goto vir_buffer_failed;
}
- r = virBufferAdd (xml, " </arch>\n", -1);
+ r = virBufferAddLit (xml, " </arch>\n");
if (r == -1) goto vir_buffer_failed;
r = qemudGetFeatures(xml, qemudArchs[i].fflags);
if (r == -1) goto vir_buffer_failed;
- r = virBufferAdd (xml, " </guest>\n", -1);
+ r = virBufferAddLit (xml, " </guest>\n");
if (r == -1) goto vir_buffer_failed;
}
/* Finish off. */
- r = virBufferAdd (xml,
+ r = virBufferAddLit (xml,
"\
-</capabilities>\n", -1);
+</capabilities>\n");
if (r == -1) goto vir_buffer_failed;
return virBufferContentAndFree(xml);
diff --git a/src/test.c b/src/test.c
index ab83f65..003d6b7 100644
--- a/src/test.c
+++ b/src/test.c
@@ -1492,7 +1492,7 @@ static char *testDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
virBufferVSprintf(buf, " <on_poweroff>%s</on_poweroff>\n", testRestartFlagToString(privdom->onPoweroff));
virBufferVSprintf(buf, " <on_crash>%s</on_crash>\n", testRestartFlagToString(privdom->onCrash));
- virBufferAdd(buf, "</domain>\n", -1);
+ virBufferAddLit(buf, "</domain>\n");
xml = buf->content;
free(buf);
@@ -1863,7 +1863,7 @@ static char *testNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE
return (NULL);
}
- virBufferAdd(buf, "<network>\n", -1);
+ virBufferAddLit(buf, "<network>\n");
virBufferVSprintf(buf, " <name>%s</name>\n", network->name);
uuid = network->uuid;
virUUIDFormat(uuid, uuidstr);
@@ -1873,18 +1873,18 @@ static char *testNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE
if (privnet->forwardDev[0])
virBufferVSprintf(buf, " <forward dev='%s'/>\n", privnet->forwardDev);
else
- virBufferAdd(buf, " <forward/>\n", -1);
+ virBufferAddLit(buf, " <forward/>\n");
}
virBufferVSprintf(buf, " <ip address='%s' netmask='%s'>\n",
privnet->ipAddress, privnet->ipNetmask);
- virBufferAdd(buf, " <dhcp>\n", -1);
+ virBufferAddLit(buf, " <dhcp>\n");
virBufferVSprintf(buf, " <range start='%s' end='%s'/>\n",
privnet->dhcpStart, privnet->dhcpEnd);
- virBufferAdd(buf, " </dhcp>\n", -1);
- virBufferAdd(buf, " </ip>\n", -1);
+ virBufferAddLit(buf, " </dhcp>\n");
+ virBufferAddLit(buf, " </ip>\n");
- virBufferAdd(buf, "</network>\n", -1);
+ virBufferAddLit(buf, "</network>\n");
xml = buf->content;
free(buf);
diff --git a/src/xen_internal.c b/src/xen_internal.c
index 1292382..1ddff85 100644
--- a/src/xen_internal.c
+++ b/src/xen_internal.c
@@ -1,7 +1,7 @@
/*
* xen_internal.c: direct access to Xen hypervisor level
*
- * Copyright (C) 2005, 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -2330,11 +2330,11 @@ xenHypervisorMakeCapabilitiesXML(virConnectPtr conn,
if (r == -1) goto vir_buffer_failed;
}
if (host_pae) {
- r = virBufferAdd (xml, "\
- <pae/>\n", -1);
+ r = virBufferAddLit (xml, "\
+ <pae/>\n");
if (r == -1) goto vir_buffer_failed;
}
- r = virBufferAdd (xml,
+ r = virBufferAddLit (xml,
"\
</features>\n\
</cpu>\n\
@@ -2344,7 +2344,7 @@ xenHypervisorMakeCapabilitiesXML(virConnectPtr conn,
<uri_transport>xenmigr</uri_transport>\n\
</uri_transports>\n\
</migration_features>\n\
- </host>\n", -1);
+ </host>\n");
if (r == -1) goto vir_buffer_failed;
if (sys_interface_version >= 4) {
@@ -2376,48 +2376,48 @@ xenHypervisorMakeCapabilitiesXML(virConnectPtr conn,
guest_archs[i].bits == 64 ? "64" : "");
if (r == -1) goto vir_buffer_failed;
}
- r = virBufferAdd (xml,
+ r = virBufferAddLit (xml,
"\
</arch>\n\
- <features>\n", -1);
+ <features>\n");
if (r == -1) goto vir_buffer_failed;
if (guest_archs[i].pae) {
- r = virBufferAdd (xml,
+ r = virBufferAddLit (xml,
"\
- <pae/>\n", -1);
+ <pae/>\n");
if (r == -1) goto vir_buffer_failed;
}
if (guest_archs[i].nonpae) {
- r = virBufferAdd (xml, " <nonpae/>\n", -1);
+ r = virBufferAddLit (xml, " <nonpae/>\n");
if (r == -1) goto vir_buffer_failed;
}
if (guest_archs[i].ia64_be) {
- r = virBufferAdd (xml, " <ia64_be/>\n", -1);
+ r = virBufferAddLit (xml, " <ia64_be/>\n");
if (r == -1) goto vir_buffer_failed;
}
if (guest_archs[i].hvm) {
- r = virBufferAdd (xml, " <acpi default='on' toggle='yes'/>\n",
- -1);
+ r = virBufferAddLit (xml,
+ " <acpi default='on' toggle='yes'/>\n");
if (r == -1) goto vir_buffer_failed;
// In Xen 3.1.0, APIC is always on and can't be toggled
if (hv_major >= 3 && hv_minor > 0) {
- r = virBufferAdd (xml,
- " <apic default='off' toggle='no'/>\n", -1);
+ r = virBufferAddLit (xml,
+ " <apic default='off' toggle='no'/>\n");
} else {
- r = virBufferAdd (xml,
- " <apic default='on' toggle='yes'/>\n", -1);
+ r = virBufferAddLit (xml,
+ " <apic default='on' toggle='yes'/>\n");
}
if (r == -1) goto vir_buffer_failed;
}
- r = virBufferAdd (xml, "\
+ r = virBufferAddLit (xml, "\
</features>\n\
- </guest>\n", -1);
+ </guest>\n");
if (r == -1) goto vir_buffer_failed;
}
- r = virBufferAdd (xml,
+ r = virBufferAddLit (xml,
"\
-</capabilities>\n", -1);
+</capabilities>\n");
if (r == -1) goto vir_buffer_failed;
xml_str = strdup (xml->content);
if (!xml_str) goto vir_buffer_failed;
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 78691c9..9a79591 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -1286,7 +1286,7 @@ xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf
return(-1);
}
- virBufferAdd(buf, " <os>\n", 7);
+ virBufferAddLit(buf, " <os>\n");
if (hvm) {
virBufferVSprintf(buf, " <type>hvm</type>\n");
tmp = sexpr_node(node, "domain/image/hvm/kernel");
@@ -1304,7 +1304,7 @@ xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf
while (*tmp) {
if (*tmp == 'a')
/* XXX no way to deal with boot from 2nd floppy */
- virBufferAdd(buf, " <boot dev='fd'/>\n", 21 );
+ virBufferAddLit(buf, " <boot dev='fd'/>\n");
else if (*tmp == 'c')
/*
* Don't know what to put here. Say the vm has been given 3
@@ -1312,11 +1312,11 @@ xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf
* We're going to assume that first disk is the boot disk since
* this is most common practice
*/
- virBufferAdd(buf, " <boot dev='hd'/>\n", 21 );
+ virBufferAddLit(buf, " <boot dev='hd'/>\n");
else if (*tmp == 'd')
- virBufferAdd(buf, " <boot dev='cdrom'/>\n", 24 );
+ virBufferAddLit(buf, " <boot dev='cdrom'/>\n");
else if (*tmp == 'n')
- virBufferAdd(buf, " <boot dev='network'/>\n", 26 );
+ virBufferAddLit(buf, " <boot dev='network'/>\n");
tmp++;
}
}
@@ -1341,7 +1341,7 @@ xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf
virBufferEscapeString(buf, " <cmdline>%s</cmdline>\n", tmp);
}
- virBufferAdd(buf, " </os>\n", 8);
+ virBufferAddLit(buf, " </os>\n");
return(0);
}
@@ -1472,20 +1472,20 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
if (hvm) {
int clockLocal;
- virBufferAdd(&buf, " <features>\n", 13);
+ virBufferAddLit(&buf, " <features>\n");
if (sexpr_int(root, "domain/image/hvm/acpi"))
- virBufferAdd(&buf, " <acpi/>\n", 12);
+ virBufferAddLit(&buf, " <acpi/>\n");
if (sexpr_int(root, "domain/image/hvm/apic"))
- virBufferAdd(&buf, " <apic/>\n", 12);
+ virBufferAddLit(&buf, " <apic/>\n");
if (sexpr_int(root, "domain/image/hvm/pae"))
- virBufferAdd(&buf, " <pae/>\n", 11);
- virBufferAdd(&buf, " </features>\n", 14);
+ virBufferAddLit(&buf, " <pae/>\n");
+ virBufferAddLit(&buf, " </features>\n");
clockLocal = sexpr_int(root, "domain/image/hvm/localtime");
virBufferVSprintf(&buf, " <clock offset='%s'/>\n", clockLocal ? "localtime" : "utc");
}
- virBufferAdd(&buf, " <devices>\n", 12);
+ virBufferAddLit(&buf, " <devices>\n");
/* in case of HVM we have devices emulation */
tmp = sexpr_node(root, "domain/image/hvm/device_model");
@@ -1636,7 +1636,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
virBufferVSprintf(&buf, " <readonly/>\n");
else if ((mode != NULL) && (!strcmp(mode, "w!")))
virBufferVSprintf(&buf, " <shareable/>\n");
- virBufferAdd(&buf, " </disk>\n", 12);
+ virBufferAddLit(&buf, " </disk>\n");
bad_parse:
free(drvName);
@@ -1673,7 +1673,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
virBufferVSprintf(&buf, " <script path='%s'/>\n",
tmp2);
- virBufferAdd(&buf, " </interface>\n", 17);
+ virBufferAddLit(&buf, " </interface>\n");
vif_index++;
} else if (sexpr_lookup(node, "device/vfb")) {
/* New style graphics config for PV guests in >= 3.0.4,
@@ -1682,7 +1682,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
if (tmp && !strcmp(tmp, "sdl")) {
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen");
- virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27);
+ virBufferAddLit(&buf, " <graphics type='sdl'/>\n");
} else if (tmp && !strcmp(tmp, "vnc")) {
int port = xenStoreDomainGetVNCPort(conn, domid);
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
@@ -1699,7 +1699,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
}
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
- virBufferAdd(&buf, "/>\n", 3);
+ virBufferAddLit(&buf, "/>\n");
}
}
}
@@ -1707,29 +1707,29 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
if (hvm) {
tmp = sexpr_node(root, "domain/image/hvm/fda");
if ((tmp != NULL) && (tmp[0] != 0)) {
- virBufferAdd(&buf, " <disk type='file' device='floppy'>\n", 39);
+ virBufferAddLit(&buf, " <disk type='file' device='floppy'>\n");
virBufferVSprintf(&buf, " <source file='%s'/>\n", tmp);
- virBufferAdd(&buf, " <target dev='fda'/>\n", 26);
- virBufferAdd(&buf, " </disk>\n", 12);
+ virBufferAddLit(&buf, " <target dev='fda'/>\n");
+ virBufferAddLit(&buf, " </disk>\n");
}
tmp = sexpr_node(root, "domain/image/hvm/fdb");
if ((tmp != NULL) && (tmp[0] != 0)) {
- virBufferAdd(&buf, " <disk type='file' device='floppy'>\n", 39);
+ virBufferAddLit(&buf, " <disk type='file' device='floppy'>\n");
virBufferVSprintf(&buf, " <source file='%s'/>\n", tmp);
- virBufferAdd(&buf, " <target dev='fdb'/>\n", 26);
- virBufferAdd(&buf, " </disk>\n", 12);
+ virBufferAddLit(&buf, " <target dev='fdb'/>\n");
+ virBufferAddLit(&buf, " </disk>\n");
}
/* Old style cdrom config from Xen <= 3.0.2 */
if (xendConfigVersion == 1) {
tmp = sexpr_node(root, "domain/image/hvm/cdrom");
if ((tmp != NULL) && (tmp[0] != 0)) {
- virBufferAdd(&buf, " <disk type='file' device='cdrom'>\n", 38);
- virBufferAdd(&buf, " <driver name='file'/>\n", 28);
+ virBufferAddLit(&buf, " <disk type='file' device='cdrom'>\n");
+ virBufferAddLit(&buf, " <driver name='file'/>\n");
virBufferVSprintf(&buf, " <source file='%s'/>\n", tmp);
- virBufferAdd(&buf, " <target dev='hdc'/>\n", 26);
- virBufferAdd(&buf, " <readonly/>\n", 18);
- virBufferAdd(&buf, " </disk>\n", 12);
+ virBufferAddLit(&buf, " <target dev='hdc'/>\n");
+ virBufferAddLit(&buf, " <readonly/>\n");
+ virBufferAddLit(&buf, " </disk>\n");
}
}
}
@@ -1742,9 +1742,9 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
tmp = sexpr_node(node, "usbdevice");
if (tmp && *tmp) {
if (!strcmp(tmp, "tablet"))
- virBufferAdd(&buf, " <input type='tablet' bus='usb'/>\n", 37);
+ virBufferAddLit(&buf, " <input type='tablet' bus='usb'/>\n");
else if (!strcmp(tmp, "mouse"))
- virBufferAdd(&buf, " <input type='mouse' bus='usb'/>\n", 36);
+ virBufferAddLit(&buf, " <input type='mouse' bus='usb'/>\n");
}
}
}
@@ -1779,7 +1779,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
}
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
- virBufferAdd(&buf, "/>\n", 3);
+ virBufferAddLit(&buf, "/>\n");
}
}
@@ -1788,7 +1788,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
if (tmp != NULL) {
if (tmp[0] == '1') {
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2" : "xen");
- virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27 );
+ virBufferAddLit(&buf, " <graphics type='sdl'/>\n");
}
}
}
@@ -1799,8 +1799,8 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
free(tty);
}
- virBufferAdd(&buf, " </devices>\n", 13);
- virBufferAdd(&buf, "</domain>\n", 10);
+ virBufferAddLit(&buf, " </devices>\n");
+ virBufferAddLit(&buf, "</domain>\n");
buf.content[buf.use] = 0;
return (buf.content);
@@ -1969,9 +1969,9 @@ sexpr_to_xend_topology_xml(virConnectPtr conn, const struct sexpr *root,
r = virParseXenCpuTopology(conn, xml, nodeToCpu, numCpus);
if (r < 0) goto error;
- r = virBufferAdd (xml, "\
+ r = virBufferAddLit (xml, "\
</cells>\n\
- </topology>\n", -1);
+ </topology>\n");
if (r < 0) goto vir_buffer_failed;
return (0);
diff --git a/src/xm_internal.c b/src/xm_internal.c
index f452819..2dc126a 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -592,7 +592,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
buf = virBufferNew(4096);
- virBufferAdd(buf, "<domain type='xen'>\n", -1);
+ virBufferAddLit(buf, "<domain type='xen'>\n");
virBufferVSprintf(buf, " <name>%s</name>\n", name);
virUUIDFormat(uuid, uuidstr);
virBufferVSprintf(buf, " <uuid>%s</uuid>\n", uuidstr);
@@ -603,8 +603,8 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (hvm) {
const char *boot;
- virBufferAdd(buf, " <os>\n", -1);
- virBufferAdd(buf, " <type>hvm</type>\n", -1);
+ virBufferAddLit(buf, " <os>\n");
+ virBufferAddLit(buf, " <type>hvm</type>\n");
if (xenXMConfigGetString(conf, "kernel", &str) == 0)
virBufferVSprintf(buf, " <loader>%s</loader>\n", str);
@@ -629,7 +629,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
boot++;
}
- virBufferAdd(buf, " </os>\n", -1);
+ virBufferAddLit(buf, " </os>\n");
} else {
if (xenXMConfigGetString(conf, "bootloader", &str) == 0)
@@ -637,14 +637,14 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (xenXMConfigGetString(conf, "bootargs", &str) == 0)
virBufferEscapeString(buf, " <bootloader_args>%s</bootloader_args>\n", str);
if (xenXMConfigGetString(conf, "kernel", &str) == 0) {
- virBufferAdd(buf, " <os>\n", -1);
- virBufferAdd(buf, " <type>linux</type>\n", -1);
+ virBufferAddLit(buf, " <os>\n");
+ virBufferAddLit(buf, " <type>linux</type>\n");
virBufferVSprintf(buf, " <kernel>%s</kernel>\n", str);
if (xenXMConfigGetString(conf, "ramdisk", &str) == 0)
virBufferVSprintf(buf, " <initrd>%s</initrd>\n", str);
if (xenXMConfigGetString(conf, "extra", &str) == 0)
virBufferEscapeString(buf, " <cmdline>%s</cmdline>\n", str);
- virBufferAdd(buf, " </os>\n", -1);
+ virBufferAddLit(buf, " </os>\n");
}
}
@@ -687,24 +687,24 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (hvm) {
- virBufferAdd(buf, " <features>\n", -1);
+ virBufferAddLit(buf, " <features>\n");
if (xenXMConfigGetInt(conf, "pae", &val) == 0 &&
val)
- virBufferAdd(buf, " <pae/>\n", -1);
+ virBufferAddLit(buf, " <pae/>\n");
if (xenXMConfigGetInt(conf, "acpi", &val) == 0 &&
val)
- virBufferAdd(buf, " <acpi/>\n", -1);
+ virBufferAddLit(buf, " <acpi/>\n");
if (xenXMConfigGetInt(conf, "apic", &val) == 0 &&
val)
- virBufferAdd(buf, " <apic/>\n", -1);
- virBufferAdd(buf, " </features>\n", -1);
+ virBufferAddLit(buf, " <apic/>\n");
+ virBufferAddLit(buf, " </features>\n");
if (xenXMConfigGetInt(conf, "localtime", &val) < 0)
val = 0;
virBufferVSprintf(buf, " <clock offset='%s'/>\n", val ? "localtime" : "utc");
}
- virBufferAdd(buf, " <devices>\n", -1);
+ virBufferAddLit(buf, " <devices>\n");
if (hvm) {
if (xenXMConfigGetString(conf, "device_model", &str) == 0)
@@ -808,11 +808,11 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
virBufferVSprintf(buf, " <target dev='%s'/>\n", dev);
if (!strcmp(head, "r") ||
!strcmp(head, "ro"))
- virBufferAdd(buf, " <readonly/>\n", -1);
+ virBufferAddLit(buf, " <readonly/>\n");
else if ((!strcmp(head, "w!")) ||
(!strcmp(head, "!")))
- virBufferAdd(buf, " <shareable/>\n", -1);
- virBufferAdd(buf, " </disk>\n", -1);
+ virBufferAddLit(buf, " <shareable/>\n");
+ virBufferAddLit(buf, " </disk>\n");
skipdisk:
list = list->next;
@@ -821,12 +821,12 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (hvm && priv->xendConfigVersion == 1) {
if (xenXMConfigGetString(conf, "cdrom", &str) == 0) {
- virBufferAdd(buf, " <disk type='file' device='cdrom'>\n", -1);
- virBufferAdd(buf, " <driver name='file'/>\n", -1);
+ virBufferAddLit(buf, " <disk type='file' device='cdrom'>\n");
+ virBufferAddLit(buf, " <driver name='file'/>\n");
virBufferVSprintf(buf, " <source file='%s'/>\n", str);
- virBufferAdd(buf, " <target dev='hdc'/>\n", -1);
- virBufferAdd(buf, " <readonly/>\n", -1);
- virBufferAdd(buf, " </disk>\n", -1);
+ virBufferAddLit(buf, " <target dev='hdc'/>\n");
+ virBufferAddLit(buf, " <readonly/>\n");
+ virBufferAddLit(buf, " </disk>\n");
}
}
@@ -897,7 +897,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
type = 1;
}
- virBufferAdd(buf, " <interface type='bridge'>\n", -1);
+ virBufferAddLit(buf, " <interface type='bridge'>\n");
if (mac[0])
virBufferVSprintf(buf, " <mac address='%s'/>\n", mac);
if (type == 1 && bridge[0])
@@ -906,7 +906,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
virBufferVSprintf(buf, " <script path='%s'/>\n", script);
if (ip[0])
virBufferVSprintf(buf, " <ip address='%s'/>\n", ip);
- virBufferAdd(buf, " </interface>\n", -1);
+ virBufferAddLit(buf, " </interface>\n");
skipnic:
list = list->next;
@@ -916,9 +916,9 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (hvm) {
if (xenXMConfigGetString(conf, "usbdevice", &str) == 0 && str) {
if (!strcmp(str, "tablet"))
- virBufferAdd(buf, " <input type='tablet' bus='usb'/>\n", 37);
+ virBufferAddLit(buf, " <input type='tablet' bus='usb'/>\n");
else if (!strcmp(str, "mouse"))
- virBufferAdd(buf, " <input type='mouse' bus='usb'/>\n", 36);
+ virBufferAddLit(buf, " <input type='mouse' bus='usb'/>\n");
/* Ignore else branch - probably some other non-input device we don't
support in libvirt yet */
}
@@ -1006,23 +1006,23 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (keymap) {
virBufferVSprintf(buf, " keymap='%s'", keymap);
}
- virBufferAdd(buf, "/>\n", 3);
+ virBufferAddLit(buf, "/>\n");
}
if (sdl) {
- virBufferAdd(buf, " <graphics type='sdl'/>\n", -1);
+ virBufferAddLit(buf, " <graphics type='sdl'/>\n");
}
if (hvm) {
if (xenXMConfigGetString(conf, "serial", &str) == 0 && !strcmp(str, "pty")) {
- virBufferAdd(buf, " <console/>\n", -1);
+ virBufferAddLit(buf, " <console/>\n");
}
} else { /* Paravirt implicitly always has a console */
- virBufferAdd(buf, " <console/>\n", -1);
+ virBufferAddLit(buf, " <console/>\n");
}
- virBufferAdd(buf, " </devices>\n", -1);
+ virBufferAddLit(buf, " </devices>\n");
- virBufferAdd(buf, "</domain>\n", -1);
+ virBufferAddLit(buf, "</domain>\n");
xml = buf->content;
buf->content = NULL;
@@ -1274,7 +1274,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain,
n = i*8 + j;
if (comma) {
- if (virBufferAdd (mapbuf, ",", 1) == -1) {
+ if (virBufferAddLit (mapbuf, ",") == -1) {
xenXMError (domain->conn, VIR_ERR_NO_MEMORY, __FUNCTION__);
virBufferFree (mapbuf);
return -1;
diff --git a/src/xml.c b/src/xml.c
index b7ffe2a..3052148 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -172,7 +172,7 @@ virSaveCpuSet(virConnectPtr conn, char *cpuset, int maxcpu)
start = cur;
} else if (start != -1) {
if (!first)
- virBufferAdd(buf, ",", -1);
+ virBufferAddLit(buf, ",");
else
first = 0;
if (cur == start + 1)
@@ -185,7 +185,7 @@ virSaveCpuSet(virConnectPtr conn, char *cpuset, int maxcpu)
}
if (start != -1) {
if (!first)
- virBufferAdd(buf, ",", -1);
+ virBufferAddLit(buf, ",");
if (maxcpu == start + 1)
virBufferVSprintf(buf, "%d", start);
else
@@ -384,9 +384,9 @@ virParseXenCpuTopology(virConnectPtr conn, virBufferPtr xml,
goto memory_error;
}
}
- ret = virBufferAdd(xml, "\
+ ret = virBufferAddLit(xml, "\
</cpus>\n\
- </cell>\n", -1);
+ </cell>\n");
if (ret < 0)
goto memory_error;
@@ -718,15 +718,15 @@ virDomainParseXMLGraphicsDescImage(virConnectPtr conn ATTRIBUTE_UNUSED,
graphics_type = xmlGetProp(node, BAD_CAST "type");
if (graphics_type != NULL) {
if (xmlStrEqual(graphics_type, BAD_CAST "sdl")) {
- virBufferAdd(buf, "(sdl 1)", 7);
+ virBufferAddLit(buf, "(sdl 1)", 7);
/* TODO:
* Need to understand sdl options
*
- *virBufferAdd(buf, "(display localhost:10.0)", 24);
- *virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
+ *virBufferAddLit(buf, "(display localhost:10.0)");
+ *virBufferAddLit(buf, "(xauthority /root/.Xauthority)");
*/
} else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
- virBufferAdd(buf, "(vnc 1)", 7);
+ virBufferAddLit(buf, "(vnc 1)");
if (xendConfigVersion >= 2) {
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
@@ -737,7 +737,7 @@ virDomainParseXMLGraphicsDescImage(virConnectPtr conn ATTRIBUTE_UNUSED,
long port = strtol((const char *) vncport, NULL, 10);
if (port == -1)
- virBufferAdd(buf, "(vncunused 1)", 13);
+ virBufferAddLit(buf, "(vncunused 1)");
else if (port >= 5900)
virBufferVSprintf(buf, "(vncdisplay %ld)",
port - 5900);
@@ -784,18 +784,18 @@ virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED,
graphics_type = xmlGetProp(node, BAD_CAST "type");
if (graphics_type != NULL) {
- virBufferAdd(buf, "(device (vkbd))", 15);
- virBufferAdd(buf, "(device (vfb ", 13);
+ virBufferAddLit(buf, "(device (vkbd))");
+ virBufferAddLit(buf, "(device (vfb ");
if (xmlStrEqual(graphics_type, BAD_CAST "sdl")) {
- virBufferAdd(buf, "(type sdl)", 10);
+ virBufferAddLit(buf, "(type sdl)");
/* TODO:
* Need to understand sdl options
*
- *virBufferAdd(buf, "(display localhost:10.0)", 24);
- *virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
+ *virBufferAddLit(buf, "(display localhost:10.0)");
+ *virBufferAddLit(buf, "(xauthority /root/.Xauthority)");
*/
} else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
- virBufferAdd(buf, "(type vnc)", 10);
+ virBufferAddLit(buf, "(type vnc)");
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
xmlChar *vncpasswd = xmlGetProp(node, BAD_CAST "passwd");
@@ -805,7 +805,7 @@ virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED,
long port = strtol((const char *) vncport, NULL, 10);
if (port == -1)
- virBufferAdd(buf, "(vncunused 1)", 13);
+ virBufferAddLit(buf, "(vncunused 1)");
else if (port >= 5900)
virBufferVSprintf(buf, "(vncdisplay %ld)",
port - 5900);
@@ -824,7 +824,7 @@ virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED,
xmlFree(keymap);
}
}
- virBufferAdd(buf, "))", 2);
+ virBufferAddLit(buf, "))");
xmlFree(graphics_type);
}
return 0;
@@ -910,7 +910,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
virXMLError(conn, VIR_ERR_OS_TYPE, (const char *) type, 0);
return (-1);
}
- virBufferAdd(buf, "(image (hvm ", 12);
+ virBufferAddLit(buf, "(image (hvm ");
if (loader == NULL) {
virXMLError(conn, VIR_ERR_NO_KERNEL, NULL, 0);
goto error;
@@ -980,13 +980,13 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
}
if (virXPathNode("/domain/features/acpi", ctxt) != NULL)
- virBufferAdd(buf, "(acpi 1)", 8);
+ virBufferAddLit(buf, "(acpi 1)");
if (virXPathNode("/domain/features/apic", ctxt) != NULL)
- virBufferAdd(buf, "(apic 1)", 8);
+ virBufferAddLit(buf, "(apic 1)");
if (virXPathNode("/domain/features/pae", ctxt) != NULL)
- virBufferAdd(buf, "(pae 1)", 7);
+ virBufferAddLit(buf, "(pae 1)");
- virBufferAdd(buf, "(usb 1)", 7);
+ virBufferAddLit(buf, "(usb 1)");
nb_nodes = virXPathNodeSet("/domain/devices/input", ctxt, &nodes);
if (nb_nodes > 0) {
int i;
@@ -1015,7 +1015,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (!isMouse) {
/* Nothing - implicit ps2 */
} else {
- virBufferAdd(buf, "(usbdevice tablet)", 13);
+ virBufferAddLit(buf, "(usbdevice tablet)");
}
} else {
if (!strcmp((const char *) bus, "ps2")) {
@@ -1028,9 +1028,9 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
/* Nothing - implicit ps2 */
} else if (!strcmp((const char *) bus, "usb")) {
if (isMouse)
- virBufferAdd(buf, "(usbdevice mouse)", 17);
+ virBufferAddLit(buf, "(usbdevice mouse)");
else
- virBufferAdd(buf, "(usbdevice tablet)", 18);
+ virBufferAddLit(buf, "(usbdevice tablet)");
}
}
xmlFree(bus);
@@ -1046,7 +1046,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
goto error;
}
if (res) {
- virBufferAdd(buf, "(serial pty)", 12);
+ virBufferAddLit(buf, "(serial pty)");
}
/* HVM graphics for xen <= 3.0.5 */
@@ -1064,11 +1064,11 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
str = virXPathString("string(/domain/clock/@offset)", ctxt);
if (str != NULL && !strcmp(str, "localtime")) {
- virBufferAdd(buf, "(localtime 1)", 13);
+ virBufferAddLit(buf, "(localtime 1)");
}
free(str);
- virBufferAdd(buf, "))", 2);
+ virBufferAddLit(buf, "))");
return (0);
@@ -1147,7 +1147,7 @@ virDomainParseXMLOSDescPV(virConnectPtr conn, xmlNodePtr node,
virXMLError(conn, VIR_ERR_OS_TYPE, (const char *) type, 0);
return (-1);
}
- virBufferAdd(buf, "(image (linux ", 14);
+ virBufferAddLit(buf, "(image (linux ");
if (kernel == NULL) {
virXMLError(conn, VIR_ERR_NO_KERNEL, NULL, 0);
return (-1);
@@ -1174,7 +1174,7 @@ virDomainParseXMLOSDescPV(virConnectPtr conn, xmlNodePtr node,
}
error:
- virBufferAdd(buf, "))", 2);
+ virBufferAddLit(buf, "))");
return (0);
}
@@ -1304,14 +1304,14 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node,
}
- virBufferAdd(buf, "(device ", 8);
+ virBufferAddLit(buf, "(device ");
/* Normally disks are in a (device (vbd ...)) block
* but blktap disks ended up in a differently named
* (device (tap ....)) block.... */
if (drvName && !strcmp((const char *) drvName, "tap")) {
- virBufferAdd(buf, "(tap ", 5);
+ virBufferAddLit(buf, "(tap ");
} else {
- virBufferAdd(buf, "(vbd ", 5);
+ virBufferAddLit(buf, "(vbd ");
}
if (hvm) {
@@ -1358,8 +1358,8 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node,
else
virBufferVSprintf(buf, "(mode 'w')");
- virBufferAdd(buf, ")", 1);
- virBufferAdd(buf, ")", 1);
+ virBufferAddLit(buf, ")");
+ virBufferAddLit(buf, ")");
cleanup:
if (drvType)
@@ -1442,7 +1442,7 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED,
cur = cur->next;
}
- virBufferAdd(buf, "(vif ", 5);
+ virBufferAddLit(buf, "(vif ");
if (mac != NULL) {
unsigned int addr[12];
int tmp = sscanf((const char *) mac,
@@ -1496,9 +1496,9 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED,
* from Xen 3.1.0
*/
if ((hvm) && (xendConfigVersion < 4))
- virBufferAdd(buf, "(type ioemu)", 12);
+ virBufferAddLit(buf, "(type ioemu)");
- virBufferAdd(buf, ")", 1);
+ virBufferAddLit(buf, ")");
ret = 0;
error:
if (mac != NULL)
@@ -1583,7 +1583,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
}
xmlFree(prop);
}
- virBufferAdd(&buf, "(vm ", 4);
+ virBufferAddLit(&buf, "(vm ");
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
goto error;
@@ -1748,7 +1748,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
nb_nodes = virXPathNodeSet("/domain/devices/interface", ctxt, &nodes);
if (nb_nodes > 0) {
for (i = 0; i < nb_nodes; i++) {
- virBufferAdd(&buf, "(device ", 8);
+ virBufferAddLit(&buf, "(device ");
res =
virDomainParseXMLIfDesc(conn, nodes[i], &buf, hvm,
xendConfigVersion);
@@ -1756,7 +1756,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
free(nodes);
goto error;
}
- virBufferAdd(&buf, ")", 1);
+ virBufferAddLit(&buf, ")");
}
free(nodes);
}
@@ -1779,7 +1779,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
}
- virBufferAdd(&buf, ")", 1); /* closes (vm */
+ virBufferAddLit(&buf, ")"); /* closes (vm */
buf.content[buf.use] = 0;
xmlXPathFreeContext(ctxt);
--
1.5.4.19.gd3dfd
16 years, 10 months
[Libvir] FYI: [PATCH] Fix new "make distcheck" failures.
by Jim Meyering
I've just checked this in:
* src/xml.c (virDomainParseXMLOSDescHVM): Mark a diagnostic.
diff --git a/src/xml.c b/src/xml.c
index c3e25d5..614deb0 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -907,7 +907,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
bootorder[nbootorder] = '\0';
if (loader == NULL) {
- virXMLError(conn, VIR_ERR_INTERNAL_ERROR, "no HVM domain loader", 0);
+ virXMLError(conn, VIR_ERR_INTERNAL_ERROR, _("no HVM domain loader"), 0);
return -1;
}
--
1.5.4.19.gd3dfd
16 years, 10 months
[Libvir] removing trailing blanks (and keeping them away)
by Jim Meyering
Any objection to a mass removal of trailing blanks?
[ If you haven't yet been adversely affected by e.g., pointless conflicts
due solely to differences in white space, count yourself lucky, and
chalk it up to not having to deal with many branches.
The sooner we do this the better, IME. ]
I'm proposing two things:
- remove all trailing blanks
- add a "make syntax-check" check to ensure that no new ones are added
There aren't that many, but the change would affect many files.
IMHO, such a change should wait until after big patches like
Dan's StorageAPI changes are in.
Obviously, one would not change .png and .gif files,
and they would be exempted from the mechanical check.
Here's the full list:
tests/xmlrpctest.c:44
src/openvz_driver.c:41
src/openvz_conf.c:38
NEWS:33
src/libvirt.c:30
docs/virsh.pod:29
docs/libvir.html:24
virsh.1:21
src/xend_internal.c:19
docs/news.html:19
docs/index.py:19
docs/apibuild.py:18
src/xmlrpc.c:16
src/remote_internal.c:14
docs/devhelp/style.css:11
src/xen_internal.c:10
src/proxy_internal.c:9
src/xen_unified.c:8
proxy/libvirt_proxy.c:8
src/xs_internal.c:6
src/util.c:6
src/iptables.c:6
src/qemu_driver.c:5
src/qemu_conf.c:5
include/libvirt/libvirt.h:5
include/libvirt/libvirt.h.in:5
docs/library.xen:5
src/conf.c:4
python/generator.py:4
tests/virshtest.c:3
src/xml.c:3
src/xend_internal.h:3
src/openvz_conf.h:3
src/bridge.c:3
python/libvir.c:3
po/sv.po:3
libvirt.spec.in:3
docs/search.php:3
docs/libvirt.rng:3
docs/libvirLogo.png:3
docs/format.html:3
docs/examples/Makefile.am:3
docs/ChangeLog.xsl:3
docs/ChangeLog.awk:3
src/virterror.c:2
src/qemu.conf:2
src/driver.h:2
qemud/mdns.c:2
docs/site.xsl:2
docs/libvirHeader.png:2
docs/examples/suspend.c:2
docs/examples/python/README:2
docs/examples/examples.xsl:2
docs/Libxml2-Logo-90x34.gif:2
autogen.sh:2
TODO:2
tests/xml2sexprtest.c:1
tests/testutils.h:1
tests/test_conf.sh:1
tests/reconnect.c:1
src/xm_internal.c:1
src/virsh.c:1
src/sexpr.c:1
src/proxy_internal.h:1
src/openvz_driver.h:1
src/hash.c:1
src/buf.c:1
qemud/mdns.h:1
qemud/libvirtd.sasl:1
python/types.c:1
python/tests/uuid.py:1
python/tests/create.py:1
python/Makefile.am:1
po/ru.po:1
docs/windows.html:1
docs/windows-cygwin-3.png:1
docs/uri.html:1
docs/testnode.xml:1
docs/structures.fig:1
docs/node.fig:1
docs/news.xsl:1
docs/newapi.xsl:1
docs/libvirtLogo.png:1
docs/html/libvirt-libvirt.html:1
docs/examples/python/domstart.py:1
docs/examples/python/domsave.py:1
docs/examples/python/dominfo.py:1
docs/devhelp/Makefile.am:1
docs/architecture.fig:1
docs/Makefile.am:1
autobuild.sh:1
16 years, 10 months