[Libvir] Libvirt on windows
by Gabriel Kaufmann
Hi,
Did anybody managed to compile libvirt-0.4.0 on windows.
I tried following instructions on http://libvirt.org/windows.html which offer compiling in Cygwin.
This doesn't work because of inconsistency with winsock2.
If I change manually the HAVE_WINSOCK2 macro and make some changes in the code (see https://www.redhat.com/archives/libvir-list/2008-January/msg00344.html )
I manage to compile but after compiling virsh doesn't work (don't manage to connect to the host and returns Bad Address immediately)
Then I tried following the (not so detailed) instructions in https://www.redhat.com/archives/libvir-list/2008-January/msg00017.html
I get error compilation:
In file included from remote_internal.c:73:
../qemud/remote_protocol.h:1218:2: error: #endif without #if
remote_internal.c: In function 'remoteDomainGetMaxMemory':
remote_internal.c:1581: error: 'remote_domain_get_max_memory_ret' has no member named 'memory'
remote_internal.c: In function 'remoteDomainSetMaxMemory':
remote_internal.c:1591: error: 'remote_domain_set_max_memory_args' has no member named 'memory'
remote_internal.c: In function 'remoteDomainSetMemory':
remote_internal.c:1608: error: 'remote_domain_set_memory_args' has no member named 'memory'
remote_internal.c: In function 'remoteDomainGetInfo':
remote_internal.c:1634: error: 'remote_domain_get_info_ret' has no member named 'max_mem'
remote_internal.c:1635: error: 'remote_domain_get_info_ret' has no member named 'memory'
remote_internal.c:1636: error: 'remote_domain_get_info_ret' has no member named 'nr_virt_cpu'
remote_internal.c:1637: error: 'remote_domain_get_info_ret' has no member named 'cpu_time'
remote_internal.c: In function 'remoteDomainMigratePrepare':
remote_internal.c:1846: error: 'remote_domain_migrate_prepare_args' has no member named 'flags'
remote_internal.c:1847: error: 'remote_domain_migrate_prepare_args' has no member named 'dname'
remote_internal.c:1848: error: 'remote_domain_migrate_prepare_args' has no member named 'resource'
remote_internal.c: In function 'remoteDomainMigratePerform':
remote_internal.c:1882: error: 'remote_domain_migrate_perform_args' has no member named 'flags'
remote_internal.c:1883: error: 'remote_domain_migrate_perform_args' has no member named 'dname'
remote_internal.c:1884: error: 'remote_domain_migrate_perform_args' has no member named 'resource'
remote_internal.c: In function 'remoteDomainMigrateFinish':
remote_internal.c:1911: error: 'remote_domain_migrate_finish_args' has no member named 'flags'
make[2]: *** [libvirt_la-remote_internal.lo] Error 1
make[2]: Leaving directory `/data/cvs/libvirt/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/data/cvs/libvirt'
Can anyone tell help?
Best Regards,
Gabriel Kaufmann
Software Engineer
Gabriel.Kaufmann(a)ericom.com<mailto:Gabriel.Kaufmann@ericom.com>
Ericom Software
Tel (Dir): +972 2 591 1700 Ext 754
Tel (Main): +972 2 591 1700
http://www.ericom.com
Access Done Right
Empower Enterprise-Wide Access to Microsoft(r) Terminal Server, Virtual Desktops and Legacy Applications
16 years, 11 months
[Libvir] Empty <bootloader> tag?
by Kaitlin Rupert
Hello,
I created a guest from XML without a <bootloader> tag. When I run
dumpxml on the guest, I notice that an empty <bootloader /> tag is
appended. Is this the expected behavior? This seems to differ from the
behavior of other optional tags.
Thanks!
Log:
----------------
$ cat no_boot.xml
<domain type='xen' id='-1'>
<name>domU1</name>
<uuid>12278656-c4c9-11dc-8852-feffffffffff</uuid>
<os>
<type>linux</type>
<kernel>/tmp/default-xen-kernel</kernel>
<initrd>/tmp/default-xen-initrd</initrd>
<cmdline>TERM=xterm </cmdline>
</os>
<memory>131072</memory>
<vcpu>1</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<interface type='ethernet'>
<target dev='vif-1.0'/>
<mac address='11:22:33:aa:bb:cc'/>
</interface>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/tmp/default-xen-dimage'/>
<target dev='xvda'/>
</disk>
</devices>
</domain>
$ sudo virsh define no_boot.xml
Domain domU1 defined from no_boot.xml
$ sudo virsh dumpxml domU1
<domain type='xen' id='-1'>
<name>domU1</name>
<uuid>12278656-c4c9-11dc-8852-feffffffffff</uuid>
<bootloader/>
<os>
<type>linux</type>
<kernel>/tmp/default-xen-kernel</kernel>
<initrd>/tmp/default-xen-initrd</initrd>
<cmdline>TERM=xterm </cmdline>
</os>
<memory>131072</memory>
<vcpu>1</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<interface type='ethernet'>
<target dev='vif-1.0'/>
<mac address='11:22:33:aa:bb:cc'/>
</interface>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/tmp/default-xen-dimage'/>
<target dev='xvda'/>
</disk>
</devices>
</domain>
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com
16 years, 11 months
[Libvir] PATCH: Remove use of PKG_CHECK_EXISTS
by Daniel P. Berrange
This patch removes the use of PKG_CHECK_EXISTS which is only available in
new versions of pkg-config. Instead we use the 3rd and 4th args of the
PKG_CHECK_MODULES macro to control the if-found/not-found behaviour. This
allows us to auto-disable features if they're missing, rather than aborting
the configure run. This patch also updates the SASL tests to support the
value 'check' for auto-enable/disable like the rest of the modules.
With this applied I can successfully run the following on RHEL-4 hosts
with the default RPMs installed
./autogen.sh --without-xen
make
make dist
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
16 years, 11 months
[Libvir] Libvirt on Mac OS X 10.5
by Richard W.M. Jones
I got a little bit further with this, my current patch is attached.
At the moment, it gets as far as building libvirt & virsh, but fails to
build the Python bindings. However virsh doesn't run, apparently
because of a simple dynamic linking problem because of where the
libraries are (not yet) installed. I'm afraid that my understanding of
how to build and install applications on Mac OS X ends around here. In
particular I have no idea how to get the detailed abort trace that
Andrew showed up in his previous email.
References to portablexdr will be explained in a forthcoming email.
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
16 years, 11 months
[Libvir] API "int virDomainRestore(Conn, from)"
by Daniel Schwager
Hi,
I would like to restore a domain.
I think, after restoring the domain, the vnc-port
maybe has changed (because e.g. another domain use the old VNC-port
at the meantime).
If I do not know the domainname I restored, I have no possibility
to get this vnc-port or connect to the restored domain. Is this correct ?
So, would it not be better to change the API to
virDomainPtr virDomainRestore(Conn, from)
regards
Danny
-------------------------------------------------------------------
DT Netsolution GmbH - Taläckerstr. 30 - D-70437 Stuttgart
Geschäftsführer: Daniel Schwager, Stefan Hörz - HRB Stuttgart 19870
Tel: +49-711-849910-32, Fax: -932 - Mailto:daniel.schwager@dtnet.de
16 years, 11 months
[Libvir] Any sample code to use virConnectOpenAuth() in C binding ?
by Arun Sharma
Hello All,
Can anyone provide me sample code for connecting hypervisor using
credentials.
As of now i have implemented using(virConnectOpen(NULL)) , but this function
does not takes any credential information.
I saw that there is function (virConnectOpenAuth()) which can be used , but
i don;t know any way to implement
Thanks in advance.
--
Regards
Arun Sharma
0-934-829-3810
16 years, 11 months
[Libvir] Windows sizeof(long) != Linux sizeof(long)
by Daniel P. Berrange
Just discovered that on x86_64, Windows and Linux differ in what they
think sizeof(long) to be.
http://lists.xensource.com/archives/html/xen-devel/2008-01/msg00736.html
http://www.winehq.org/pipermail/wine-devel/2005-July/038602.html
Windows i686: sizeof(long) == 4, sizeof(void*) == 4
Windows x86_64: sizeof(long) == 4, sizeof(void*) == 8
Linux i686: sizeof(long) == 4, sizeof(void*) == 4
Linux x86_64: sizeof(long) == 8, sizeof(void*) == 8
Unfortunately we have a number of APIs which use 'long' in the public header
file for dealing with VM memory. Fortunately they are all using memory in
size of KB, so we are not totally doomed until people start wanting to
manage VMs with > 2 TB of RAM. Also fortunately, the wire-encoding for
these APIs all uses hyper, so on the wire everything is 64-bit guarenteed.
Eventually though we might want to consider adding
struct virDomainInfo64
struct virNodeInfo64
virDomainGetMemory64
virDomainSetMemory64
virDomainSetMaxMemory64
....simply replacing 'long' with 'long long' in these 5 APIs so we have
public APIs whose precision matches the wire encoding.
More immediately though, we need to be careful that there is no code that
assumes sizeof(long) == sizeof(void*) - eg any places we cast pointers
to integers and back again will break on Windows 64. Again fortunately, so
far I can only find places going from int -> pointer -> int which is OK
because we're not loosing precision.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
16 years, 11 months
[Libvir] Remove useless "if (foo)" before "free (foo)".
by Jim Meyering
Likewise, given if (foo != NULL) free (foo); remove the useless "if" test.
Do the same for sexpr_free, since it has similar semantics.
Detect with this:
(-0x3b tells Perl to use ';' as the input record separator)
perl -0x3b -ne '/\b(if \((.+?)(?:\s*!=\s*NULL\s*)?\)\s+(sexpr_)?free *\(\2\))/s and print "$ARGV: $1\n"'\ $(git ls-files)
Note that it also changes the code produced by generator.py.
This is just a heads-up.
Before committing it, I will add a rule using something like
the above to help avoid regressions.
BTW, there is some very misleading indentation in the vicinity
of some of these changes, but I didn't correct any of that.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
proxy/libvirt_proxy.c | 3 +-
python/generator.py | 2 +-
qemud/qemud.c | 5 +--
src/buf.c | 3 +-
src/conf.c | 7 +----
src/hash.c | 15 ++++---------
src/iptables.c | 6 +---
src/libvirt.c | 6 ++--
src/openvz_conf.c | 3 +-
src/qemu_conf.c | 8 ++----
src/qemu_driver.c | 18 +++++-----------
src/remote_internal.c | 26 ++++++++++++------------
src/test.c | 24 +++++++--------------
src/virsh.c | 53 ++++++++++++++++--------------------------------
src/virterror.c | 12 +++-------
src/xen_internal.c | 9 ++-----
src/xen_unified.c | 12 +++-------
src/xend_internal.c | 44 +++++++++++++---------------------------
src/xm_internal.c | 9 ++-----
src/xml.c | 21 ++++++-------------
src/xmlrpc.c | 20 +++++-------------
src/xs_internal.c | 2 -
tests/testutils.c | 3 +-
tests/xencapstest.c | 3 +-
tests/xmconfigtest.c | 3 +-
25 files changed, 110 insertions(+), 207 deletions(-)
diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c
index d8f2e64..5ccf855 100644
--- a/proxy/libvirt_proxy.c
+++ b/proxy/libvirt_proxy.c
@@ -505,8 +505,7 @@ retry2:
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
strcpy(&request.extra.str[VIR_UUID_BUFLEN], name);
}
- if (name)
- free(name);
+ free(name);
break;
}
case VIR_PROXY_LOOKUP_UUID: {
diff --git a/python/generator.py b/python/generator.py
index 7625a93..30b03fd 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -375,7 +375,7 @@ def print_function_wrapper(name, output, export, include):
if ret[0] == 'void':
if file == "python_accessor":
if args[1][1] == "char *":
- c_call = "\n if (%s->%s != NULL) free(%s->%s);\n" % (
+ c_call = "\n free(%s->%s);\n" % (
args[0][0], args[1][0], args[0][0], args[1][0])
c_call = c_call + " %s->%s = (%s)strdup((const xmlChar *)%s);\n" % (args[0][0],
args[1][0], args[1][1], args[1][0])
diff --git a/qemud/qemud.c b/qemud/qemud.c
index 467e011..4cbe04e 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -1132,7 +1132,7 @@ static void qemudDispatchClientFailure(struct qemud_server *server, struct qemud
#if HAVE_SASL
if (client->saslconn) sasl_dispose(&client->saslconn);
- if (client->saslUsername) free(client->saslUsername);
+ free(client->saslUsername);
#endif
if (client->tlssession) gnutls_deinit (client->tlssession);
close(client->fd);
@@ -1638,8 +1638,7 @@ static void qemudCleanup(struct qemud_server *server) {
if (server->saslUsernameWhitelist) {
char **list = server->saslUsernameWhitelist;
while (*list) {
- if (*list)
- free(*list);
+ free(*list);
list++;
}
}
diff --git a/src/buf.c b/src/buf.c
index 5f58027..188d040 100644
--- a/src/buf.c
+++ b/src/buf.c
@@ -150,8 +150,7 @@ void
virBufferFree(virBufferPtr buf)
{
if (buf) {
- if (buf->content)
- free(buf->content);
+ free(buf->content);
free(buf);
}
}
diff --git a/src/conf.c b/src/conf.c
index 62c42ff..8e66d84 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -490,7 +490,6 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
ret = calloc(1, sizeof(*ret));
if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"), 0);
- if (str != NULL)
free(str);
return(NULL);
}
@@ -642,8 +641,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
if (virConfAddEntry(ctxt->conf, name, value, comm) == NULL) {
free(name);
virConfFreeValue(value);
- if (comm != NULL)
- free(comm);
+ free(comm);
return(-1);
}
return(0);
@@ -776,8 +774,7 @@ __virConfFree(virConfPtr conf)
virConfEntryPtr next;
free(tmp->name);
virConfFreeValue(tmp->value);
- if (tmp->comment)
- free(tmp->comment);
+ free(tmp->comment);
next = tmp->next;
free(tmp);
tmp = next;
diff --git a/src/hash.c b/src/hash.c
index d95eea9..4e4ce60 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -226,8 +226,7 @@ virHashFree(virHashTablePtr table, virHashDeallocator f)
next = iter->next;
if ((f != NULL) && (iter->payload != NULL))
f(iter->payload, iter->name);
- if (iter->name)
- free(iter->name);
+ free(iter->name);
iter->payload = NULL;
if (!inside_table)
free(iter);
@@ -453,8 +452,7 @@ virHashRemoveEntry(virHashTablePtr table, const char *name,
if ((f != NULL) && (entry->payload != NULL))
f(entry->payload, entry->name);
entry->payload = NULL;
- if (entry->name)
- free(entry->name);
+ free(entry->name);
if (prev) {
prev->next = entry->next;
free(entry);
@@ -538,8 +536,7 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDealloc
if (iter(entry->payload, entry->name, data)) {
count++;
f(entry->payload, entry->name);
- if (entry->name)
- free(entry->name);
+ free(entry->name);
if (prev) {
prev->next = entry->next;
free(entry);
@@ -812,8 +809,7 @@ __virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid)
error:
pthread_mutex_unlock(&conn->lock);
if (ret != NULL) {
- if (ret->name != NULL)
- free(ret->name );
+ free(ret->name );
free(ret);
}
return(NULL);
@@ -946,8 +942,7 @@ __virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid)
error:
pthread_mutex_unlock(&conn->lock);
if (ret != NULL) {
- if (ret->name != NULL)
- free(ret->name );
+ free(ret->name );
free(ret);
}
return(NULL);
diff --git a/src/iptables.c b/src/iptables.c
index 5ac9be6..b59faa4 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -254,8 +254,7 @@ iptRulesSave(iptRules *rules)
static void
iptRuleFree(iptRule *rule)
{
- if (rule->rule)
- free(rule->rule);
+ free(rule->rule);
rule->rule = NULL;
if (rule->argv) {
@@ -488,8 +487,7 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
}
error:
- if (rule)
- free(rule);
+ free(rule);
if (argv) {
n = 0;
diff --git a/src/libvirt.c b/src/libvirt.c
index e400783..af81930 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -615,7 +615,7 @@ do_open (const char *name,
return ret;
failed:
- if (ret->name) free (ret->name);
+ free (ret->name);
if (ret->driver) ret->driver->close (ret);
if (uri) xmlFreeURI(uri);
virUnrefConnect(ret);
@@ -1978,8 +1978,8 @@ virDomainMigrate (virDomainPtr domain,
ddomain = virDomainLookupByName (dconn, dname);
done:
- if (uri_out) free (uri_out);
- if (cookie) free (cookie);
+ free (uri_out);
+ free (cookie);
return ddomain;
}
diff --git a/src/openvz_conf.c b/src/openvz_conf.c
index a886001..4e4019c 100644
--- a/src/openvz_conf.c
+++ b/src/openvz_conf.c
@@ -494,8 +494,7 @@ static struct openvz_vm_def
return def;
bail_out:
- if (prop)
- free(prop);
+ free(prop);
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 922223e..0de641d 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -1379,8 +1379,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
return def;
error:
- if (prop)
- free(prop);
+ free(prop);
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
@@ -1468,8 +1467,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
no_memory:
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "tapfds");
error:
- if (retval)
- free(retval);
+ free(retval);
if (tapfd != -1)
close(tapfd);
return NULL;
@@ -1941,7 +1939,7 @@ qemudParseVMDeviceDef(virConnectPtr conn,
error:
if (xml) xmlFreeDoc(xml);
- if (dev) free(dev);
+ free(dev);
return NULL;
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 566fb76..71a3125 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -228,7 +228,7 @@ qemudStartup(void) {
out_of_memory:
qemudLog (QEMUD_ERR, "qemudStartup: out of memory");
- if (base) free (base);
+ free (base);
free(qemu_driver);
qemu_driver = NULL;
return -1;
@@ -330,17 +330,11 @@ qemudShutdown(void) {
qemu_driver->nactivenetworks = 0;
qemu_driver->ninactivenetworks = 0;
- if (qemu_driver->configDir)
- free(qemu_driver->configDir);
- if (qemu_driver->autostartDir)
- free(qemu_driver->autostartDir);
- if (qemu_driver->networkConfigDir)
- free(qemu_driver->networkConfigDir);
- if (qemu_driver->networkAutostartDir)
- free(qemu_driver->networkAutostartDir);
-
- if (qemu_driver->vncTLSx509certdir)
- free(qemu_driver->vncTLSx509certdir);
+ free(qemu_driver->configDir);
+ free(qemu_driver->autostartDir);
+ free(qemu_driver->networkConfigDir);
+ free(qemu_driver->networkAutostartDir);
+ free(qemu_driver->vncTLSx509certdir);
if (qemu_driver->brctl)
brShutdown(qemu_driver->brctl);
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 860b4d8..4d855ab 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -735,13 +735,13 @@ doRemoteOpen (virConnectPtr conn,
cleanup:
/* Free up the URL and strings. */
- if (name) free (name);
- if (command) free (command);
- if (sockname) free (sockname);
- if (authtype) free (authtype);
- if (netcat) free (netcat);
- if (username) free (username);
- if (port) free (port);
+ free (name);
+ free (command);
+ free (sockname);
+ free (authtype);
+ free (netcat);
+ free (username);
+ free (port);
if (cmd_argv) {
char **cmd_argv_ptr = cmd_argv;
while (*cmd_argv_ptr) {
@@ -1139,10 +1139,10 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
#endif
/* Free hostname copy */
- if (priv->hostname) free (priv->hostname);
+ free (priv->hostname);
/* See comment for remoteType. */
- if (priv->type) free (priv->type);
+ free (priv->type);
/* Free private data. */
priv->magic = DEAD;
@@ -3267,7 +3267,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
/* This server call shows complete, and earlier client step was OK */
if (complete && err == SASL_OK) {
- if (serverin) free(serverin);
+ free(serverin);
break;
}
}
@@ -3297,9 +3297,9 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
ret = 0;
cleanup:
- if (localAddr) free(localAddr);
- if (remoteAddr) free(remoteAddr);
- if (serverin) free(serverin);
+ free(localAddr);
+ free(remoteAddr);
+ free(serverin);
free(saslcb);
remoteAuthFreeCredentials(cred, ncred);
diff --git a/src/test.c b/src/test.c
index d228b31..d39207f 100644
--- a/src/test.c
+++ b/src/test.c
@@ -354,8 +354,7 @@ static int testLoadDomain(virConnectPtr conn,
return (handle);
error:
- if (name)
- free(name);
+ free(name);
return (-1);
}
@@ -525,16 +524,11 @@ static int testLoadNetwork(virConnectPtr conn,
return (handle);
error:
- if (ipaddress)
- free(ipaddress);
- if (ipnetmask)
- free(ipnetmask);
- if (dhcpstart)
- free(dhcpstart);
- if (dhcpend)
- free(dhcpend);
- if (name)
- free(name);
+ free(ipaddress);
+ free(ipnetmask);
+ free(dhcpstart);
+ free(dhcpend);
+ free(name);
return (-1);
}
@@ -838,10 +832,8 @@ static int testOpenFromFile(virConnectPtr conn,
return (0);
error:
- if (domains != NULL)
- free(domains);
- if (networks != NULL)
- free(networks);
+ free(domains);
+ free(networks);
if (xml)
xmlFreeDoc(xml);
if (fd != -1)
diff --git a/src/virsh.c b/src/virsh.c
index 78c7c85..d081008 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -428,8 +428,7 @@ cmdConnect(vshControl * ctl, vshCmd * cmd)
ctl->conn = NULL;
}
- if (ctl->name)
- free(ctl->name);
+ free(ctl->name);
ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL));
if (!ro) {
@@ -577,8 +576,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
maxname = virConnectNumOfDefinedDomains(ctl->conn);
if (maxname < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
- if (ids)
- free(ids);
+ free(ids);
return FALSE;
}
if (maxname) {
@@ -586,8 +584,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
- if (ids)
- free(ids);
+ free(ids);
free(names);
return FALSE;
}
@@ -639,10 +636,8 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
virDomainFree(dom);
free(names[i]);
}
- if (ids)
- free(ids);
- if (names)
- free(names);
+ free(ids);
+ free(names);
return TRUE;
}
@@ -1217,8 +1212,7 @@ cmdSchedinfo(vshControl * ctl, vshCmd * cmd)
}
}
cleanup:
- if (params)
- free(params);
+ free(params);
virDomainFree(dom);
return ret_val;
}
@@ -2513,8 +2507,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
maxinactive = virConnectNumOfDefinedNetworks(ctl->conn);
if (maxinactive < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive networks"));
- if (activeNames)
- free(activeNames);
+ free(activeNames);
return FALSE;
}
if (maxinactive) {
@@ -2522,8 +2515,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if ((maxinactive = virConnectListDefinedNetworks(ctl->conn, inactiveNames, maxinactive)) < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive networks"));
- if (activeNames)
- free(activeNames);
+ free(activeNames);
free(inactiveNames);
return FALSE;
}
@@ -2581,10 +2573,8 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
virNetworkFree(network);
free(inactiveNames[i]);
}
- if (activeNames)
- free(activeNames);
- if (inactiveNames)
- free(inactiveNames);
+ free(activeNames);
+ free(inactiveNames);
return TRUE;
}
@@ -3230,10 +3220,8 @@ cmdAttachInterface(vshControl * ctl, vshCmd * cmd)
cleanup:
if (dom)
virDomainFree(dom);
- if (buf)
- free(buf);
- if (tmp)
- free(tmp);
+ free(buf);
+ free(tmp);
return ret;
}
@@ -3516,10 +3504,8 @@ cmdAttachDisk(vshControl * ctl, vshCmd * cmd)
cleanup:
if (dom)
virDomainFree(dom);
- if (buf)
- free(buf);
- if (tmp)
- free(tmp);
+ free(buf);
+ free(tmp);
return ret;
}
@@ -3868,8 +3854,7 @@ vshCommandOptFree(vshCmdOpt * arg)
a = a->next;
- if (tmp->data)
- free(tmp->data);
+ free(tmp->data);
free(tmp);
}
}
@@ -4267,7 +4252,7 @@ vshCommandParse(vshControl * ctl, char *cmdstr)
c->next = NULL;
if (!vshCommandCheckOpts(ctl, c)) {
- if(c) free(c);
+ free(c);
goto syntaxError;
}
@@ -4286,8 +4271,7 @@ vshCommandParse(vshControl * ctl, char *cmdstr)
vshCommandFree(ctl->cmd);
if (first)
vshCommandOptFree(first);
- if (tkdata)
- free(tkdata);
+ free(tkdata);
return FALSE;
}
@@ -4791,8 +4775,7 @@ static int
vshDeinit(vshControl * ctl)
{
vshCloseLogFile(ctl);
- if (ctl->name)
- free(ctl->name);
+ free(ctl->name);
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
ctl->conn = NULL; /* prevent recursive call from vshError() */
diff --git a/src/virterror.c b/src/virterror.c
index 0c0423b..bf4062d 100644
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -109,14 +109,10 @@ virResetError(virErrorPtr err)
{
if (err == NULL)
return;
- if (err->message != NULL)
- free(err->message);
- if (err->str1 != NULL)
- free(err->str1);
- if (err->str2 != NULL)
- free(err->str2);
- if (err->str3 != NULL)
- free(err->str3);
+ free(err->message);
+ free(err->str1);
+ free(err->str2);
+ free(err->str3);
memset(err, 0, sizeof(virError));
}
diff --git a/src/xen_internal.c b/src/xen_internal.c
index 2ca1052..133c253 100644
--- a/src/xen_internal.c
+++ b/src/xen_internal.c
@@ -1680,8 +1680,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
op.u.setvcpumapd5.cpumap.nr_cpus = nr_cpus;
}
ret = xenHypervisorDoV2Dom(handle, &op);
- if (new)
- free(new);
+ free(new);
if (unlock_pages(cpumap, maplen) < 0) {
virXenError(NULL, VIR_ERR_XEN_CALL, " release", maplen);
@@ -2056,15 +2055,13 @@ xenHypervisorInit(void)
virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL);
close(fd);
in_init = 0;
- if (ipt)
- free(ipt);
+ free(ipt);
return(-1);
done:
close(fd);
in_init = 0;
- if (ipt)
- free(ipt);
+ free(ipt);
return(0);
}
diff --git a/src/xen_unified.c b/src/xen_unified.c
index 187b7f5..d46e63b 100644
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -200,12 +200,9 @@ xenDomainUsedCpus(virDomainPtr dom)
}
done:
- if (cpulist != NULL)
- free(cpulist);
- if (cpumap != NULL)
- free(cpumap);
- if (cpuinfo != NULL)
- free(cpuinfo);
+ free(cpulist);
+ free(cpumap);
+ free(cpuinfo);
return(res);
}
@@ -912,9 +909,8 @@ xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
char *cpus, *res;
cpus = xenDomainUsedCpus(dom);
res = xenDaemonDomainDumpXML(dom, flags, cpus);
- if (cpus != NULL)
free(cpus);
- return(res);
+ return(res);
}
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET])
return xenProxyDomainDumpXML(dom, flags);
diff --git a/src/xend_internal.c b/src/xend_internal.c
index a9fc332..61af69b 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -620,8 +620,7 @@ xend_op_ext2(virConnectPtr xend, const char *path, char *error,
}
ret = http2unix(xend, xend_post(xend, path, buf.content, error, n_error));
- if (buf.content != NULL)
- free(buf.content);
+ free(buf.content);
return ret;
}
@@ -1640,10 +1639,8 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
virBufferAdd(&buf, " </disk>\n", 12);
bad_parse:
- if (drvName)
- free(drvName);
- if (drvType)
- free(drvType);
+ free(drvName);
+ free(drvType);
} else if (sexpr_lookup(node, "device/vif")) {
const char *tmp2;
tmp2 = sexpr_node(node, "device/vif/script");
@@ -1809,8 +1806,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
return (buf.content);
error:
- if (buf.content != NULL)
- free(buf.content);
+ free(buf.content);
return (NULL);
}
@@ -2809,7 +2805,6 @@ xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids)
}
error:
- if (root != NULL)
sexpr_free(root);
return(ret);
}
@@ -2843,7 +2838,6 @@ xenDaemonNumOfDomains(virConnectPtr conn)
}
error:
- if (root != NULL)
sexpr_free(root);
return(ret);
}
@@ -2877,8 +2871,7 @@ xenDaemonLookupByID(virConnectPtr conn, int id) {
return (ret);
error:
- if (name != NULL)
- free(name);
+ free(name);
return (NULL);
}
@@ -3152,10 +3145,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");
- if (sexpr != NULL)
- free(sexpr);
- if (name != NULL)
- free(name);
+ free(sexpr);
+ free(name);
return (NULL);
}
@@ -3187,8 +3178,7 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
xenDaemonDomainDestroy(dom);
virUnrefDomain(dom);
}
- if (name != NULL)
- free(name);
+ free(name);
return (NULL);
}
@@ -3228,8 +3218,7 @@ xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
str = virDomainGetOSType(domain);
if (strcmp(str, "linux"))
hvm = 1;
- if (str)
- free(str);
+ free(str);
sexpr = virParseXMLDevice(domain->conn, xml, hvm, priv->xendConfigVersion);
if (sexpr == NULL)
return (-1);
@@ -3460,10 +3449,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");
- if (sexpr != NULL)
- free(sexpr);
- if (name != NULL)
- free(name);
+ free(sexpr);
+ free(name);
return (NULL);
}
@@ -3482,8 +3469,7 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
return (dom);
error:
- if (name != NULL)
- free(name);
+ free(name);
return (NULL);
}
int xenDaemonDomainCreate(virDomainPtr domain)
@@ -3558,8 +3544,7 @@ xenDaemonNumOfDefinedDomains(virConnectPtr conn)
}
error:
- if (root != NULL)
- sexpr_free(root);
+ sexpr_free(root);
return(ret);
}
@@ -3591,8 +3576,7 @@ int xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxn
}
error:
- if (root != NULL)
- sexpr_free(root);
+ sexpr_free(root);
return(ret);
}
diff --git a/src/xm_internal.c b/src/xm_internal.c
index 6b502d0..a1317c4 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -1865,8 +1865,7 @@ static char *xenXMParseXMLVif(virConnectPtr conn, xmlNodePtr node, int hvm) {
}
cleanup:
- if (bridge != NULL)
- free(bridge);
+ free(bridge);
if (mac != NULL)
xmlFree(mac);
if (source != NULL)
@@ -2238,8 +2237,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
if (!vif)
goto error;
if (!(thisVif = malloc(sizeof(*thisVif)))) {
- if (vif)
- free(vif);
+ free(vif);
xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
goto error;
}
@@ -2410,8 +2408,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
return (ret);
error:
- if (entry)
- free(entry);
+ free(entry);
if (conf)
virConfFree(conf);
return (NULL);
diff --git a/src/xml.c b/src/xml.c
index c698889..a546002 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -397,14 +397,12 @@ virParseXenCpuTopology(virConnectPtr conn, virBufferPtr xml,
parse_error:
virXMLError(conn, VIR_ERR_XEN_CALL, _("topology syntax error"), 0);
error:
- if (cpuset != NULL)
- free(cpuset);
+ free(cpuset);
return (-1);
memory_error:
- if (cpuset != NULL)
- free(cpuset);
+ free(cpuset);
virXMLError(conn, VIR_ERR_NO_MEMORY, _("allocate buffer"), 0);
return (-1);
}
@@ -1066,16 +1064,14 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (str != NULL && !strcmp(str, "localtime")) {
virBufferAdd(buf, "(localtime 1)", 13);
}
- if (str)
- free(str);
+ free(str);
virBufferAdd(buf, "))", 2);
return (0);
error:
- if (nodes)
- free(nodes);
+ free(nodes);
return (-1);
}
@@ -1723,8 +1719,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
vcpus, xendConfigVersion);
}
- if (str != NULL)
- free(str);
+ free(str);
if (res != 0)
goto error;
@@ -1797,8 +1792,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
return (buf.content);
error:
- if (nam != NULL)
- free(nam);
+ free(nam);
if (name != NULL)
*name = NULL;
if (ctxt != NULL)
@@ -1807,8 +1801,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
xmlFreeDoc(xml);
if (pctxt != NULL)
xmlFreeParserCtxt(pctxt);
- if (buf.content != NULL)
- free(buf.content);
+ free(buf.content);
return (NULL);
}
diff --git a/src/xmlrpc.c b/src/xmlrpc.c
index b433ef5..f956f0d 100644
--- a/src/xmlrpc.c
+++ b/src/xmlrpc.c
@@ -115,8 +115,7 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalInteger(xmlNodePtr node)
if (ret && value)
ret->value.integer = atoi(value);
- if (value)
- free(value);
+ free(value);
return ret;
}
@@ -131,8 +130,7 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalBoolean(xmlNodePtr node)
ret->value.boolean = true;
else
ret->value.boolean = false;
- if (value)
- free(value);
+ free(value);
return ret;
}
@@ -143,8 +141,7 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalDouble(xmlNodePtr node)
if (ret && value)
ret->value.real = atof(value);
- if (value)
- free(value);
+ free(value);
return ret;
}
@@ -198,8 +195,7 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
ret->value = xmlRpcValueUnmarshal(cur);
} else {
xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected dict node"), 0);
- if (ret->name)
- free(ret->name);
+ free(ret->name);
if (ret->value)
xmlRpcValueFree(ret->value);
free(ret);
@@ -679,12 +675,8 @@ xmlRpcContextPtr xmlRpcContextNew(const char *uri)
void xmlRpcContextFree(xmlRpcContextPtr context)
{
if (context) {
- if (context->uri)
- free(context->uri);
-
- if (context->faultMessage)
- free(context->faultMessage);
-
+ free(context->uri);
+ free(context->faultMessage);
free(context);
}
}
diff --git a/src/xs_internal.c b/src/xs_internal.c
index 726af30..1dbbba6 100644
--- a/src/xs_internal.c
+++ b/src/xs_internal.c
@@ -635,9 +635,7 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
ret->id = id;
done:
- if (xenddomain != NULL)
free(xenddomain);
- if (idlist != NULL)
free(idlist);
return(ret);
diff --git a/tests/testutils.c b/tests/testutils.c
index 1141edb..4fea6b6 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -83,8 +83,7 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
else
fprintf(stderr, "%-50s ... FAILED\n", title);
- if (ts)
- free(ts);
+ free(ts);
return ret;
}
diff --git a/tests/xencapstest.c b/tests/xencapstest.c
index dd1c386..bf9ce07 100644
--- a/tests/xencapstest.c
+++ b/tests/xencapstest.c
@@ -62,8 +62,7 @@ static int testCompareFiles(const char *hostmachine,
fail:
- if (actualxml)
- free(actualxml);
+ free(actualxml);
if (fp1)
fclose(fp1);
if (fp2)
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index f49ca6c..51f4b67 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -153,8 +153,7 @@ static int testCompareFormatXML(const char *xmcfg_rel, const char *xml_rel,
fail:
if (conf)
virConfFree(conf);
- if (gotxml)
- free(gotxml);
+ free(gotxml);
if (conn) {
conn->privateData = old_priv;
--
1.5.4.rc3.14.g44397
16 years, 11 months
[Libvir] Probs migrating domain with libvirt 0.4.0
by Daniel Schwager
Hi,
I try migrate a domain from xen02 to xen03-server (both fedora core-8 linux)
- but it failed. Could you tell me, where a can look for more information
About this failure ?
[root@xen02 ~]# rpm -qa | grep libvirt
libvirt-0.4.0-3.fc8
libvirt-0.4.0-3.fc8
libvirt-devel-0.4.0-3.fc8
libvirt-python-0.4.0-3.fc8
[root@xen03 log]# rpm -qa | grep libvirt
libvirt-0.4.0-3.fc8
libvirt-python-0.4.0-3.fc8
**********
**** Migration with native XEN
**********
[root@xen02 ~]# xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 512 8 r----- 1610.6
vm-home.winxp100-home.winxp100.1200950924765.2.1200950924765.4 1 250 1 -b---- 735.4
vm-home.winxp100-home.winxp100.1200951541281.2.1200951541281.4 2 250 1 -b---- 1564.2
vm-home.winxp100-home.winxp100.1200951640937.2.1200951640937.4 3 250 1 -b---- 1540.6
[root@xen02 ~]# xm migrate -l 2 xen03.domain.com
[root@xen02 ~]# xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 512 8 r----- 1618.5
vm-home.winxp100-home.winxp100.1200950924765.2.1200950924765.4 1 250 1 -b---- 735.6
vm-home.winxp100-home.winxp100.1200951640937.2.1200951640937.4 3 250 1 -b---- 1541.1
**********
**** Check remote access (show migrated domain)
**********
[root@xen02 ~]# virsh -c xen://xen03.domain.com/ list
Id Name State
----------------------------------
0 Domain-0 running
1 vm-home.winxp100-home.winxp100.1200951541281.2.1200951541281.4 no state
**********
**** Migration with libvirtd
**********
[root@xen02 ~]# virsh
Welcome to virsh, the virtualization interactive terminal.
virsh # list
Id Name State
----------------------------------
0 Domain-0 running
1 vm-home.winxp100-home.winxp100.1200950924765.2.1200950924765.4 blocked
3 vm-home.winxp100-home.winxp100.1200951640937.2.1200951640937.4 blocked
virsh # migrate 3 xen://xen03.domain.com
libvir: Remote error : remoteDispatchClientRequest: internal error: library function returned error but did not set virterror
regards
Danny
-------------------------------------------------------------------
DT Netsolution GmbH - Taläckerstr. 30 - D-70437 Stuttgart
Geschäftsführer: Daniel Schwager, Stefan Hörz - HRB Stuttgart 19870
Tel: +49-711-849910-32, Fax: -932 - Mailto:daniel.schwager@dtnet.de
16 years, 11 months