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