[libvirt] libvirtd cpu usage
by Thomas Mueller
hi there
i'm playing on debian lenny with kvm-66/libvirt-0.4.2 .
if i run top, i see libvirtd is top cpu consumer. if i connect with
strace to libvirtd, i see a thousand times this message:
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN|POLLERR|POLLHUP},
{fd=7, events=POLLIN|POLLERR|POLLHUP}, {fd=8, events=POLLIN}, {fd=13,
events=POLLIN|POLLERR|POLLHUP, revents=POLLHUP}, {fd=15,
events=POLLIN|POLLERR|POLLHUP, revents=POLLHUP}, {fd=17,
events=POLLIN|POLLERR|POLLHUP}, {fd=19, events=POLLIN|POLLERR|POLLHUP}],
8, -1) = 2
if i stop libvirtd and start the guest myself on cli, the guest is much
faster.
- Thomas
16 years, 5 months
[libvirt] [PATCH] avoid using STREQLEN with a literal; use STRPREFIX instead
by Jim Meyering
The goal of this change is to remove the error-prone duplication
between literal strings and corresponding literal length.
This was almost 100% mechanical:
# Do this:
# - STRNEQLEN((const char *)target, "hd", 2) &&
# + !STRPREFIX((const char *)target, "hd") &&
git grep -l '\<STRNEQLEN *('| f | xargs \
perl -pi -e 's/\bSTRNEQLEN( *\(.*?, *".*?"), \d+\)/!STRPREFIX$1)/'
# Do this:
# - } else if (STREQLEN(key, "vnclisten=", 10)) {
# + } else if (STRPREFIX(key, "vnclisten=")) {
git grep -l '\<STREQLEN *('| f | xargs \
perl -pi -e 's/\bSTREQLEN( *\(.*?, *".*?"), \d+\)/STRPREFIX$1)/'
# Two missed by the above
# src/qemu_conf.c: if (STREQLEN("vnet", (const char*)ifname, 4)) {
# src/xm_internal.c: if (STREQLEN(ent->d_name, QEMU_IF_SCRIPT, strlen(QEMU_IF_SCRIPT)))
# Since there are 3 more like the latter, do them automatically:
git grep -l '\<STREQLEN *('| f | xargs \
perl -pi -e 's/\bSTREQLEN( *\(.*?, *(\w+)), strlen\(\2\)\)/STRPREFIX$1)/'
I manually reversed the two args with the "vnet" use in qemu_conf.c,
so that the perl code would transform that one, too.
>From b043c2d627a7133d75664c01a3fe813b760502e9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 15 May 2008 15:58:23 +0200
Subject: [PATCH] avoid using STREQLEN with a literal; use STRPREFIX instead
Likewise for STRNEQLEN -> !STRPREFIX.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate):
* src/qemu_conf.c (qemudNetworkIfaceConnect):
(qemudParseInterfaceXML):
* src/qemu_driver.c (qemudDomainBlockStats):
* src/remote_internal.c (call):
* src/stats_linux.c (xenLinuxDomainDeviceID):
* src/xend_internal.c (xend_parse_sexp_desc):
(xend_get, sexpr_to_xend_topology):
* src/xm_internal.c (xenXMConfigCacheRefresh)
(xenXMDomainFormatXML):
---
src/nodeinfo.c | 6 +++---
src/qemu_conf.c | 6 +++---
src/qemu_driver.c | 14 +++++++-------
src/remote_internal.c | 2 +-
src/stats_linux.c | 8 ++++----
src/xend_internal.c | 6 +++---
src/xm_internal.c | 14 +++++++-------
7 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index e227c69..b2ef6ee 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -57,7 +57,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
/* XXX hyperthreads */
while (fgets(line, sizeof(line), cpuinfo) != NULL) {
char *buf = line;
- if (STREQLEN(buf, "processor", 9)) { /* aka a single logical CPU */
+ if (STRPREFIX(buf, "processor")) { /* aka a single logical CPU */
buf += 9;
while (*buf && c_isspace(*buf))
buf++;
@@ -68,7 +68,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
return -1;
}
nodeinfo->cpus++;
- } else if (STREQLEN(buf, "cpu MHz", 7)) {
+ } else if (STRPREFIX(buf, "cpu MHz")) {
char *p;
unsigned int ui;
buf += 9;
@@ -84,7 +84,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
/* Accept trailing fractional part. */
&& (*p == '\0' || *p == '.' || c_isspace(*p)))
nodeinfo->mhz = ui;
- } else if (STREQLEN(buf, "cpu cores", 9)) { /* aka cores */
+ } else if (STRPREFIX(buf, "cpu cores")) { /* aka cores */
char *p;
unsigned int id;
buf += 9;
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index f31b33a..8ae0960 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -816,7 +816,7 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
(net->type == QEMUD_NET_BRIDGE)) &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
ifname = xmlGetProp(cur, BAD_CAST "dev");
- if (STREQLEN("vnet", (const char*)ifname, 4)) {
+ if (STRPREFIX((const char*)ifname, "vnet")) {
/* An auto-generated target name, blank it out */
xmlFree(ifname);
ifname = NULL;
@@ -2130,7 +2130,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
}
brname = network->bridge;
if (net->dst.network.ifname[0] == '\0' ||
- STREQLEN(net->dst.network.ifname, "vnet", 4) ||
+ STRPREFIX(net->dst.network.ifname, "vnet") ||
strchr(net->dst.network.ifname, '%')) {
strcpy(net->dst.network.ifname, "vnet%d");
}
@@ -2138,7 +2138,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
} else if (net->type == QEMUD_NET_BRIDGE) {
brname = net->dst.bridge.brname;
if (net->dst.bridge.ifname[0] == '\0' ||
- STREQLEN(net->dst.bridge.ifname, "vnet", 4) ||
+ STRPREFIX(net->dst.bridge.ifname, "vnet") ||
strchr(net->dst.bridge.ifname, '%')) {
strcpy(net->dst.bridge.ifname, "vnet%d");
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 7d52798..6ba6179 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2650,12 +2650,12 @@ qemudDomainBlockStats (virDomainPtr dom,
* cdrom to ide1-cd0
* fd[a-] to floppy[0-]
*/
- if (STREQLEN (path, "hd", 2) && path[2] >= 'a' && path[2] <= 'z')
+ if (STRPREFIX (path, "hd") && path[2] >= 'a' && path[2] <= 'z')
snprintf (qemu_dev_name, sizeof (qemu_dev_name),
"ide0-hd%d", path[2] - 'a');
else if (STREQ (path, "cdrom"))
strcpy (qemu_dev_name, "ide1-cd0");
- else if (STREQLEN (path, "fd", 2) && path[2] >= 'a' && path[2] <= 'z')
+ else if (STRPREFIX (path, "fd") && path[2] >= 'a' && path[2] <= 'z')
snprintf (qemu_dev_name, sizeof (qemu_dev_name),
"floppy%d", path[2] - 'a');
else {
@@ -2679,7 +2679,7 @@ qemudDomainBlockStats (virDomainPtr dom,
* unlikely to be the name of a block device, we can use this
* to detect if qemu supports the command.
*/
- if (STREQLEN (info, "info ", 5)) {
+ if (STRPREFIX (info, "info ")) {
free (info);
qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
"%s",
@@ -2711,19 +2711,19 @@ qemudDomainBlockStats (virDomainPtr dom,
p += len+2; /* Skip to first label. */
while (*p) {
- if (STREQLEN (p, "rd_bytes=", 9)) {
+ if (STRPREFIX (p, "rd_bytes=")) {
p += 9;
if (virStrToLong_ll (p, &dummy, 10, &stats->rd_bytes) == -1)
DEBUG ("error reading rd_bytes: %s", p);
- } else if (STREQLEN (p, "wr_bytes=", 9)) {
+ } else if (STRPREFIX (p, "wr_bytes=")) {
p += 9;
if (virStrToLong_ll (p, &dummy, 10, &stats->wr_bytes) == -1)
DEBUG ("error reading wr_bytes: %s", p);
- } else if (STREQLEN (p, "rd_operations=", 14)) {
+ } else if (STRPREFIX (p, "rd_operations=")) {
p += 14;
if (virStrToLong_ll (p, &dummy, 10, &stats->rd_req) == -1)
DEBUG ("error reading rd_req: %s", p);
- } else if (STREQLEN (p, "wr_operations=", 14)) {
+ } else if (STRPREFIX (p, "wr_operations=")) {
p += 14;
if (virStrToLong_ll (p, &dummy, 10, &stats->wr_req) == -1)
DEBUG ("error reading wr_req: %s", p);
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 1b6e9d3..51e8eb7 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -4339,7 +4339,7 @@ call (virConnectPtr conn, struct private_data *priv,
rerror.domain == VIR_FROM_REMOTE &&
rerror.code == VIR_ERR_RPC &&
rerror.level == VIR_ERR_ERROR &&
- STREQLEN(*rerror.message, "unknown procedure", 17)) {
+ STRPREFIX(*rerror.message, "unknown procedure")) {
return -2;
}
server_error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, &rerror);
diff --git a/src/stats_linux.c b/src/stats_linux.c
index cb647fe..30a4990 100644
--- a/src/stats_linux.c
+++ b/src/stats_linux.c
@@ -230,7 +230,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
/* Strip leading path if any */
if (strlen(path) > 5 &&
- STREQLEN(path, "/dev/", 5))
+ STRPREFIX(path, "/dev/"))
path += 5;
/*
@@ -251,7 +251,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
*/
if (strlen (path) >= 4 &&
- STREQLEN (path, "xvd", 3)) {
+ STRPREFIX (path, "xvd")) {
/* Xen paravirt device handling */
disk = (path[3] - 'a');
if (disk < 0 || disk > 15) {
@@ -274,7 +274,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
return (XENVBD_MAJOR * 256) + (disk * 16) + part;
} else if (strlen (path) >= 3 &&
- STREQLEN (path, "sd", 2)) {
+ STRPREFIX (path, "sd")) {
/* SCSI device handling */
int majors[] = { SCSI_DISK0_MAJOR, SCSI_DISK1_MAJOR, SCSI_DISK2_MAJOR,
SCSI_DISK3_MAJOR, SCSI_DISK4_MAJOR, SCSI_DISK5_MAJOR,
@@ -318,7 +318,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
return (majors[disk/16] * 256) + ((disk%16) * 16) + part;
} else if (strlen (path) >= 3 &&
- STREQLEN (path, "hd", 2)) {
+ STRPREFIX (path, "hd")) {
/* IDE device handling */
int majors[] = { IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR,
IDE4_MAJOR, IDE5_MAJOR, IDE6_MAJOR, IDE7_MAJOR,
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 6aecfdd..590fabe 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -487,7 +487,7 @@ xend_get(virConnectPtr xend, const char *path,
close(s);
if (((ret < 0) || (ret >= 300)) &&
- ((ret != 404) || (STRNEQLEN(path, "/xend/domain/", 13)))) {
+ ((ret != 404) || (!STRPREFIX(path, "/xend/domain/")))) {
virXendError(xend, VIR_ERR_GET_FAILED, content);
}
@@ -1943,7 +1943,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
}
}
- if (STREQLEN(dst, "ioemu:", 6))
+ if (STRPREFIX(dst, "ioemu:"))
dst += 6;
/* New style disk config from Xen >= 3.0.3 */
@@ -2399,7 +2399,7 @@ sexpr_to_xend_topology(virConnectPtr conn,
goto parse_error;
cur++;
virSkipSpaces(&cur);
- if (STREQLEN(cur, "no cpus", 7)) {
+ if (STRPREFIX(cur, "no cpus")) {
nb_cpus = 0;
for (cpu = 0; cpu < numCpus; cpu++)
cpuset[cpu] = 0;
diff --git a/src/xm_internal.c b/src/xm_internal.c
index 393700c..9731125 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -353,19 +353,19 @@ static int xenXMConfigCacheRefresh (virConnectPtr conn) {
*/
/* Like 'dot' files... */
- if (STREQLEN(ent->d_name, ".", 1))
+ if (STRPREFIX(ent->d_name, "."))
continue;
/* ...and the XenD server config file */
- if (STREQLEN(ent->d_name, XEND_CONFIG_FILE, strlen(XEND_CONFIG_FILE)))
+ if (STRPREFIX(ent->d_name, XEND_CONFIG_FILE))
continue;
/* ...and random PCI config cruft */
- if (STREQLEN(ent->d_name, XEND_PCI_CONFIG_PREFIX, strlen(XEND_PCI_CONFIG_PREFIX)))
+ if (STRPREFIX(ent->d_name, XEND_PCI_CONFIG_PREFIX))
continue;
/* ...and the example domain configs */
- if (STREQLEN(ent->d_name, XM_EXAMPLE_PREFIX, strlen(XM_EXAMPLE_PREFIX)))
+ if (STRPREFIX(ent->d_name, XM_EXAMPLE_PREFIX))
continue;
/* ...and the QEMU networking script */
- if (STREQLEN(ent->d_name, QEMU_IF_SCRIPT, strlen(QEMU_IF_SCRIPT)))
+ if (STRPREFIX(ent->d_name, QEMU_IF_SCRIPT))
continue;
/* ...and editor backups */
@@ -778,7 +778,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
}
/* And the source driver sub-type */
- if (STREQLEN(drvName, "tap", 3)) {
+ if (STRPREFIX(drvName, "tap")) {
if (!(tmp1 = strchr(tmp+1, ':')) || !tmp1[0])
goto skipdisk;
strncpy(drvType, tmp+1, (tmp1-(tmp+1)));
@@ -795,7 +795,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
}
/* Remove legacy ioemu: junk */
- if (STREQLEN(dev, "ioemu:", 6)) {
+ if (STRPREFIX(dev, "ioemu:")) {
memmove(dev, dev+6, strlen(dev)-5);
}
--
1.5.5.1.148.gbc1be
16 years, 5 months
[libvirt] Event on domain state change
by Stefan de Konink
Hi,
In the TODO list I find this line:
- event on big domain state change (create, crashed, paused, shutdown,
destroy)
Because this is a feature that is very useful, I first wonder how libvirt
reliably get 'events' itself for example from Xen? From what I can read
from xen_internal there is a xenHypervisorGetDomInfo function, but this
function should be scheduled in order to see event changes. Even if so,
can we be 'quick' enough to detect a destroy? Or determine the difference
between a shutdown and a destroy?
Stefan
16 years, 5 months
[libvirt] [BUG] second libvirtd breaks the first
by Stefan de Konink
By accident I ran a second instance of libvirtd. This second instance did
not terminate the first instance nor did it detect there was already a
running instance. By killing the second instance the first did not work
anymore.
Next to this, why does libvirtd terminate its iSCSI connections upon stop?
I saw it cannot gracefully 'reuse' existing sessions, but it is absurd
that restarting libvirtd would kill all running VMs on a host using iSCSI,
or not able to get a storage pool up because it is already logged in to
it.
Stefan
16 years, 5 months
[libvirt] [PATCH] Bind to ip_addr support.
by Stefan de Konink
Hi,
Mainly because I think Daniel always gives good feedback and comments,
plus I don't want to be a troll on this list, I decided the time had come
to spend some minutes to hack up a patch :)
It has been tested:
tcp 0 0 192.168.0.5:16509 *:* LISTEN
vs
tcp 0 0 *:16509 *:* LISTEN
Only lefts me:
By making a contribution to this project, I, Stefan de Konink, certify
that:
(a) The contribution was created in whole or in part by me and I have the
right to submit it under the open source license indicated in the file; or
(b) The contribution is based upon previous work that, to the best of my
knowledge, is covered under an appropriate open source license and I have
the right under that license to submit that work with modifications,
whether created in whole or in part by me, under the same open source
license (unless I am permitted to submit under a different license), as
indicated in the file; or
(c) The contribution was provided directly to me by some other person who
certified (a), (b) or (c) and I have not modified it; and
(d) In the case of each of (a), (b), or (c), I understand and agree that
this project and the contribution are public and that a record of the
contribution (including all personal information I submit with it,
including my sign-off) is maintained indefinitely and may be redistributed
consistent with this project or the open source license indicated in the
file.
Signed-off-by: Stefan de Konink <dekonink(a)kinkrsoftware.nl>
Yours Sincerely,
Stefan de Konink
16 years, 5 months
[libvirt] PATCH: Remove use of strcmp, etc
by Daniel P. Berrange
This patch removes all use of strcmp, strncmp, strcasecmp and strncasecmp
in favour of the equality macros we have defined in internal.h, eg STREQ,
STRNEQ, STRNEQLEN, STREQLEN, etc, etc
The only strcasecmp left is in virsh where it is used in a sort function
so does genuinely need the -1, 0, +1 tristate return value rather than a
simple boolean for equality.
This brings all code into compliance with string comparison guidelines in
the HACKING file.
proxy/libvirt_proxy.c | 4 -
src/conf.c | 4 -
src/hash.c | 12 ++---
src/iptables.c | 6 +-
src/libvirt.c | 4 -
src/openvz_conf.c | 10 ++--
src/qemu_conf.c | 62 ++++++++++++++---------------
src/remote_internal.c | 10 ++--
src/sexpr.c | 4 -
src/test.c | 14 +++---
src/util.c | 8 +--
src/virsh.c | 30 +++++++-------
src/xen_unified.c | 6 +-
src/xend_internal.c | 40 +++++++++----------
src/xm_internal.c | 104 +++++++++++++++++++++++++-------------------------
src/xml.c | 22 +++++-----
src/xmlrpc.c | 2
tests/virshtest.c | 6 +-
tests/xml2sexprtest.c | 2
tests/xmlrpctest.c | 2
20 files changed, 177 insertions(+), 175 deletions(-)
Dan.
Index: proxy/libvirt_proxy.c
===================================================================
RCS file: /data/cvs/libvirt/proxy/libvirt_proxy.c,v
retrieving revision 1.33
diff -u -p -u -p -r1.33 libvirt_proxy.c
--- proxy/libvirt_proxy.c 24 Apr 2008 09:17:29 -0000 1.33
+++ proxy/libvirt_proxy.c 9 May 2008 21:08:07 -0000
@@ -802,9 +802,9 @@ int main(int argc, char **argv) {
}
for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-v")) {
+ if (STREQ(argv[i], "-v")) {
debug++;
- } else if (!strcmp(argv[i], "-no-timeout")) {
+ } else if (STREQ(argv[i], "-no-timeout")) {
persist = 1;
} else {
usage(argv[0]);
Index: src/conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/conf.c,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 conf.c
--- src/conf.c 28 Apr 2008 15:14:59 -0000 1.26
+++ src/conf.c 9 May 2008 21:08:08 -0000
@@ -800,7 +800,7 @@ __virConfGetValue(virConfPtr conf, const
cur = conf->entries;
while (cur != NULL) {
- if ((cur->name != NULL) && (!strcmp(cur->name, setting)))
+ if ((cur->name != NULL) && (STREQ(cur->name, setting)))
return(cur->value);
cur = cur->next;
}
@@ -829,7 +829,7 @@ __virConfSetValue (virConfPtr conf,
cur = conf->entries;
while (cur != NULL) {
- if ((cur->name != NULL) && (!strcmp(cur->name, setting))) {
+ if ((cur->name != NULL) && (STREQ(cur->name, setting))) {
break;
}
prev = cur;
Index: src/hash.c
===================================================================
RCS file: /data/cvs/libvirt/src/hash.c,v
retrieving revision 1.39
diff -u -p -u -p -r1.39 hash.c
--- src/hash.c 29 Apr 2008 13:48:41 -0000 1.39
+++ src/hash.c 9 May 2008 21:08:08 -0000
@@ -270,11 +270,11 @@ virHashAddEntry(virHashTablePtr table, c
} else {
for (insert = &(table->table[key]); insert->next != NULL;
insert = insert->next) {
- if (!strcmp(insert->name, name))
+ if (STREQ(insert->name, name))
return (-1);
len++;
}
- if (!strcmp(insert->name, name))
+ if (STREQ(insert->name, name))
return (-1);
}
@@ -335,14 +335,14 @@ virHashUpdateEntry(virHashTablePtr table
} else {
for (insert = &(table->table[key]); insert->next != NULL;
insert = insert->next) {
- if (!strcmp(insert->name, name)) {
+ if (STREQ(insert->name, name)) {
if (f)
f(insert->payload, insert->name);
insert->payload = userdata;
return (0);
}
}
- if (!strcmp(insert->name, name)) {
+ if (STREQ(insert->name, name)) {
if (f)
f(insert->payload, insert->name);
insert->payload = userdata;
@@ -393,7 +393,7 @@ virHashLookup(virHashTablePtr table, con
if (table->table[key].valid == 0)
return (NULL);
for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
- if (!strcmp(entry->name, name))
+ if (STREQ(entry->name, name))
return (entry->payload);
}
return (NULL);
@@ -445,7 +445,7 @@ virHashRemoveEntry(virHashTablePtr table
} else {
for (entry = &(table->table[key]); entry != NULL;
entry = entry->next) {
- if (!strcmp(entry->name, name)) {
+ if (STREQ(entry->name, name)) {
if ((f != NULL) && (entry->payload != NULL))
f(entry->payload, entry->name);
entry->payload = NULL;
Index: src/iptables.c
===================================================================
RCS file: /data/cvs/libvirt/src/iptables.c,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 iptables.c
--- src/iptables.c 10 Apr 2008 16:53:29 -0000 1.26
+++ src/iptables.c 9 May 2008 21:08:08 -0000
@@ -114,7 +114,7 @@ stripLine(char *str, int len, const char
s = str;
while ((p = strchr(s, '\n'))) {
- if (p == s || strncmp(s, line, p - s) != 0) {
+ if (p == s || STRNEQLEN(s, line, p - s)) {
s = ++p;
continue;
}
@@ -125,7 +125,7 @@ stripLine(char *str, int len, const char
changed = 1;
}
- if (strcmp(s, line) == 0) {
+ if (STREQ(s, line)) {
*s = '\0';
changed = 1;
}
@@ -310,7 +310,7 @@ iptRulesRemove(iptRules *rules,
int i;
for (i = 0; i < rules->nrules; i++)
- if (!strcmp(rules->rules[i].rule, rule))
+ if (STREQ(rules->rules[i].rule, rule))
break;
if (i >= rules->nrules)
Index: src/libvirt.c
===================================================================
RCS file: /data/cvs/libvirt/src/libvirt.c,v
retrieving revision 1.137
diff -u -p -u -p -r1.137 libvirt.c
--- src/libvirt.c 10 Apr 2008 16:54:54 -0000 1.137
+++ src/libvirt.c 9 May 2008 21:08:08 -0000
@@ -644,7 +644,7 @@ virGetVersion(unsigned long *libVer, con
type = "Xen";
for (i = 0;i < virDriverTabCount;i++) {
if ((virDriverTab[i] != NULL) &&
- (!strcasecmp(virDriverTab[i]->name, type))) {
+ (STRCASEEQ(virDriverTab[i]->name, type))) {
*typeVer = virDriverTab[i]->ver;
break;
}
@@ -710,7 +710,7 @@ do_open (const char *name,
}
/* Convert xen -> xen:/// for back compat */
- if (!strcasecmp(name, "xen"))
+ if (STRCASEEQ(name, "xen"))
name = "xen:///";
/* Convert xen:// -> xen:/// because xmlParseURI cannot parse the
Index: src/openvz_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/openvz_conf.c,v
retrieving revision 1.22
diff -u -p -u -p -r1.22 openvz_conf.c
--- src/openvz_conf.c 10 Apr 2008 16:54:54 -0000 1.22
+++ src/openvz_conf.c 9 May 2008 21:08:08 -0000
@@ -107,7 +107,7 @@ struct openvz_vm
struct openvz_vm *vm = driver->vms;
while (vm) {
- if (!strcmp(vm->vmdef->name, name))
+ if (STREQ(vm->vmdef->name, name))
return vm;
vm = vm->next;
}
@@ -324,7 +324,7 @@ static struct openvz_vm_def
goto bail_out;
}
- if (strcmp((char *)prop, "openvz")){
+ if (STRNEQ((char *)prop, "openvz")){
error(conn, VIR_ERR_INTERNAL_ERROR, _("invalid domain type attribute"));
goto bail_out;
}
@@ -553,7 +553,7 @@ openvzGetVPSInfo(virConnectPtr conn) {
_("Failed to parse vzlist output"));
goto error;
}
- if(strcmp(status, "stopped")) {
+ if(STRNEQ(status, "stopped")) {
(*pnext)->status = VIR_DOMAIN_RUNNING;
driver->num_active ++;
(*pnext)->vpsid = veid;
@@ -673,7 +673,7 @@ openvzGetVPSUUID(int vpsid, char *uuidst
}
sscanf(line, "%s %s\n", iden, uuidbuf);
- if(!strcmp(iden, "#UUID:")) {
+ if(STREQ(iden, "#UUID:")) {
strncpy(uuidstr, uuidbuf, VIR_UUID_STRING_BUFLEN);
break;
}
@@ -747,7 +747,7 @@ int openvzAssignUUIDs(void)
while((dent = readdir(dp))) {
res = sscanf(dent->d_name, "%d.%5s", &vpsid, ext);
- if(!(res == 2 && !strcmp(ext, "conf")))
+ if(!(res == 2 && STREQ(ext, "conf")))
continue;
if(vpsid > 0) /* '0.conf' belongs to the host, ignore it */
openvzSetUUID(vpsid);
Index: src/qemu_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_conf.c,v
retrieving revision 1.55
diff -u -p -u -p -r1.55 qemu_conf.c
--- src/qemu_conf.c 9 May 2008 16:41:20 -0000 1.55
+++ src/qemu_conf.c 9 May 2008 21:08:08 -0000
@@ -166,7 +166,7 @@ struct qemud_vm *qemudFindVMByName(const
struct qemud_vm *vm = driver->vms;
while (vm) {
- if (!strcmp(vm->def->name, name))
+ if (STREQ(vm->def->name, name))
return vm;
vm = vm->next;
}
@@ -192,7 +192,7 @@ struct qemud_network *qemudFindNetworkBy
struct qemud_network *network = driver->networks;
while (network) {
- if (!strcmp(network->def->name, name))
+ if (STREQ(network->def->name, name))
return network;
network = network->next;
}
@@ -644,30 +644,30 @@ static int qemudParseDiskXML(virConnectP
}
if (device &&
- !strcmp((const char *)device, "floppy") &&
- strcmp((const char *)target, "fda") &&
- strcmp((const char *)target, "fdb")) {
+ STREQ((const char *)device, "floppy") &&
+ STRNEQ((const char *)target, "fda") &&
+ STRNEQ((const char *)target, "fdb")) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Invalid floppy device name: %s"), target);
goto error;
}
if (device &&
- !strcmp((const char *)device, "cdrom") &&
- strcmp((const char *)target, "hdc")) {
+ STREQ((const char *)device, "cdrom") &&
+ STRNEQ((const char *)target, "hdc")) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Invalid cdrom device name: %s"), target);
goto error;
}
if (device &&
- !strcmp((const char *)device, "cdrom"))
+ STREQ((const char *)device, "cdrom"))
disk->readonly = 1;
- if ((!device || !strcmp((const char *)device, "disk")) &&
- strncmp((const char *)target, "hd", 2) &&
- strncmp((const char *)target, "sd", 2) &&
- strncmp((const char *)target, "vd", 2)) {
+ if ((!device || STREQ((const char *)device, "disk")) &&
+ !STRPREFIX((const char *)target, "hd") &&
+ !STRPREFIX((const char *)target, "sd") &&
+ !STRPREFIX((const char *)target, "vd")) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Invalid harddisk device name: %s"), target);
goto error;
@@ -682,11 +682,11 @@ static int qemudParseDiskXML(virConnectP
if (!device)
disk->device = QEMUD_DISK_DISK;
- else if (!strcmp((const char *)device, "disk"))
+ else if (STREQ((const char *)device, "disk"))
disk->device = QEMUD_DISK_DISK;
- else if (!strcmp((const char *)device, "cdrom"))
+ else if (STREQ((const char *)device, "cdrom"))
disk->device = QEMUD_DISK_CDROM;
- else if (!strcmp((const char *)device, "floppy"))
+ else if (STREQ((const char *)device, "floppy"))
disk->device = QEMUD_DISK_FLOPPY;
else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -1376,9 +1376,9 @@ static int qemudParseInputXML(virConnect
goto error;
}
- if (!strcmp((const char *)type, "mouse")) {
+ if (STREQ((const char *)type, "mouse")) {
input->type = QEMU_INPUT_TYPE_MOUSE;
- } else if (!strcmp((const char *)type, "tablet")) {
+ } else if (STREQ((const char *)type, "tablet")) {
input->type = QEMU_INPUT_TYPE_TABLET;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -1388,7 +1388,7 @@ static int qemudParseInputXML(virConnect
}
if (bus) {
- if (!strcmp((const char*)bus, "ps2")) { /* Only allow mouse */
+ if (STREQ((const char*)bus, "ps2")) { /* Only allow mouse */
if (input->type == QEMU_INPUT_TYPE_TABLET) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("ps2 bus does not support %s input device"),
@@ -1396,7 +1396,7 @@ static int qemudParseInputXML(virConnect
goto error;
}
input->bus = QEMU_INPUT_BUS_PS2;
- } else if (!strcmp((const char *)bus, "usb")) { /* Allow mouse & keyboard */
+ } else if (STREQ((const char *)bus, "usb")) { /* Allow mouse & keyboard */
input->bus = QEMU_INPUT_BUS_USB;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -1537,11 +1537,11 @@ static struct qemud_vm_def *qemudParseXM
goto error;
}
- if (!strcmp((char *)prop, "qemu"))
+ if (STREQ((char *)prop, "qemu"))
def->virtType = QEMUD_VIRT_QEMU;
- else if (!strcmp((char *)prop, "kqemu"))
+ else if (STREQ((char *)prop, "kqemu"))
def->virtType = QEMUD_VIRT_KQEMU;
- else if (!strcmp((char *)prop, "kvm"))
+ else if (STREQ((char *)prop, "kvm"))
def->virtType = QEMUD_VIRT_KVM;
else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -1654,7 +1654,7 @@ static struct qemud_vm_def *qemudParseXM
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
def->noReboot = 0;
} else {
- if (!strcmp((char*)obj->stringval, "destroy"))
+ if (STREQ((char*)obj->stringval, "destroy"))
def->noReboot = 1;
else
def->noReboot = 0;
@@ -1667,7 +1667,7 @@ static struct qemud_vm_def *qemudParseXM
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
def->localtime = 0;
} else {
- if (!strcmp((char*)obj->stringval, "localtime"))
+ if (STREQ((char*)obj->stringval, "localtime"))
def->localtime = 1;
else
def->localtime = 0;
@@ -1791,13 +1791,13 @@ static struct qemud_vm_def *qemudParseXM
for (i = 0; i < obj->nodesetval->nodeNr && i < QEMUD_MAX_BOOT_DEVS ; i++) {
if (!(prop = xmlGetProp(obj->nodesetval->nodeTab[i], BAD_CAST "dev")))
continue;
- if (!strcmp((char *)prop, "hd")) {
+ if (STREQ((char *)prop, "hd")) {
def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_DISK;
- } else if (!strcmp((char *)prop, "fd")) {
+ } else if (STREQ((char *)prop, "fd")) {
def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_FLOPPY;
- } else if (!strcmp((char *)prop, "cdrom")) {
+ } else if (STREQ((char *)prop, "cdrom")) {
def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_CDROM;
- } else if (!strcmp((char *)prop, "network")) {
+ } else if (STREQ((char *)prop, "network")) {
def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_NET;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -1849,7 +1849,7 @@ static struct qemud_vm_def *qemudParseXM
(obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0)) {
def->graphicsType = QEMUD_GRAPHICS_NONE;
} else if ((prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "type"))) {
- if (!strcmp((char *)prop, "vnc")) {
+ if (STREQ((char *)prop, "vnc")) {
xmlChar *vncport, *vnclisten;
def->graphicsType = QEMUD_GRAPHICS_VNC;
vncport = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "port");
@@ -1868,7 +1868,7 @@ static struct qemud_vm_def *qemudParseXM
def->keymap = (char *) xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "keymap");
xmlFree(vncport);
xmlFree(vnclisten);
- } else if (!strcmp((char *)prop, "sdl")) {
+ } else if (STREQ((char *)prop, "sdl")) {
def->graphicsType = QEMUD_GRAPHICS_SDL;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -2318,7 +2318,7 @@ int qemudBuildCommandLine(virConnectPtr
* 3. The qemu binary has the -no-kqemu flag
*/
if ((vm->qemuCmdFlags & QEMUD_CMD_FLAG_KQEMU) &&
- !strcmp(ut.machine, vm->def->os.arch) &&
+ STREQ(ut.machine, vm->def->os.arch) &&
vm->def->virtType == QEMUD_VIRT_QEMU)
disableKQEMU = 1;
Index: src/remote_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/remote_internal.c,v
retrieving revision 1.71
diff -u -p -u -p -r1.71 remote_internal.c
--- src/remote_internal.c 1 May 2008 18:11:03 -0000 1.71
+++ src/remote_internal.c 9 May 2008 21:08:09 -0000
@@ -316,15 +316,15 @@ doRemoteOpen (virConnectPtr conn,
trans_tcp,
} transport;
- if (!transport_str || strcasecmp (transport_str, "tls") == 0)
+ if (!transport_str || STRCASEEQ (transport_str, "tls"))
transport = trans_tls;
- else if (strcasecmp (transport_str, "unix") == 0)
+ else if (STRCASEEQ (transport_str, "unix"))
transport = trans_unix;
- else if (strcasecmp (transport_str, "ssh") == 0)
+ else if (STRCASEEQ (transport_str, "ssh"))
transport = trans_ssh;
- else if (strcasecmp (transport_str, "ext") == 0)
+ else if (STRCASEEQ (transport_str, "ext"))
transport = trans_ext;
- else if (strcasecmp (transport_str, "tcp") == 0)
+ else if (STRCASEEQ (transport_str, "tcp"))
transport = trans_tcp;
else {
error (conn, VIR_ERR_INVALID_ARG,
Index: src/sexpr.c
===================================================================
RCS file: /data/cvs/libvirt/src/sexpr.c,v
retrieving revision 1.19
diff -u -p -u -p -r1.19 sexpr.c
--- src/sexpr.c 9 May 2008 13:50:14 -0000 1.19
+++ src/sexpr.c 9 May 2008 21:08:09 -0000
@@ -433,7 +433,7 @@ sexpr_lookup_key(const struct sexpr *sex
return NULL;
}
- if (strcmp(sexpr->u.s.car->u.value, token) != 0) {
+ if (STRNEQ(sexpr->u.s.car->u.value, token)) {
return NULL;
}
@@ -451,7 +451,7 @@ sexpr_lookup_key(const struct sexpr *sex
continue;
}
- if (strcmp(i->u.s.car->u.s.car->u.value, token) == 0) {
+ if (STREQ(i->u.s.car->u.s.car->u.value, token)) {
sexpr = i->u.s.car;
break;
}
Index: src/test.c
===================================================================
RCS file: /data/cvs/libvirt/src/test.c,v
retrieving revision 1.73
diff -u -p -u -p -r1.73 test.c
--- src/test.c 28 Apr 2008 15:14:59 -0000 1.73
+++ src/test.c 9 May 2008 21:08:09 -0000
@@ -196,13 +196,13 @@ testError(virConnectPtr con,
}
static int testRestartStringToFlag(const char *str) {
- if (!strcmp(str, "restart")) {
+ if (STREQ(str, "restart")) {
return VIR_DOMAIN_RESTART;
- } else if (!strcmp(str, "destroy")) {
+ } else if (STREQ(str, "destroy")) {
return VIR_DOMAIN_DESTROY;
- } else if (!strcmp(str, "preserve")) {
+ } else if (STREQ(str, "preserve")) {
return VIR_DOMAIN_PRESERVE;
- } else if (!strcmp(str, "rename-restart")) {
+ } else if (STREQ(str, "rename-restart")) {
return VIR_DOMAIN_RENAME_RESTART;
} else {
return (0);
@@ -914,7 +914,7 @@ static int testOpen(virConnectPtr conn,
if (!uri)
return VIR_DRV_OPEN_DECLINED;
- if (!uri->scheme || strcmp(uri->scheme, "test") != 0)
+ if (!uri->scheme || STRNEQ(uri->scheme, "test"))
return VIR_DRV_OPEN_DECLINED;
/* Remote driver should handle these. */
@@ -1170,7 +1170,7 @@ static virDomainPtr testLookupDomainByNa
for (i = 0 ; i < MAX_DOMAINS ; i++) {
if (privconn->domains[i].active &&
- strcmp(name, privconn->domains[i].name) == 0) {
+ STREQ(name, privconn->domains[i].name)) {
idx = i;
break;
}
@@ -1767,7 +1767,7 @@ static virNetworkPtr testLookupNetworkBy
for (i = 0 ; i < MAX_NETWORKS ; i++) {
if (privconn->networks[i].active &&
- strcmp(name, privconn->networks[i].name) == 0) {
+ STREQ(name, privconn->networks[i].name)) {
idx = i;
break;
}
Index: src/util.c
===================================================================
RCS file: /data/cvs/libvirt/src/util.c,v
retrieving revision 1.36
diff -u -p -u -p -r1.36 util.c
--- src/util.c 9 May 2008 16:41:20 -0000 1.36
+++ src/util.c 9 May 2008 21:08:09 -0000
@@ -384,8 +384,8 @@ int virFileMatchesNameSuffix(const char
int suffixlen = strlen(suffix);
if (filelen == (namelen + suffixlen) &&
- !strncmp(file, name, namelen) &&
- !strncmp(file + namelen, suffix, suffixlen))
+ STREQLEN(file, name, namelen) &&
+ STREQLEN(file + namelen, suffix, suffixlen))
return 1;
else
return 0;
@@ -400,7 +400,7 @@ int virFileHasSuffix(const char *str,
if (len < suffixlen)
return 0;
- return strcmp(str + len - suffixlen, suffix) == 0;
+ return STREQ(str + len - suffixlen, suffix);
}
#ifndef __MINGW32__
@@ -479,7 +479,7 @@ int virFileLinkPointsTo(const char *chec
}
/* compare */
- if (strcmp(checkReal, real) != 0) {
+ if (STRNEQ(checkReal, real)) {
virLog("Link '%s' does not point to '%s', ignoring",
checkLink, checkReal);
return 0;
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.149
diff -u -p -u -p -r1.149 virsh.c
--- src/virsh.c 9 May 2008 13:50:14 -0000 1.149
+++ src/virsh.c 9 May 2008 21:08:09 -0000
@@ -4351,7 +4351,7 @@ cmdVNCDisplay(vshControl * ctl, vshCmd *
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/graphics[@type='vnc']/@listen)", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0) ||
- !strcmp((const char*)obj->stringval, "0.0.0.0")) {
+ STREQ((const char*)obj->stringval, "0.0.0.0")) {
vshPrint(ctl, ":%d\n", port-5900);
} else {
vshPrint(ctl, "%s:%d\n", (const char *)obj->stringval, port-5900);
@@ -4587,9 +4587,9 @@ cmdAttachInterface(vshControl * ctl, vsh
script = vshCommandOptString(cmd, "script", NULL);
/* check interface type */
- if (strcmp(type, "network") == 0) {
+ if (STREQ(type, "network")) {
typ = 1;
- } else if (strcmp(type, "bridge") == 0) {
+ } else if (STREQ(type, "bridge")) {
typ = 2;
} else {
vshError(ctl, FALSE, _("No support %s in command 'attach-interface'"), type);
@@ -4824,23 +4824,23 @@ cmdAttachDisk(vshControl * ctl, vshCmd *
mode = vshCommandOptString(cmd, "mode", NULL);
if (type) {
- if (strcmp(type, "cdrom") && strcmp(type, "disk")) {
+ if (STRNEQ(type, "cdrom") && STRNEQ(type, "disk")) {
vshError(ctl, FALSE, _("No support %s in command 'attach-disk'"), type);
goto cleanup;
}
}
if (driver) {
- if (!strcmp(driver, "file") || !strcmp(driver, "tap")) {
+ if (STREQ(driver, "file") || STREQ(driver, "tap")) {
isFile = 1;
- } else if (strcmp(driver, "phy")) {
+ } else if (STRNEQ(driver, "phy")) {
vshError(ctl, FALSE, _("No support %s in command 'attach-disk'"), driver);
goto cleanup;
}
}
if (mode) {
- if (strcmp(mode, "readonly") && strcmp(mode, "shareable")) {
+ if (STRNEQ(mode, "readonly") && STRNEQ(mode, "shareable")) {
vshError(ctl, FALSE, _("No support %s in command 'attach-disk'"), mode);
goto cleanup;
}
@@ -5171,7 +5171,7 @@ vshCmddefGetInfo(vshCmdDef * cmd, const
vshCmdInfo *info;
for (info = cmd->info; info && info->name; info++) {
- if (strcmp(info->name, name) == 0)
+ if (STREQ(info->name, name))
return info->data;
}
return NULL;
@@ -5183,7 +5183,7 @@ vshCmddefGetOption(vshCmdDef * cmd, cons
vshCmdOptDef *opt;
for (opt = cmd->opts; opt && opt->name; opt++)
- if (strcmp(opt->name, name) == 0)
+ if (STREQ(opt->name, name))
return opt;
return NULL;
}
@@ -5244,7 +5244,7 @@ vshCmddefSearch(const char *cmdname)
vshCmdDef *c;
for (c = commands; c->name; c++)
- if (strcmp(c->name, cmdname) == 0)
+ if (STREQ(c->name, cmdname))
return c;
return NULL;
}
@@ -5343,7 +5343,7 @@ vshCommandOpt(vshCmd * cmd, const char *
vshCmdOpt *opt = cmd->opts;
while (opt) {
- if (opt->def && strcmp(opt->def->name, name) == 0)
+ if (opt->def && STREQ(opt->def->name, name))
return opt;
opt = opt->next;
}
@@ -5617,7 +5617,7 @@ vshCommandRun(vshControl * ctl, vshCmd *
if (ctl->timing)
GETTIMEOFDAY(&after);
- if (strcmp(cmd->def->name, "quit") == 0) /* hack ... */
+ if (STREQ(cmd->def->name, "quit")) /* hack ... */
return ret;
if (ctl->timing)
@@ -6213,7 +6213,7 @@ vshReadlineCommandGenerator(const char *
*/
while ((name = commands[list_index].name)) {
list_index++;
- if (strncmp(name, text, len) == 0)
+ if (STREQLEN(name, text, len))
return vshStrdup(NULL, name);
}
@@ -6262,7 +6262,7 @@ vshReadlineOptionsGenerator(const char *
continue;
if (len > 2) {
- if (strncmp(name, text + 2, len - 2))
+ if (STRNEQLEN(name, text + 2, len - 2))
continue;
}
res = vshMalloc(NULL, strlen(name) + 3);
@@ -6435,7 +6435,7 @@ vshParseArgv(vshControl * ctl, int argc,
if (sz == 2 && *(last + 1) == o->val)
/* valid virsh short option */
valid = TRUE;
- else if (sz > 2 && strcmp(o->name, last + 2) == 0)
+ else if (sz > 2 && STREQ(o->name, last + 2))
/* valid virsh long option */
valid = TRUE;
}
Index: src/xen_unified.c
===================================================================
RCS file: /data/cvs/libvirt/src/xen_unified.c,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 xen_unified.c
--- src/xen_unified.c 9 May 2008 08:17:19 -0000 1.43
+++ src/xen_unified.c 9 May 2008 21:08:09 -0000
@@ -245,8 +245,8 @@ xenUnifiedOpen (virConnectPtr conn, xmlU
/* Refuse any scheme which isn't "xen://" or "http://". */
if (uri->scheme &&
- strcasecmp(uri->scheme, "xen") != 0 &&
- strcasecmp(uri->scheme, "http") != 0)
+ STRCASENEQ(uri->scheme, "xen") &&
+ STRCASENEQ(uri->scheme, "http"))
return VIR_DRV_OPEN_DECLINED;
/* xmlParseURI will parse a naked string like "foo" as a URI with
@@ -258,7 +258,7 @@ xenUnifiedOpen (virConnectPtr conn, xmlU
return VIR_DRV_OPEN_DECLINED;
/* Refuse any xen:// URI with a server specified - allow remote to do it */
- if (uri->scheme && strcasecmp(uri->scheme, "xen") == 0 && uri->server)
+ if (uri->scheme && STRCASEEQ(uri->scheme, "xen") && uri->server)
return VIR_DRV_OPEN_DECLINED;
/* Allocate per-connection private data. */
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.189
diff -u -p -u -p -r1.189 xend_internal.c
--- src/xend_internal.c 9 May 2008 13:50:14 -0000 1.189
+++ src/xend_internal.c 9 May 2008 21:08:09 -0000
@@ -403,7 +403,7 @@ sreads(virConnectPtr xend, int fd, char
static int
istartswith(const char *haystack, const char *needle)
{
- return (strncasecmp(haystack, needle, strlen(needle)) == 0);
+ return STRCASEEQLEN(haystack, needle, strlen(needle));
}
@@ -426,7 +426,7 @@ xend_req(virConnectPtr xend, int fd, cha
int retcode = 0;
while (sreads(xend, fd, buffer, sizeof(buffer)) > 0) {
- if (strcmp(buffer, "\r\n") == 0)
+ if (STREQ(buffer, "\r\n"))
break;
if (istartswith(buffer, "Content-Length: "))
@@ -487,7 +487,7 @@ xend_get(virConnectPtr xend, const char
close(s);
if (((ret < 0) || (ret >= 300)) &&
- ((ret != 404) || (strncmp(path, "/xend/domain/", 13)))) {
+ ((ret != 404) || (STRNEQLEN(path, "/xend/domain/", 13)))) {
virXendError(xend, VIR_ERR_GET_FAILED, content);
}
@@ -1882,7 +1882,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
/* There is a case without the uname to the CD-ROM device */
offset = strchr(dst, ':');
if (offset) {
- if (hvm && !strcmp( offset , ":cdrom")) {
+ if (hvm && STREQ( offset , ":cdrom")) {
isNoSrcCdrom = 1;
}
offset[0] = '\0';
@@ -1913,7 +1913,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
src = offset + 1;
- if (!strcmp(drvName, "tap")) {
+ if (STREQ(drvName, "tap")) {
offset = strchr(src, ':');
if (!offset) {
virXendError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -1936,23 +1936,23 @@ xend_parse_sexp_desc(virConnectPtr conn,
omnipotent, we can revisit this, perhaps stat()'ing
the src file in question */
isBlock = 0;
- } else if (!strcmp(drvName, "phy")) {
+ } else if (STREQ(drvName, "phy")) {
isBlock = 1;
- } else if (!strcmp(drvName, "file")) {
+ } else if (STREQ(drvName, "file")) {
isBlock = 0;
}
}
- if (!strncmp(dst, "ioemu:", 6))
+ if (STREQLEN(dst, "ioemu:", 6))
dst += 6;
/* New style disk config from Xen >= 3.0.3 */
if (xendConfigVersion > 1) {
offset = strrchr(dst, ':');
if (offset) {
- if (!strcmp(offset, ":cdrom")) {
+ if (STREQ(offset, ":cdrom")) {
cdrom = 1;
- } else if (!strcmp(offset, ":disk")) {
+ } else if (STREQ(offset, ":disk")) {
/* The default anyway */
} else {
/* Unknown, lets pretend its a disk too */
@@ -1993,9 +1993,9 @@ xend_parse_sexp_desc(virConnectPtr conn,
/* XXX should we force mode == r, if cdrom==1, or assume
xend has already done this ? */
- if ((mode != NULL) && (!strcmp(mode, "r")))
+ if ((mode != NULL) && (STREQ(mode, "r")))
virBufferAddLit(&buf, " <readonly/>\n");
- else if ((mode != NULL) && (!strcmp(mode, "w!")))
+ else if ((mode != NULL) && (STREQ(mode, "w!")))
virBufferAddLit(&buf, " <shareable/>\n");
virBufferAddLit(&buf, " </disk>\n");
@@ -2046,11 +2046,11 @@ xend_parse_sexp_desc(virConnectPtr conn,
* or for HVM guests in >= 3.0.5 */
tmp = sexpr_node(node, "device/vfb/type");
- if (tmp && !strcmp(tmp, "sdl")) {
+ if (tmp && STREQ(tmp, "sdl")) {
vfb = 1;
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen");
virBufferAddLit(&buf, " <graphics type='sdl'/>\n");
- } else if (tmp && !strcmp(tmp, "vnc")) {
+ } else if (tmp && STREQ(tmp, "vnc")) {
int port = xenStoreDomainGetVNCPort(conn, domid);
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
const char *vncPasswd = NULL;
@@ -2109,9 +2109,9 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (sexpr_lookup(node, "usbdevice")) {
tmp = sexpr_node(node, "usbdevice");
if (tmp && *tmp) {
- if (!strcmp(tmp, "tablet"))
+ if (STREQ(tmp, "tablet"))
virBufferAddLit(&buf, " <input type='tablet' bus='usb'/>\n");
- else if (!strcmp(tmp, "mouse"))
+ else if (STREQ(tmp, "mouse"))
virBufferAddLit(&buf, " <input type='mouse' bus='usb'/>\n");
}
}
@@ -2399,7 +2399,7 @@ sexpr_to_xend_topology(virConnectPtr con
goto parse_error;
cur++;
virSkipSpaces(&cur);
- if (!strncmp(cur, "no cpus", 7)) {
+ if (STREQLEN(cur, "no cpus", 7)) {
nb_cpus = 0;
for (cpu = 0; cpu < numCpus; cpu++)
cpuset[cpu] = 0;
@@ -3460,7 +3460,7 @@ xenDaemonDomainGetVcpus(virDomainPtr dom
for (s = root; s->kind == SEXPR_CONS; s = s->u.s.cdr) {
if ((s->u.s.car->kind == SEXPR_CONS) &&
(s->u.s.car->u.s.car->kind == SEXPR_VALUE) &&
- !strcmp(s->u.s.car->u.s.car->u.value, "vcpu")) {
+ STREQ(s->u.s.car->u.s.car->u.value, "vcpu")) {
t = s->u.s.car;
vcpu = ipt->number = sexpr_int(t, "vcpu/number");
if ((oln = sexpr_int(t, "vcpu/online")) != 0) {
@@ -3481,7 +3481,7 @@ xenDaemonDomainGetVcpus(virDomainPtr dom
for (t = t->u.s.cdr; t->kind == SEXPR_CONS; t = t->u.s.cdr)
if ((t->u.s.car->kind == SEXPR_CONS) &&
(t->u.s.car->u.s.car->kind == SEXPR_VALUE) &&
- !strcmp(t->u.s.car->u.s.car->u.value, "cpumap") &&
+ STREQ(t->u.s.car->u.s.car->u.value, "cpumap") &&
(t->u.s.car->u.s.cdr->kind == SEXPR_CONS)) {
for (t = t->u.s.car->u.s.cdr->u.s.car; t->kind == SEXPR_CONS; t = t->u.s.cdr)
if (t->u.s.car->kind == SEXPR_VALUE
@@ -3677,7 +3677,7 @@ xenDaemonAttachDevice(virDomainPtr domai
return (-1);
str = virDomainGetOSType(domain);
- if (strcmp(str, "linux"))
+ if (STREQ(str, "hvm"))
hvm = 1;
free(str);
sexpr = virParseXMLDevice(domain->conn, xml, hvm, priv->xendConfigVersion);
Index: src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.76
diff -u -p -u -p -r1.76 xm_internal.c
--- src/xm_internal.c 8 May 2008 14:41:56 -0000 1.76
+++ src/xm_internal.c 9 May 2008 21:08:10 -0000
@@ -304,7 +304,7 @@ static int xenXMConfigReaper(const void
is currently mapped as owner of a named domain. */
if (xenXMConfigGetString(entry->conf, "name", &olddomname) != -1) {
char *nameowner = (char *)virHashLookup(nameConfigMap, olddomname);
- if (nameowner && !strcmp(nameowner, key)) {
+ if (nameowner && STREQ(nameowner, key)) {
virHashRemoveEntry(nameConfigMap, olddomname, NULL);
}
}
@@ -353,19 +353,19 @@ static int xenXMConfigCacheRefresh (virC
*/
/* Like 'dot' files... */
- if (!strncmp(ent->d_name, ".", 1))
+ if (STREQLEN(ent->d_name, ".", 1))
continue;
/* ...and the XenD server config file */
- if (!strncmp(ent->d_name, XEND_CONFIG_FILE, strlen(XEND_CONFIG_FILE)))
+ if (STREQLEN(ent->d_name, XEND_CONFIG_FILE, strlen(XEND_CONFIG_FILE)))
continue;
/* ...and random PCI config cruft */
- if (!strncmp(ent->d_name, XEND_PCI_CONFIG_PREFIX, strlen(XEND_PCI_CONFIG_PREFIX)))
+ if (STREQLEN(ent->d_name, XEND_PCI_CONFIG_PREFIX, strlen(XEND_PCI_CONFIG_PREFIX)))
continue;
/* ...and the example domain configs */
- if (!strncmp(ent->d_name, XM_EXAMPLE_PREFIX, strlen(XM_EXAMPLE_PREFIX)))
+ if (STREQLEN(ent->d_name, XM_EXAMPLE_PREFIX, strlen(XM_EXAMPLE_PREFIX)))
continue;
/* ...and the QEMU networking script */
- if (!strncmp(ent->d_name, QEMU_IF_SCRIPT, strlen(QEMU_IF_SCRIPT)))
+ if (STREQLEN(ent->d_name, QEMU_IF_SCRIPT, strlen(QEMU_IF_SCRIPT)))
continue;
/* ...and editor backups */
@@ -401,7 +401,7 @@ static int xenXMConfigCacheRefresh (virC
re-acquire it later - just in case it was renamed */
if (xenXMConfigGetString(entry->conf, "name", &olddomname) != -1) {
char *nameowner = (char *)virHashLookup(nameConfigMap, olddomname);
- if (nameowner && !strcmp(nameowner, path)) {
+ if (nameowner && STREQ(nameowner, path)) {
virHashRemoveEntry(nameConfigMap, olddomname, NULL);
}
}
@@ -607,7 +607,7 @@ char *xenXMDomainFormatXML(virConnectPtr
virBufferVSprintf(&buf, " <uuid>%s</uuid>\n", uuidstr);
if ((xenXMConfigGetString(conf, "builder", &str) == 0) &&
- !strcmp(str, "hvm"))
+ STREQ(str, "hvm"))
hvm = 1;
if (hvm) {
@@ -778,7 +778,7 @@ char *xenXMDomainFormatXML(virConnectPtr
}
/* And the source driver sub-type */
- if (!strncmp(drvName, "tap", 3)) {
+ if (STREQLEN(drvName, "tap", 3)) {
if (!(tmp1 = strchr(tmp+1, ':')) || !tmp1[0])
goto skipdisk;
strncpy(drvType, tmp+1, (tmp1-(tmp+1)));
@@ -790,18 +790,18 @@ char *xenXMDomainFormatXML(virConnectPtr
}
/* phy: type indicates a block device */
- if (!strcmp(drvName, "phy")) {
+ if (STREQ(drvName, "phy")) {
block = 1;
}
/* Remove legacy ioemu: junk */
- if (!strncmp(dev, "ioemu:", 6)) {
+ if (STREQLEN(dev, "ioemu:", 6)) {
memmove(dev, dev+6, strlen(dev)-5);
}
/* Check for a :cdrom/:disk postfix */
if ((tmp = strchr(dev, ':')) != NULL) {
- if (!strcmp(tmp, ":cdrom"))
+ if (STREQ(tmp, ":cdrom"))
cdrom = 1;
tmp[0] = '\0';
}
@@ -824,11 +824,11 @@ char *xenXMDomainFormatXML(virConnectPtr
if (src[0])
virBufferVSprintf(&buf, " <source %s='%s'/>\n", block ? "dev" : "file", src);
virBufferVSprintf(&buf, " <target dev='%s' bus='%s'/>\n", dev, bus);
- if (!strcmp(head, "r") ||
- !strcmp(head, "ro"))
+ if (STREQ(head, "r") ||
+ STREQ(head, "ro"))
virBufferAddLit(&buf, " <readonly/>\n");
- else if ((!strcmp(head, "w!")) ||
- (!strcmp(head, "!")))
+ else if ((STREQ(head, "w!")) ||
+ (STREQ(head, "!")))
virBufferAddLit(&buf, " <shareable/>\n");
virBufferAddLit(&buf, " </disk>\n");
@@ -878,32 +878,32 @@ char *xenXMDomainFormatXML(virConnectPtr
goto skipnic;
data++;
- if (!strncmp(key, "mac=", 4)) {
+ if (STRPREFIX(key, "mac=")) {
int len = nextkey ? (nextkey - data) : 17;
if (len > 17)
len = 17;
strncpy(mac, data, len);
mac[len] = '\0';
- } else if (!strncmp(key, "bridge=", 7)) {
+ } else if (STRPREFIX(key, "bridge=")) {
int len = nextkey ? (nextkey - data) : sizeof(bridge)-1;
type = 1;
if (len > (sizeof(bridge)-1))
len = sizeof(bridge)-1;
strncpy(bridge, data, len);
bridge[len] = '\0';
- } else if (!strncmp(key, "script=", 7)) {
+ } else if (STRPREFIX(key, "script=")) {
int len = nextkey ? (nextkey - data) : PATH_MAX-1;
if (len > (PATH_MAX-1))
len = PATH_MAX-1;
strncpy(script, data, len);
script[len] = '\0';
- } else if (!strncmp(key, "model=", 6)) {
+ } else if (STRPREFIX(key, "model=")) {
int len = nextkey ? (nextkey - data) : sizeof(model)-1;
if (len > (sizeof(model)-1))
len = sizeof(model)-1;
strncpy(model, data, len);
model[len] = '\0';
- } else if (!strncmp(key, "ip=", 3)) {
+ } else if (STRPREFIX(key, "ip=")) {
int len = nextkey ? (nextkey - data) : 15;
if (len > 15)
len = 15;
@@ -943,9 +943,9 @@ char *xenXMDomainFormatXML(virConnectPtr
if (hvm) {
if (xenXMConfigGetString(conf, "usbdevice", &str) == 0 && str) {
- if (!strcmp(str, "tablet"))
+ if (STREQ(str, "tablet"))
virBufferAddLit(&buf, " <input type='tablet' bus='usb'/>\n");
- else if (!strcmp(str, "mouse"))
+ else if (STREQ(str, "mouse"))
virBufferAddLit(&buf, " <input type='mouse' bus='usb'/>\n");
/* Ignore else branch - probably some other non-input device we don't
support in libvirt yet */
@@ -993,19 +993,19 @@ char *xenXMDomainFormatXML(virConnectPtr
break;
data++;
- if (!strncmp(key, "type=sdl", 8)) {
+ if (STRPREFIX(key, "type=sdl")) {
sdl = 1;
- } else if (!strncmp(key, "type=vnc", 8)) {
+ } else if (STRPREFIX(key, "type=vnc")) {
vnc = 1;
- } else if (!strncmp(key, "vncunused=", 10)) {
+ } else if (STRPREFIX(key, "vncunused=")) {
vncunused = strtol(key+10, NULL, 10);
- } else if (!strncmp(key, "vnclisten=", 10)) {
+ } else if (STRPREFIX(key, "vnclisten=")) {
vnclisten = key + 10;
- } else if (!strncmp(key, "vncpasswd=", 10)) {
+ } else if (STRPREFIX(key, "vncpasswd=")) {
vncpasswd = key + 10;
- } else if (!strncmp(key, "keymap=", 7)) {
+ } else if (STRPREFIX(key, "keymap=")) {
keymap = key + 7;
- } else if (!strncmp(key, "vncdisplay=", 11)) {
+ } else if (STRPREFIX(key, "vncdisplay=")) {
vncdisplay = strtol(key+11, NULL, 10);
}
@@ -1682,7 +1682,7 @@ static int xenXMParseXMLDisk(xmlNodePtr
} else if ((drvName == NULL) &&
(xmlStrEqual(cur->name, BAD_CAST "driver"))) {
drvName = xmlGetProp(cur, BAD_CAST "name");
- if (drvName && !strcmp((const char *)drvName, "tap"))
+ if (drvName && STREQ((const char *)drvName, "tap"))
drvType = xmlGetProp(cur, BAD_CAST "type");
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
readonly = 1;
@@ -1704,7 +1704,7 @@ static int xenXMParseXMLDisk(xmlNodePtr
*/
if (hvm &&
device &&
- !strcmp((const char *)device, "floppy")) {
+ STREQ((const char *)device, "floppy")) {
ret = 0;
goto cleanup;
}
@@ -1712,7 +1712,7 @@ static int xenXMParseXMLDisk(xmlNodePtr
/* Xend <= 3.0.2 doesn't include cdrom config here */
if (hvm &&
device &&
- !strcmp((const char *)device, "cdrom")) {
+ STREQ((const char *)device, "cdrom")) {
if (xendConfigVersion == 1) {
ret = 0;
goto cleanup;
@@ -1729,7 +1729,7 @@ static int xenXMParseXMLDisk(xmlNodePtr
if (drvName) {
buflen += strlen((const char*)drvName) + 1;
- if (!strcmp((const char*)drvName, "tap")) {
+ if (STREQ((const char*)drvName, "tap")) {
if (drvType)
buflen += strlen((const char*)drvType) + 1;
else
@@ -1761,7 +1761,7 @@ static int xenXMParseXMLDisk(xmlNodePtr
if(source) {
if (drvName) {
strcpy(buf, (const char*)drvName);
- if (!strcmp((const char*)drvName, "tap")) {
+ if (STREQ((const char*)drvName, "tap")) {
strcat(buf, ":");
if (drvType)
strcat(buf, (const char*)drvType);
@@ -2024,7 +2024,7 @@ virConfPtr xenXMParseXMLToConfig(virConn
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type)", ctxt);
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
- (obj->stringval != NULL) && !strcmp((char*)obj->stringval, "hvm"))
+ (obj->stringval != NULL) && STREQ((char*)obj->stringval, "hvm"))
hvm = 1;
xmlXPathFreeObject(obj);
@@ -2043,11 +2043,11 @@ virConfPtr xenXMParseXMLToConfig(virConn
obj = xmlXPathEval(BAD_CAST "string(/domain/os/boot/@dev)", ctxt);
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL)) {
- if (!strcmp((const char*)obj->stringval, "fd"))
+ if (STREQ((const char*)obj->stringval, "fd"))
boot = "a";
- else if (!strcmp((const char*)obj->stringval, "hd"))
+ else if (STREQ((const char*)obj->stringval, "hd"))
boot = "c";
- else if (!strcmp((const char*)obj->stringval, "cdrom"))
+ else if (STREQ((const char*)obj->stringval, "cdrom"))
boot = "d";
}
xmlXPathFreeObject(obj);
@@ -2069,7 +2069,7 @@ virConfPtr xenXMParseXMLToConfig(virConn
obj = xmlXPathEval(BAD_CAST "string(/domain/clock/@offset)", ctxt);
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL)) {
- if (!strcmp((const char*)obj->stringval, "localtime"))
+ if (STREQ((const char*)obj->stringval, "localtime"))
clockLocal = 1;
}
xmlXPathFreeObject(obj);
@@ -2173,15 +2173,15 @@ virConfPtr xenXMParseXMLToConfig(virConn
if (!(type = xmlGetProp(obj->nodesetval->nodeTab[i], BAD_CAST "type"))) {
continue;
}
- if (!strcmp((const char*)type, "sdl")) {
+ if (STREQ((const char*)type, "sdl")) {
val = strdup("type=sdl");
- } else if (!strcmp((const char*)type, "vnc")) {
+ } else if (STREQ((const char*)type, "vnc")) {
int len = 8 + 1; /* type=vnc & NULL */
xmlChar *vncport = xmlGetProp(obj->nodesetval->nodeTab[i], BAD_CAST "port");
xmlChar *vnclisten = xmlGetProp(obj->nodesetval->nodeTab[i], BAD_CAST "listen");
xmlChar *vncpasswd = xmlGetProp(obj->nodesetval->nodeTab[i], BAD_CAST "passwd");
xmlChar *keymap = xmlGetProp(obj->nodesetval->nodeTab[i], BAD_CAST "keymap");
- int vncunused = vncport ? (!strcmp((const char*)vncport, "-1") ? 1 : 0) : 1;
+ int vncunused = vncport ? (STREQ((const char*)vncport, "-1") ? 1 : 0) : 1;
if (vncunused)
len += 12;
else
@@ -2743,9 +2743,9 @@ xenXMAttachDisk(virDomainPtr domain, xml
xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
goto cleanup;
}
- if (!strcmp((const char *) type, "block"))
+ if (STREQ((const char *) type, "block"))
source = xmlGetProp(node, BAD_CAST "dev");
- else if (!strcmp((const char *) type, "file"))
+ else if (STREQ((const char *) type, "file"))
source = xmlGetProp(node, BAD_CAST "file");
else {
xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
@@ -2788,7 +2788,7 @@ xenXMAttachDisk(virDomainPtr domain, xml
head = offset + 1;
/* Remove legacy ioemu: junk */
- if (!strncmp(domdev, "ioemu:", 6)) {
+ if (STRPREFIX(domdev, "ioemu:")) {
memmove(domdev, domdev+6, strlen(domdev)-5);
}
@@ -2796,7 +2796,7 @@ xenXMAttachDisk(virDomainPtr domain, xml
if ((tmp = strchr(domdev, ':')))
tmp[0] = '\0';
- if (!(strcmp(domdev, (const char *) target)))
+ if (STREQ(domdev, (const char *) target))
break;
skip:
prev = list_val;
@@ -2895,7 +2895,7 @@ xenXMAttachInterface(virDomainPtr domain
goto skip;
data++;
- if (!strncmp(key, "mac=", 4)) {
+ if (STRPREFIX(key, "mac=")) {
int len = nextkey ? (nextkey - data) : 17;
if (len > 17)
len = 17;
@@ -3114,7 +3114,7 @@ xenXMDomainDetachDevice(virDomainPtr dom
else if (list_ptr && list_ptr->type == VIR_CONF_LIST) {
list_val = list_ptr->list;
while (list_val) {
- if (!(strcmp(device, "disk"))) {
+ if (STREQ(device, "disk")) {
char domdev[NAME_MAX];
char *head;
char *offset;
@@ -3141,7 +3141,7 @@ xenXMDomainDetachDevice(virDomainPtr dom
head = offset + 1;
/* Remove legacy ioemu: junk */
- if (!strncmp(domdev, "ioemu:", 6)) {
+ if (STRPREFIX(domdev, "ioemu:")) {
memmove(domdev, domdev+6, strlen(domdev)-5);
}
@@ -3149,7 +3149,7 @@ xenXMDomainDetachDevice(virDomainPtr dom
if ((tmp = strchr(domdev, ':')))
tmp[0] = '\0';
- if (!(strcmp(domdev, (const char *) key)))
+ if (STREQ(domdev, (const char *) key))
break;
} else {
char dommac[18];
@@ -3169,7 +3169,7 @@ xenXMDomainDetachDevice(virDomainPtr dom
goto skip;
data++;
- if (!strncmp(mac, "mac=", 4)) {
+ if (STRPREFIX(mac, "mac=")) {
int len = nextmac ? (nextmac - data) : 17;
if (len > 17)
len = 17;
Index: src/xml.c
===================================================================
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.123
diff -u -p -u -p -r1.123 xml.c
--- src/xml.c 7 May 2008 18:50:23 -0000 1.123
+++ src/xml.c 9 May 2008 21:08:10 -0000
@@ -1083,9 +1083,9 @@ virDomainParseXMLOSDescHVM(virConnectPtr
if (!itype) {
goto error;
}
- if (!strcmp((const char *) itype, "tablet"))
+ if (STREQ((const char *) itype, "tablet"))
isMouse = 0;
- else if (strcmp((const char *) itype, "mouse")) {
+ else if (STRNEQ((const char *) itype, "mouse")) {
xmlFree(itype);
virXMLError(conn, VIR_ERR_XML_ERROR,
_("invalid input device"), 0);
@@ -1101,7 +1101,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr
virBufferAddLit(buf, "(usbdevice tablet)");
}
} else {
- if (!strcmp((const char *) bus, "ps2")) {
+ if (STREQ((const char *) bus, "ps2")) {
if (!isMouse) {
xmlFree(bus);
virXMLError(conn, VIR_ERR_XML_ERROR,
@@ -1109,7 +1109,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr
goto error;
}
/* Nothing - implicit ps2 */
- } else if (!strcmp((const char *) bus, "usb")) {
+ } else if (STREQ((const char *) bus, "usb")) {
if (isMouse)
virBufferAddLit(buf, "(usbdevice mouse)");
else
@@ -1320,7 +1320,7 @@ virDomainParseXMLDiskDesc(virConnectPtr
} else if ((drvName == NULL) &&
(xmlStrEqual(cur->name, BAD_CAST "driver"))) {
drvName = xmlGetProp(cur, BAD_CAST "name");
- if (drvName && !strcmp((const char *) drvName, "tap"))
+ if (drvName && STREQ((const char *) drvName, "tap"))
drvType = xmlGetProp(cur, BAD_CAST "type");
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
ro = 1;
@@ -1335,7 +1335,7 @@ virDomainParseXMLDiskDesc(virConnectPtr
/* There is a case without the source
* to the CD-ROM device
*/
- if (hvm && device && !strcmp((const char *) device, "cdrom")) {
+ if (hvm && device && STREQ((const char *) device, "cdrom")) {
isNoSrcCdrom = 1;
}
if (!isNoSrcCdrom) {
@@ -1353,12 +1353,12 @@ virDomainParseXMLDiskDesc(virConnectPtr
/* Xend (all versions) put the floppy device config
* under the hvm (image (os)) block
*/
- if (hvm && device && !strcmp((const char *) device, "floppy")) {
+ if (hvm && device && STREQ((const char *) device, "floppy")) {
goto cleanup;
}
/* Xend <= 3.0.2 doesn't include cdrom config here */
- if (hvm && device && !strcmp((const char *) device, "cdrom")) {
+ if (hvm && device && STREQ((const char *) device, "cdrom")) {
if (xendConfigVersion == 1)
goto cleanup;
else
@@ -1370,7 +1370,7 @@ virDomainParseXMLDiskDesc(virConnectPtr
/* 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")) {
+ if (drvName && STREQ((const char *) drvName, "tap")) {
virBufferAddLit(buf, "(tap ");
} else {
virBufferAddLit(buf, "(vbd ");
@@ -1380,7 +1380,7 @@ virDomainParseXMLDiskDesc(virConnectPtr
char *tmp = (char *) target;
/* Just in case user mistakenly still puts ioemu: in their XML */
- if (!strncmp((const char *) tmp, "ioemu:", 6))
+ if (STRPREFIX((const char *) tmp, "ioemu:"))
tmp += 6;
/* Xend <= 3.0.2 wants a ioemu: prefix on devices for HVM */
@@ -1393,7 +1393,7 @@ virDomainParseXMLDiskDesc(virConnectPtr
virBufferVSprintf(buf, "(dev '%s')", (const char *) target);
if (drvName && !isNoSrcCdrom) {
- if (!strcmp((const char *) drvName, "tap")) {
+ if (STREQ((const char *) drvName, "tap")) {
virBufferVSprintf(buf, "(uname '%s:%s:%s')",
(const char *) drvName,
(drvType ? (const char *) drvType : "aio"),
Index: src/xmlrpc.c
===================================================================
RCS file: /data/cvs/libvirt/src/xmlrpc.c,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 xmlrpc.c
--- src/xmlrpc.c 28 Apr 2008 15:14:59 -0000 1.14
+++ src/xmlrpc.c 9 May 2008 21:08:10 -0000
@@ -429,7 +429,7 @@ static char *xmlRpcCallRaw(const char *u
goto error;
}
- if (contentType && strcmp(contentType, "text/xml") != 0) {
+ if (contentType && STRNEQ(contentType, "text/xml")) {
errno = EINVAL;
xmlRpcError(VIR_ERR_POST_FAILED, _("unexpected mime type"), 0);
goto error;
Index: tests/virshtest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/virshtest.c,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 virshtest.c
--- tests/virshtest.c 10 Apr 2008 16:54:54 -0000 1.11
+++ tests/virshtest.c 9 May 2008 21:08:10 -0000
@@ -52,8 +52,10 @@ static int testCompareOutput(const char
printf("Expect %d '%s'\n", (int)strlen(expectData), expectData);
printf("Actual %d '%s'\n", (int)strlen(actualData), actualData);
}
- if (strcmp(expectData, actualData))
- return -1;
+ if (STRNEQ(expectData, actualData)) {
+ virtTestDifference(stderr, expectData, actualData);
+ return -1;
+ }
return 0;
}
Index: tests/xml2sexprtest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/xml2sexprtest.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 xml2sexprtest.c
--- tests/xml2sexprtest.c 7 May 2008 14:04:41 -0000 1.27
+++ tests/xml2sexprtest.c 9 May 2008 21:08:10 -0000
@@ -43,7 +43,7 @@ static int testCompareFiles(const char *
goto fail;
}
- if (strcmp(name, gotname)) {
+ if (STRNEQ(name, gotname)) {
printf("Got wrong name: expected %s, got %s\n", name, gotname);
goto fail;
}
Index: tests/xmlrpctest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/xmlrpctest.c,v
retrieving revision 1.12
diff -u -p -u -p -r1.12 xmlrpctest.c
--- tests/xmlrpctest.c 28 Apr 2008 15:14:59 -0000 1.12
+++ tests/xmlrpctest.c 9 May 2008 21:08:10 -0000
@@ -108,7 +108,7 @@ checkRequestValue(const char *xmlstr, co
break;
case XML_RPC_STRING:
if ((obj->type != XPATH_STRING) ||
- (strcmp((const char *)obj->stringval, (const char *)expected)))
+ (STRNEQ((const char *)obj->stringval, (const char *)expected)))
goto error;
break;
default:
--
|: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years, 5 months
[libvirt] [PATCH] exempt gnulib/ from "make syntax-check" strcmp prohibition
by Jim Meyering
"make syntax-check" was failing. This fixed it:
exempt gnulib/ from "make syntax-check" strcmp prohibition
* .x-sc_prohibit_strcmp: New file.
* Makefile.am (EXTRA_DIST): Add .x-sc_prohibit_strcmp.
---
.x-sc_prohibit_strcmp | 1 +
Makefile.am | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 .x-sc_prohibit_strcmp
diff --git a/.x-sc_prohibit_strcmp b/.x-sc_prohibit_strcmp
new file mode 100644
index 0000000..b7c456e
--- /dev/null
+++ b/.x-sc_prohibit_strcmp
@@ -0,0 +1 @@
+^gnulib/
diff --git a/Makefile.am b/Makefile.am
index e32033a..73552a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,6 +10,7 @@ EXTRA_DIST = \
libvirt.pc libvirt.pc.in \
$(man_MANS) autobuild.sh \
.x-sc_avoid_if_before_free \
+ .x-sc_prohibit_strcmp \
.x-sc_require_config_h
man_MANS = virsh.1
--
1.5.5.1.216.g33c73
16 years, 5 months
[libvirt] PATCH: Fix KVM maximum vCPU count
by Daniel P. Berrange
Libvirt currently returns '1' when asked for the maximum number of VCPUs
supported for KVM guests. KVM long long ago gained SMP support, so this
patch fixes it to return 16, whcih is the current supported number. I
don't bother trying to detect old versions of KVM which are UP only
because I find it hard to believe anyone will be using them.
qemu_driver.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
Dan.
diff -r b644023b5657 src/qemu_driver.c
--- a/src/qemu_driver.c Sat May 10 13:12:04 2008 -0400
+++ b/src/qemu_driver.c Sat May 10 13:12:18 2008 -0400
@@ -1572,10 +1572,8 @@
if (STRCASEEQ(type, "qemu"))
return 16;
- /* XXX future KVM will support SMP. Need to probe
- kernel to figure out KVM module version i guess */
if (STRCASEEQ(type, "kvm"))
- return 1;
+ return 16;
if (STRCASEEQ(type, "kqemu"))
return 1;
--
|: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years, 5 months
[libvirt] [PATCH] avoid "not a string literal..." warnings
by Jim Meyering
FYI, I've just checked in this change:
avoid "not a string literal..." warnings
* src/qemu_conf.c (qemudParseInterfaceXML): Add "%s".
(qemudBuildCommandLine, qemudGenerateXML): Likewise.
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 2a29382..9772721 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -1006,7 +1006,7 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
(model[i] >= 'a' && model[i] <= 'z') ||
(model[i] >= 'A' && model[i] <= 'Z') || model[i] == '_';
if (!char_ok) {
- qemudReportError (conn, NULL, NULL, VIR_ERR_INVALID_ARG,
+ qemudReportError (conn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s",
_("Model name contains invalid characters"));
goto error;
}
@@ -2751,9 +2751,9 @@ int qemudBuildCommandLine(virConnectPtr conn,
while(sound && size > 0) {
const char *model = qemudSoundModelToString(sound->model);
if (!model) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _("invalid sound model"));
- goto error;
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("invalid sound model"));
+ goto error;
}
strncat(modstr, model, size);
size -= strlen(model);
@@ -3988,7 +3988,7 @@ char *qemudGenerateXML(virConnectPtr conn,
const char *model = qemudSoundModelToString(sound->model);
if (!model) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _("invalid sound model"));
+ "%s", _("invalid sound model"));
goto cleanup;
}
virBufferVSprintf(&buf, " <sound model='%s'/>\n", model);
--
1.5.5.1.212.g8559
16 years, 5 months
[libvirt] [RFC] Network interface XML for containers
by Dave Leskovec
We never really settled on the XML format for container network interfaces. I
know a little more about what these look like now and have been working on the
code so would like to get this sorted out.
With network namespaces enabled, processes within the container will not be able
to see any network devices outside of the container. A veth device pair will be
used to transport traffic into and out off the container. One end of the veth
pair will be attached to a bridge in the parent namespace. The other end of
will be moved into the container namespace. We need to be able to represent the
following in the XML:
Network or bridge name
Name for parent side veth device
Name for container side veth device
inet address for container side veth device
So this should end up looking quite a bit like the formats for Virtual network
and Bridge to LAN with a couple new items. The formats I've been kicking around
are:
Virtual network
<devices>
<interface type='network'>
<source network='default' dev='veth0'/>
<target dev='veth1' address='192.168.0.150'/>
</interface>
</devices>
Bridge to LAN
<devices>
<interface type='bridge'>
<source bridge='virbr0' dev='veth4'/>
<target dev='veth5' address='192.168.0.155'/>
</interface>
</devices>
All comments welcome.
Thanks!
--
Best Regards,
Dave Leskovec
IBM Linux Technology Center
Open Virtualization
16 years, 5 months