Devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 40 participants
- 40153 discussions
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
4
4
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
1
0
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
3
6
05 Feb '08
Roman Divacky wrote:
> hi
>
> I am messing with libvirt and I need to add some methods to the
> xenUnifiedDriver structure. I do it this way:
> (currently #ifdef-ed out)
>
> struct xenUnifiedDriver {
> virDrvOpen open;
> virDrvClose close;
> virDrvGetVersion version;
> virDrvGetHostname getHostname;
> virDrvGetURI getURI;
> virDrvNodeGetInfo nodeGetInfo;
> virDrvGetCapabilities getCapabilities;
> virDrvListDomains listDomains;
> #if 0
> virDrvListDatastores listDatastores;
> virDrvListSyspreps listSyspreps;
> #endif
> ....
>
> with the #if switched to off I am seeing some problems in
> xenUnifiedDomainGetInfo(). it basically iterates through
> array of driver structures to find out suitable domainGetInfo()
> method. When I flip the #if to 1 the driver structures get redefined
> causing xenUnifiedDomainGetInfo() to not find any suitable driver.
Don't add things to xenUnifiedDriver structure -- this structure should
go away eventually. (See the comment in src/xen_unified.h).
Instead, just do whatever you need directly from src/xen_unified.c, be
that direct code or calling something lower level.
> code stuffed with debugging printfs:
>
> #if 0 case:
>
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: 0x2aaaaaae0c10
> priv->opened[i]: 1
> drivers[i]->domainGetInfo: 0x2aaaaaaec2c0
> Domains 0: 2 CPUs
>
> #if 1 case:
>
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: (nil)
> priv->opened[i]: 1
> drivers[i]->domainGetInfo: (nil)
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: 0x2aaaaaae7400
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: (nil)
> priv->opened[i]: 1
> drivers[i]->domainGetInfo: (nil)
> Failed to get informations for Domain 0
>
> as you can see the "drivers" (xenHypervisorDriver etc.) got
> redefined...
>
> any idea why? or whats going on?
>
> thnx for any possible help, if you cannot help me could you please
> forward this mail to the appropriete place?
You should send any questions to libvirt-list:
http://www.redhat.com/mailman/listinfo/libvir-list
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
1
0
In reply to
http://www.redhat.com/archives/libvir-list/2007-April/msg00177.html
an area where vde_switch support is usefull is an unprivileged user
running tests. A test suite involving the creation of qemu instances
thru libvirt should not be forced to create a bridge or alter the
iptables configuration. With vde_switch and slirpvde multiple qemu
instances can be run without altering the network configuration of the host.
I hope it helps.
Cheers
3
2
This makes it so some diagnostics emitted via the error function
are checked for use of "_(...)" when you run "make syntax-check",
and fixes the ones that lacked that:
Enable the sc_unmarked_diagnostics test and correct all violations
involving the "error" function.
* Makefile.cfg (local-checks-to-skip): Remove from skip list.
Then, at the end, a second patch:
Mark a string for translation.
* src/virsh.c: Add a "%s" and wrap with _(...).
Note that technically, it doesn't make sense to translate
a diagnostic like this (there are several like this):
error (conn, VIR_ERR_RPC, _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
However, if it's worth emitting the diagnostic, then I think it's worth
making it a little more useful to someone not reading the code, e.g.,
too many domains (maximum is %d)
If no one objects, I'll convert the ones below.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.cfg | 3 +-
src/remote_internal.c | 81 +++++++++++++++++++++++++++----------------------
2 files changed, 46 insertions(+), 38 deletions(-)
diff --git a/Makefile.cfg b/Makefile.cfg
index 9e75fda..dca7c5b 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -1,5 +1,5 @@
# Customize Makefile.maint. -*- makefile -*-
-# Copyright (C) 2003-2007 Free Software Foundation, Inc.
+# Copyright (C) 2003-2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,7 +29,6 @@ local-checks-to-skip = \
makefile_path_separator_check \
makefile-check \
sc_no_have_config_h \
- sc_unmarked_diagnostics \
sc_tight_scope \
sc_trailing_blank \
sc_GPL_version \
diff --git a/src/remote_internal.c b/src/remote_internal.c
index aa6bb5c..e9c7781 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -104,7 +104,7 @@ struct private_data {
struct private_data *priv = (struct private_data *) (conn)->privateData; \
if (!priv || priv->magic != MAGIC) { \
error (conn, VIR_ERR_INVALID_ARG, \
- "tried to use a closed or uninitialised handle"); \
+ _("tried to use a closed or uninitialised handle")); \
return (retcode); \
}
@@ -112,7 +112,7 @@ struct private_data {
struct private_data *priv = (struct private_data *) (conn)->networkPrivateData; \
if (!priv || priv->magic != MAGIC) { \
error (conn, VIR_ERR_INVALID_ARG, \
- "tried to use a closed or uninitialised handle"); \
+ _("tried to use a closed or uninitialised handle")); \
return (retcode); \
}
@@ -206,7 +206,7 @@ remoteForkDaemon(virConnectPtr conn)
int ret, pid, status;
if (!daemonPath) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "failed to find libvirtd binary");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("failed to find libvirtd binary"));
return(-1);
}
@@ -313,8 +313,8 @@ doRemoteOpen (virConnectPtr conn,
transport = trans_tcp;
else {
error (conn, VIR_ERR_INVALID_ARG,
- "remote_open: transport in URL not recognised "
- "(should be tls|unix|ssh|ext|tcp)");
+ _("remote_open: transport in URL not recognised "
+ "(should be tls|unix|ssh|ext|tcp)"));
return VIR_DRV_OPEN_ERROR;
}
@@ -354,7 +354,7 @@ doRemoteOpen (virConnectPtr conn,
priv->hostname = strdup (uri->server ? uri->server : "localhost");
if (!priv->hostname) {
- error (NULL, VIR_ERR_NO_MEMORY, "allocating priv->hostname");
+ error (NULL, VIR_ERR_NO_MEMORY, _("allocating priv->hostname"));
goto failed;
}
if (uri->user) {
@@ -436,7 +436,8 @@ doRemoteOpen (virConnectPtr conn,
/* For ext transport, command is required. */
if (transport == trans_ext && !command) {
- error (conn, VIR_ERR_INVALID_ARG, "remote_open: for 'ext' transport, command is required");
+ error (conn, VIR_ERR_INVALID_ARG,
+ _("remote_open: for 'ext' transport, command is required"));
goto failed;
}
@@ -754,7 +755,7 @@ doRemoteOpen (virConnectPtr conn,
return retcode;
out_of_memory:
- error (NULL, VIR_ERR_NO_MEMORY, "uri params");
+ error (NULL, VIR_ERR_NO_MEMORY, _("uri params"));
failed:
/* Close the socket if we failed. */
@@ -798,7 +799,7 @@ remoteOpen (virConnectPtr conn,
priv = malloc (sizeof(*priv));
if (!priv) {
- error (conn, VIR_ERR_NO_MEMORY, "struct private_data");
+ error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
return VIR_DRV_OPEN_ERROR;
}
@@ -1050,12 +1051,12 @@ verify_certificate (virConnectPtr conn ATTRIBUTE_UNUSED,
}
if (gnutls_certificate_type_get(session) != GNUTLS_CRT_X509) {
- error (conn, VIR_ERR_RPC, "Certificate type is not X.509");
+ error (conn, VIR_ERR_RPC, _("Certificate type is not X.509"));
return -1;
}
if (!(certs = gnutls_certificate_get_peers(session, &nCerts))) {
- error (conn, VIR_ERR_RPC, "gnutls_certificate_get_peers failed");
+ error (conn, VIR_ERR_RPC, _("gnutls_certificate_get_peers failed"));
return -1;
}
@@ -1076,13 +1077,13 @@ verify_certificate (virConnectPtr conn ATTRIBUTE_UNUSED,
}
if (gnutls_x509_crt_get_expiration_time (cert) < now) {
- error (conn, VIR_ERR_RPC, "The certificate has expired");
+ error (conn, VIR_ERR_RPC, _("The certificate has expired"));
gnutls_x509_crt_deinit (cert);
return -1;
}
if (gnutls_x509_crt_get_activation_time (cert) > now) {
- error (conn, VIR_ERR_RPC, "The certificate is not yet activated");
+ error (conn, VIR_ERR_RPC, _("The certificate is not yet activated"));
gnutls_x509_crt_deinit (cert);
return -1;
}
@@ -1309,7 +1310,7 @@ remoteListDomains (virConnectPtr conn, int *ids, int maxids)
GET_PRIVATE (conn, -1);
if (maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxids > REMOTE_DOMAIN_ID_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
return -1;
}
args.maxids = maxids;
@@ -1321,7 +1322,7 @@ remoteListDomains (virConnectPtr conn, int *ids, int maxids)
return -1;
if (ret.ids.ids_len > maxids) {
- error (conn, VIR_ERR_RPC, "ret.ids.ids_len > maxids");
+ error (conn, VIR_ERR_RPC, _("ret.ids.ids_len > maxids"));
xdr_free ((xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret);
return -1;
}
@@ -1693,7 +1694,7 @@ remoteDomainPinVcpu (virDomainPtr domain,
GET_PRIVATE (domain->conn, -1);
if (maplen > REMOTE_CPUMAP_MAX) {
- error (domain->conn, VIR_ERR_RPC, "maplen > REMOTE_CPUMAP_MAX");
+ error (domain->conn, VIR_ERR_RPC, _("maplen > REMOTE_CPUMAP_MAX"));
return -1;
}
@@ -1723,11 +1724,12 @@ remoteDomainGetVcpus (virDomainPtr domain,
GET_PRIVATE (domain->conn, -1);
if (maxinfo > REMOTE_VCPUINFO_MAX) {
- error (domain->conn, VIR_ERR_RPC, "maxinfo > REMOTE_VCPUINFO_MAX");
+ error (domain->conn, VIR_ERR_RPC, _("maxinfo > REMOTE_VCPUINFO_MAX"));
return -1;
}
if (maxinfo * maplen > REMOTE_CPUMAPS_MAX) {
- error (domain->conn, VIR_ERR_RPC, "maxinfo * maplen > REMOTE_CPUMAPS_MAX");
+ error (domain->conn, VIR_ERR_RPC,
+ _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
return -1;
}
@@ -1742,12 +1744,13 @@ remoteDomainGetVcpus (virDomainPtr domain,
return -1;
if (ret.info.info_len > maxinfo) {
- error (domain->conn, VIR_ERR_RPC, "ret.info.info_len > maxinfo");
+ error (domain->conn, VIR_ERR_RPC, _("ret.info.info_len > maxinfo"));
xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret);
return -1;
}
if (ret.cpumaps.cpumaps_len > maxinfo * maplen) {
- error (domain->conn, VIR_ERR_RPC, "ret.cpumaps.cpumaps_len > maxinfo * maplen");
+ error (domain->conn, VIR_ERR_RPC,
+ _("ret.cpumaps.cpumaps_len > maxinfo * maplen"));
xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret);
return -1;
}
@@ -1907,7 +1910,7 @@ remoteListDefinedDomains (virConnectPtr conn, char **const names, int maxnames)
GET_PRIVATE (conn, -1);
if (maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxnames > REMOTE_DOMAIN_NAME_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
return -1;
}
args.maxnames = maxnames;
@@ -1919,7 +1922,7 @@ remoteListDefinedDomains (virConnectPtr conn, char **const names, int maxnames)
return -1;
if (ret.names.names_len > maxnames) {
- error (conn, VIR_ERR_RPC, "ret.names.names_len > maxnames");
+ error (conn, VIR_ERR_RPC, _("ret.names.names_len > maxnames"));
xdr_free ((xdrproc_t) xdr_remote_list_defined_domains_ret, (char *) &ret);
return -1;
}
@@ -2119,7 +2122,9 @@ remoteDomainGetSchedulerParameters (virDomainPtr domain,
if (ret.params.params_len > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX ||
ret.params.params_len > *nparams) {
xdr_free ((xdrproc_t) xdr_remote_domain_get_scheduler_parameters_ret, (char *) &ret);
- error (domain->conn, VIR_ERR_RPC, "remoteDomainGetSchedulerParameters: returned number of parameters exceeds limit");
+ error (domain->conn, VIR_ERR_RPC,
+ _("remoteDomainGetSchedulerParameters: "
+ "returned number of parameters exceeds limit"));
return -1;
}
*nparams = ret.params.params_len;
@@ -2145,7 +2150,9 @@ remoteDomainGetSchedulerParameters (virDomainPtr domain,
params[i].value.b = ret.params.params_val[i].value.remote_sched_param_value_u.b; break;
default:
xdr_free ((xdrproc_t) xdr_remote_domain_get_scheduler_parameters_ret, (char *) &ret);
- error (domain->conn, VIR_ERR_RPC, "remoteDomainGetSchedulerParameters: unknown parameter type");
+ error (domain->conn, VIR_ERR_RPC,
+ _("remoteDomainGetSchedulerParameters: "
+ "unknown parameter type"));
return -1;
}
}
@@ -2169,7 +2176,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
args.params.params_val = malloc (sizeof (*args.params.params_val)
* nparams);
if (args.params.params_val == NULL) {
- error (domain->conn, VIR_ERR_RPC, "out of memory allocating array");
+ error (domain->conn, VIR_ERR_RPC, _("out of memory allocating array"));
return -1;
}
@@ -2178,7 +2185,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
// call() will free this:
args.params.params_val[i].field = strdup (params[i].field);
if (args.params.params_val[i].field == NULL) {
- error (domain->conn, VIR_ERR_NO_MEMORY, "out of memory");
+ error (domain->conn, VIR_ERR_NO_MEMORY, _("out of memory"));
do_error = 1;
}
args.params.params_val[i].value.type = params[i].type;
@@ -2196,7 +2203,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
args.params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
default:
- error (domain->conn, VIR_ERR_RPC, "unknown parameter type");
+ error (domain->conn, VIR_ERR_RPC, _("unknown parameter type"));
do_error = 1;
}
}
@@ -2301,7 +2308,7 @@ remoteNetworkOpen (virConnectPtr conn,
struct private_data *priv = malloc (sizeof(*priv));
int ret, rflags = 0;
if (!priv) {
- error (conn, VIR_ERR_NO_MEMORY, "struct private_data");
+ error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
return VIR_DRV_OPEN_ERROR;
}
if (flags & VIR_CONNECT_RO)
@@ -2361,7 +2368,7 @@ remoteListNetworks (virConnectPtr conn, char **const names, int maxnames)
GET_NETWORK_PRIVATE (conn, -1);
if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxnames > REMOTE_NETWORK_NAME_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
return -1;
}
args.maxnames = maxnames;
@@ -2373,7 +2380,7 @@ remoteListNetworks (virConnectPtr conn, char **const names, int maxnames)
return -1;
if (ret.names.names_len > maxnames) {
- error (conn, VIR_ERR_RPC, "ret.names.names_len > maxnames");
+ error (conn, VIR_ERR_RPC, _("ret.names.names_len > maxnames"));
xdr_free ((xdrproc_t) xdr_remote_list_networks_ret, (char *) &ret);
return -1;
}
@@ -2416,7 +2423,7 @@ remoteListDefinedNetworks (virConnectPtr conn,
GET_NETWORK_PRIVATE (conn, -1);
if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxnames > REMOTE_NETWORK_NAME_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
return -1;
}
args.maxnames = maxnames;
@@ -2428,7 +2435,7 @@ remoteListDefinedNetworks (virConnectPtr conn,
return -1;
if (ret.names.names_len > maxnames) {
- error (conn, VIR_ERR_RPC, "ret.names.names_len > maxnames");
+ error (conn, VIR_ERR_RPC, _("ret.names.names_len > maxnames"));
xdr_free ((xdrproc_t) xdr_remote_list_defined_networks_ret, (char *) &ret);
return -1;
}
@@ -3413,7 +3420,8 @@ call (virConnectPtr conn, struct private_data *priv,
}
if (!(*args_filter) (&xdr, args)) {
- error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, "marshalling args");
+ error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC,
+ _("marshalling args"));
return -1;
}
@@ -3429,7 +3437,7 @@ call (virConnectPtr conn, struct private_data *priv,
/* Encode the length word. */
xdrmem_create (&xdr, buffer2, sizeof buffer2, XDR_ENCODE);
if (!xdr_int (&xdr, &len)) {
- error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, "xdr_int (length word)");
+ error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, _("xdr_int (length word)"));
return -1;
}
xdr_destroy (&xdr);
@@ -3521,7 +3529,8 @@ call (virConnectPtr conn, struct private_data *priv,
switch (hdr.status) {
case REMOTE_OK:
if (!(*ret_filter) (&xdr, ret)) {
- error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, "unmarshalling ret");
+ error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC,
+ _("unmarshalling ret"));
return -1;
}
xdr_destroy (&xdr);
@@ -3531,7 +3540,7 @@ call (virConnectPtr conn, struct private_data *priv,
memset (&rerror, 0, sizeof rerror);
if (!xdr_remote_error (&xdr, &rerror)) {
error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- VIR_ERR_RPC, "unmarshalling remote_error");
+ VIR_ERR_RPC, _("unmarshalling remote_error"));
return -1;
}
xdr_destroy (&xdr);
--
1.5.4.8.g2b39
Mark a string for translation.
* src/virsh.c: Add a "%s" and wrap with _(...).
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
src/virsh.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/virsh.c b/src/virsh.c
index 487f256..8d3bdc2 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -1,7 +1,7 @@
/*
* virsh.c: a Xen shell used to exercise the libvirt API
*
- * Copyright (C) 2005, 2007 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -4770,7 +4770,7 @@ vshReadline (vshControl *ctl, const char *prompt)
#endif /* !USE_READLINE */
/*
- * Deinitliaze virsh
+ * Deinitialize virsh
*/
static int
vshDeinit(vshControl * ctl)
@@ -4780,8 +4780,8 @@ vshDeinit(vshControl * ctl)
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
ctl->conn = NULL; /* prevent recursive call from vshError() */
- vshError(ctl, TRUE,
- "failed to disconnect from the hypervisor");
+ vshError(ctl, TRUE, "%s",
+ _("failed to disconnect from the hypervisor"));
}
}
virResetLastError();
--
1.5.4.8.g2b39
4
4
This change marks for translation some more messages.
It adds a few new ones, too, e.g., replacing "domain" with
_("failed to parse domain description") in two places.
Likewise, there are some like this:
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
The two new grep invocations in Makefile.maint handle two situations:
First, when the entire statement is on a single line (ends in ";").
The second grep (with -A1) is to get the diagnostics that appear
on the line following the function name. Hence where the first line
ends in ",". With checks like this, it's nice if you can assume no
trailing blanks in the code base. IMHO, that would be a nice change
to make soon, but it's more invasive.
Enable more checks for unmarked messages; fix violators.
* Makefile.maint (sc_unmarked_diagnostics): Check for more functions.
* src/conf.c (virConfParseValue): Remove trailing space in diagnostic.
* src/libvirt.c (do_open, virDomainMigrate): Mark diagnostics.
* src/xend_internal.c (do_connect, xenDaemonDomainDumpXMLByID): Likewise.
(xenDaemonDomainDumpXMLByName, xenDaemonCreateLinux): Likewise.
(xenDaemonDomainMigratePerform, xenDaemonDomainDefineXML): Likewise.
* src/xml.c (virXPathString, virXPathNumber, virXPathLong): Likewise.
(virXPathBoolean, virXPathNode, virXPathNodeSet): Likewise.
(virDomainParseXMLOSDescHVM): Likewise.
* src/xmlrpc.c (xmlRpcValueNew): Likewise.
(xmlRpcValueUnmarshalDictElement): Likewise.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 10 +++++++++-
src/conf.c | 4 ++--
src/libvirt.c | 6 +++---
src/xend_internal.c | 40 ++++++++++++++++++++++++----------------
src/xml.c | 24 +++++++++++++-----------
src/xmlrpc.c | 4 ++--
6 files changed, 53 insertions(+), 35 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 0336f13..356ca73 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -287,14 +287,22 @@ sc_two_space_separator_in_usage:
echo "$(ME): an option and its description"; \
1>&2; exit 1; } || :
+err_func_re = \
+(DISABLE_fprintf|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn))Error)
+
# Look for diagnostics that aren't marked for translation.
# This won't find any for which error's format string is on a separate line.
sc_unmarked_diagnostics:
@grep -nE \
- '\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
+ '\<(vshError|error) \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
| grep -v '_''(' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
+ @{ grep -nE '\<$(err_func_re) *\(.*;$$' $$($(CVS_LIST_EXCEPT)); \
+ grep -A1 -nE '\<$(err_func_re) *\(.*,$$' $$($(CVS_LIST_EXCEPT)); } \
+ | grep '[ ]"' && \
+ { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
+ exit 1; } || :
# Avoid useless parentheses like those in this example:
# #if defined (SYMBOL) || defined (SYM2)
diff --git a/src/conf.c b/src/conf.c
index 8b3aae5..d4e5227 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1,7 +1,7 @@
/**
* conf.c: parser for a subset of the Python encoded Xen configuration files
*
- * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -473,7 +473,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
NEXT;
} else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX,
- _("list is not closed with ] "), ctxt->line);
+ _("list is not closed with ]"), ctxt->line);
virConfFreeList(lst);
return(NULL);
}
diff --git a/src/libvirt.c b/src/libvirt.c
index c19565f..8ab4cbd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2,7 +2,7 @@
* libvirt.c: Main interfaces for the libvirt library to handle virtualization
* domains from a process running in domain 0
*
- * Copyright (C) 2005,2006 Red Hat, Inc.
+ * Copyright (C) 2005,2006,2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -562,7 +562,7 @@ do_open (const char *name,
ret->name = strdup (name);
if (!ret->name) {
- virLibConnError (ret, VIR_ERR_NO_MEMORY, "allocating conn->name");
+ virLibConnError (ret, VIR_ERR_NO_MEMORY, _("allocating conn->name"));
goto failed;
}
@@ -1946,7 +1946,7 @@ virDomainMigrate (virDomainPtr domain,
if (ret == -1) goto done;
if (uri == NULL && uri_out == NULL) {
virLibConnError (conn, VIR_ERR_INTERNAL_ERROR,
- "domainMigratePrepare did not set uri");
+ _("domainMigratePrepare did not set uri"));
goto done;
}
if (uri_out) uri = uri_out; /* Did domainMigratePrepare change URI? */
diff --git a/src/xend_internal.c b/src/xend_internal.c
index bbe5013..78691c9 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -217,7 +217,7 @@ do_connect(virConnectPtr xend)
s = socket(priv->type, SOCK_STREAM, 0);
if (s == -1) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR,
- "failed to create a socket");
+ _("failed to create a socket"));
return -1;
}
@@ -240,7 +240,7 @@ do_connect(virConnectPtr xend)
*/
if ((getuid() == 0) || (xend->flags & VIR_CONNECT_RO)) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR,
- "failed to connect to xend");
+ _("failed to connect to xend"));
}
}
@@ -2512,7 +2512,8 @@ xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid, int flags,
root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid);
if (root == NULL) {
virXendError (conn, VIR_ERR_XEN_CALL,
- "xenDaemonDomainDumpXMLByID failed to find this domain");
+ _("xenDaemonDomainDumpXMLByID failed to"
+ " find this domain"));
return (NULL);
}
@@ -2536,7 +2537,8 @@ xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name, int flags,
root = sexpr_get(conn, "/xend/domain/%s?detail=1", name);
if (root == NULL) {
virXendError (conn, VIR_ERR_XEN_CALL,
- "xenDaemonDomainDumpXMLByName failed to find this domain");
+ _("xenDaemonDomainDumpXMLByName failed to"
+ " find this domain"));
return (NULL);
}
@@ -3144,7 +3146,8 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) {
- virXendError(conn, VIR_ERR_XML_ERROR, "domain");
+ virXendError(conn, VIR_ERR_XML_ERROR,
+ _("failed to parse domain description"));
free(sexpr);
free(name);
@@ -3323,7 +3326,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
/* Xen doesn't support renaming domains during migration. */
if (dname) {
virXendError (conn, VIR_ERR_NO_SUPPORT,
- "xenDaemonDomainMigrate: Xen does not support renaming domains during migration");
+ _("xenDaemonDomainMigrate: Xen does not support"
+ " renaming domains during migration"));
return -1;
}
@@ -3332,7 +3336,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
*/
if (bandwidth) {
virXendError (conn, VIR_ERR_NO_SUPPORT,
- "xenDaemonDomainMigrate: Xen does not support bandwidth limits during migration");
+ _("xenDaemonDomainMigrate: Xen does not support"
+ " bandwidth limits during migration"));
return -1;
}
@@ -3343,7 +3348,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
}
if (flags != 0) {
virXendError (conn, VIR_ERR_NO_SUPPORT,
- "xenDaemonDomainMigrate: unsupported flag");
+ _("xenDaemonDomainMigrate: unsupported flag"));
return -1;
}
@@ -3356,24 +3361,26 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
xmlURIPtr uriptr = xmlParseURI (uri);
if (!uriptr) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: invalid URI");
+ _("xenDaemonDomainMigrate: invalid URI"));
return -1;
}
if (uriptr->scheme && STRCASENEQ (uriptr->scheme, "xenmigr")) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: only xenmigr:// migrations are supported by Xen");
+ _("xenDaemonDomainMigrate: only xenmigr://"
+ " migrations are supported by Xen"));
xmlFreeURI (uriptr);
return -1;
}
if (!uriptr->server) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: a hostname must be specified in the URI");
+ _("xenDaemonDomainMigrate: a hostname must be"
+ " specified in the URI"));
xmlFreeURI (uriptr);
return -1;
}
hostname = strdup (uriptr->server);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
xmlFreeURI (uriptr);
return -1;
}
@@ -3386,7 +3393,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
if (sscanf (p+1, "%d", &port_nr) != 1) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: invalid port number");
+ _("xenDaemonDomainMigrate: invalid port number"));
return -1;
}
snprintf (port, sizeof port, "%d", port_nr);
@@ -3395,7 +3402,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
n = p - uri; /* n = Length of hostname in bytes. */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
return -1;
}
hostname[n] = '\0';
@@ -3403,7 +3410,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
else { /* "hostname" (or IP address) */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
return -1;
}
}
@@ -3448,7 +3455,8 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) {
- virXendError(conn, VIR_ERR_XML_ERROR, "domain");
+ virXendError(conn, VIR_ERR_XML_ERROR,
+ _("failed to parse domain description"));
free(sexpr);
free(name);
diff --git a/src/xml.c b/src/xml.c
index bf1c2eb..b7ffe2a 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,7 +1,7 @@
/*
* xml.c: XML based interfaces for the libvir library
*
- * Copyright (C) 2005, 2007 Red Hat, Inc.
+ * Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -473,7 +473,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathString()", 0);
+ _("Invalid parameter to virXPathString()"), 0);
return (NULL);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -486,7 +486,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj);
if (ret == NULL) {
- virXMLError(NULL, VIR_ERR_NO_MEMORY, "strdup", 0);
+ virXMLError(NULL, VIR_ERR_NO_MEMORY, _("strdup failed"), 0);
}
return (ret);
}
@@ -509,7 +509,7 @@ virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value)
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNumber()", 0);
+ _("Invalid parameter to virXPathNumber()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -544,7 +544,7 @@ virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value)
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNumber()", 0);
+ _("Invalid parameter to virXPathNumber()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -590,7 +590,7 @@ virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathBoolean()", 0);
+ _("Invalid parameter to virXPathBoolean()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -623,7 +623,7 @@ virXPathNode(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNode()", 0);
+ _("Invalid parameter to virXPathNode()"), 0);
return (NULL);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -659,7 +659,7 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt,
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNodeSet()", 0);
+ _("Invalid parameter to virXPathNodeSet()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -882,7 +882,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (nbootorder ==
((sizeof(bootorder) / sizeof(bootorder[0])) - 1)) {
virXMLError(conn, VIR_ERR_XML_ERROR,
- "too many boot devices", 0);
+ _("too many boot devices"), 0);
return (-1);
}
if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
@@ -1004,7 +1004,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
isMouse = 0;
else if (strcmp((const char *) itype, "mouse")) {
xmlFree(itype);
- virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0);
+ virXMLError(conn, VIR_ERR_XML_ERROR,
+ _("invalid input device"), 0);
goto error;
}
xmlFree(itype);
@@ -1020,7 +1021,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (!strcmp((const char *) bus, "ps2")) {
if (!isMouse) {
xmlFree(bus);
- virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0);
+ virXMLError(conn, VIR_ERR_XML_ERROR,
+ _("invalid input device"), 0);
goto error;
}
/* Nothing - implicit ps2 */
diff --git a/src/xmlrpc.c b/src/xmlrpc.c
index ac4ea6e..5baa353 100644
--- a/src/xmlrpc.c
+++ b/src/xmlrpc.c
@@ -50,7 +50,7 @@ static xmlRpcValuePtr xmlRpcValueNew(xmlRpcValueType type)
xmlRpcValuePtr ret = malloc(sizeof(*ret));
if (!ret)
- xmlRpcError(VIR_ERR_NO_MEMORY, "allocate value", sizeof(*ret));
+ xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value"), sizeof(*ret));
else
ret->kind = type;
return ret;
@@ -183,7 +183,7 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
xmlNodePtr cur;
if (!ret) {
- xmlRpcError(VIR_ERR_NO_MEMORY, "allocate dict", sizeof(*ret));
+ xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate dict"), sizeof(*ret));
return NULL;
}
memset(ret, 0, sizeof(*ret));
--
1.5.4.19.gd3dfd
2
1
Brecht Sanders wrote:
> Did you have a win32 Python version of gconf?
Nope.
Please CC questions to libvir-list so that everyone can see questions &
answers.
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
1
0
I have an old HVM guest defined in 3.0.4, and now I'm running 3.1.2 and
libvirt 0.4.0. The config looks like this:
(domain
(image
(hvm
(vnc 1)
(vncdisplay 0)
(device
(vfb
(location localhost:5900)
(vncdisplay 0)
(uuid ...)
The libvirt code looks like this:
1757 /* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */
1758 if ((hvm && xendConfigVersion < 4) ||
1759 (!hvm && xendConfigVersion < 3)) {
1760 tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");
So we don't see the 'vnc 1' at the top. But the code to parse device/vfb doesn't
expect this config either:
1685 tmp = sexpr_node(node, "device/vfb/type");
The patch below replaces the later version check with something that
copes correctly with the "upgrade" case.
regards
john
2008-01-15 John Levon <levon(a)movementarian.org>
* src/xend_internal.c: fix VNC parsing of old Xen domains on
newer Xen versions.
diff -prauN libvirt-0.4.0/src/xend_internal.c libvirt-new/src/xend_internal.c
--- libvirt-0.4.0/src/xend_internal.c 2007-12-17 15:05:27.000000000 -0800
+++ libvirt-new/src/xend_internal.c 2008-01-14 18:42:08.895060570 -0800
@@ -1371,6 +1371,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
unsigned char uuid[VIR_UUID_BUFLEN];
char uuidstr[VIR_UUID_STRING_BUFLEN];
int vif_index = 0;
+ int found_graphics = 0;
if (root == NULL) {
/* ERROR */
@@ -1683,6 +1684,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (tmp && !strcmp(tmp, "sdl")) {
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen");
virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27);
+ found_graphics = 1;
} else if (tmp && !strcmp(tmp, "vnc")) {
int port = xenStoreDomainGetVNCPort(conn, domid);
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
@@ -1700,6 +1702,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAdd(&buf, "/>\n", 3);
+ found_graphics = 1;
}
}
}
@@ -1751,8 +1754,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
}
/* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */
- if ((hvm && xendConfigVersion < 4) ||
- (!hvm && xendConfigVersion < 3)) {
+ if (!found_graphics) {
tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");
if (tmp != NULL) {
if (tmp[0] == '1') {
@@ -1780,6 +1782,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAdd(&buf, "/>\n", 3);
+ found_graphics = 1;
}
}
@@ -1789,6 +1792,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (tmp[0] == '1') {
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2" : "xen");
virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27 );
+ found_graphics = 1;
}
}
}
2
5
Now that I've added the vc-list-files script to gnulib,
this patch makes libvirt's bootstrap pull it from there.
Changes from the previous version of the script:
I reintroduced support for mercurial (only lightly tested),
and rearranged the directory-existence tests so git is first.
Here's the full patch, including a renaming in vasnprintf.c:
----------------
Pull vc-list-files from gnulib, and update.
* bootstrap (gnulib_tool): Add the vc-list-files module.
---
bootstrap | 3 ++-
build-aux/vc-list-files | 19 +++++++++++++------
gnulib/lib/Makefile.am | 9 ++++++++-
gnulib/lib/vasnprintf.c | 18 ++++++++++--------
gnulib/m4/gnulib-cache.m4 | 4 ++--
gnulib/m4/gnulib-comp.m4 | 1 +
6 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/bootstrap b/bootstrap
index 751b244..1627086 100755
--- a/bootstrap
+++ b/bootstrap
@@ -77,7 +77,8 @@ $gnulib_tool \
--tests-base=gnulib/tests \
--import physmem getaddrinfo \
sys_stat vasprintf strndup \
- strsep poll gettext getpass
+ strsep poll gettext getpass \
+ vc-list-files
rm -f \
.gitignore \
diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files
index 72a6f54..1e158bb 100755
--- a/build-aux/vc-list-files
+++ b/build-aux/vc-list-files
@@ -1,7 +1,7 @@
#!/bin/sh
-# List the specified version-controlled files.
+# List version-controlled file names.
-# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2006-2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,7 +18,8 @@
# List the specified version-controlled files.
-# With no argument, list them all.
+# With no argument, list them all. With a single DIRECTORY argument,
+# list the version-controlled files in that directory.
# This script must be run solely from the top of a $srcdir build directory.
# If there's an argument, it must be a single, "."-relative directory name.
@@ -28,12 +29,17 @@ dir=
case $# in
0) ;;
1) dir=$1 ;;
- *) echo "$0: too many arguments" 1>&2; exit 1 ;;
+ *) echo "$0: too many arguments" 1>&2
+ echo "Usage: $0 [DIR]" 1>&2; exit 1;;
esac
test "x$dir" = x && dir=.
-if test -d CVS; then
+if test -d .git; then
+ exec git ls-files "$dir"
+elif test -d .hg; then
+ exec hg locate "$dir/*"
+elif test -d CVS; then
if test -x build-aux/cvsu; then
build-aux/cvsu --find --types=AFGM "$dir"
else
@@ -46,5 +52,6 @@ if test -d CVS; then
$(find ${*-*} -name Entries -print) /dev/null;
fi
else
- git-ls-files "$dir"
+ echo "$0: Failed to determine type of version control used in "`pwd` 1>&2
+ exit 1
fi
diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am
index 64fc398..8f545ca 100644
--- a/gnulib/lib/Makefile.am
+++ b/gnulib/lib/Makefile.am
@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf vc-list-files
AUTOMAKE_OPTIONS = 1.5 gnits
@@ -719,6 +719,13 @@ EXTRA_libgnu_la_SOURCES += asprintf.c vasprintf.c
## end gnulib module vasprintf
+## begin gnulib module vc-list-files
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/vc-list-files
+
+## end gnulib module vc-list-files
+
## begin gnulib module wchar
BUILT_SOURCES += $(WCHAR_H)
diff --git a/gnulib/lib/vasnprintf.c b/gnulib/lib/vasnprintf.c
index 6c8d5dc..205a9bf 100644
--- a/gnulib/lib/vasnprintf.c
+++ b/gnulib/lib/vasnprintf.c
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -95,7 +95,7 @@
#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
# include <math.h>
-# include "isnan.h"
+# include "isnand.h"
#endif
#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL
@@ -106,7 +106,7 @@
#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
# include <math.h>
-# include "isnan.h"
+# include "isnand.h"
# include "printf-frexp.h"
#endif
@@ -236,7 +236,7 @@ decimal_point_char ()
static int
is_infinite_or_zero (double x)
{
- return isnan (x) || x + x == x;
+ return isnand (x) || x + x == x;
}
#endif
@@ -2327,7 +2327,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
double arg = a.arg[dp->arg_index].a.a_double;
- if (isnan (arg))
+ if (isnand (arg))
{
if (dp->conversion == 'A')
{
@@ -2676,7 +2676,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (dp->conversion == 'f' || dp->conversion == 'F')
{
double arg = a.arg[dp->arg_index].a.a_double;
- if (!(isnan (arg) || arg + arg == arg))
+ if (!(isnand (arg) || arg + arg == arg))
{
/* arg is finite and nonzero. */
int exponent = floorlog10 (arg < 0 ? -arg : arg);
@@ -3080,7 +3080,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
{
double arg = a.arg[dp->arg_index].a.a_double;
- if (isnan (arg))
+ if (isnand (arg))
{
if (dp->conversion >= 'A' && dp->conversion <= 'Z')
{
@@ -4327,7 +4327,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (prec_ourselves)
{
/* Handle the precision. */
- TCHAR_T *prec_ptr =
+ TCHAR_T *prec_ptr =
# if USE_SNPRINTF
(TCHAR_T *) (result + length);
# else
@@ -4654,6 +4654,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
not have this limitation. */
return result;
+#if USE_SNPRINTF
overflow:
if (!(result == resultbuf || result == NULL))
free (result);
@@ -4662,6 +4663,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
CLEANUP ();
errno = EOVERFLOW;
return NULL;
+#endif
out_of_memory:
if (!(result == resultbuf || result == NULL))
diff --git a/gnulib/m4/gnulib-cache.m4 b/gnulib/m4/gnulib-cache.m4
index d55e07a..357f170 100644
--- a/gnulib/m4/gnulib-cache.m4
+++ b/gnulib/m4/gnulib-cache.m4
@@ -15,11 +15,11 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf vc-list-files
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
-gl_MODULES([getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf])
+gl_MODULES([getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf vc-list-files])
gl_AVOID([])
gl_SOURCE_BASE([gnulib/lib])
gl_M4_BASE([gnulib/m4])
diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
index 1b91a1e..8896a38 100644
--- a/gnulib/m4/gnulib-comp.m4
+++ b/gnulib/m4/gnulib-comp.m4
@@ -225,6 +225,7 @@ AC_DEFUN([gltests_LIBSOURCES], [
AC_DEFUN([gl_FILE_LIST], [
build-aux/config.rpath
build-aux/link-warning.h
+ build-aux/vc-list-files
lib/alloca.in.h
lib/asnprintf.c
lib/asprintf.c
--
1.5.4.rc5.1.g0fa73
3
4