[libvirt] [PATCH] Domain/Net object cleanups after remote error
by Cole Robinson
Domain and Net objects were not being cleaned up properly
when reporting errors from the remote driver. Attached patch
fixes this.
Thanks,
Cole
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 51e8eb7..80f6ce6 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -4606,6 +4606,10 @@ server_error (virConnectPtr conn, remote_error *err)
err->str3 ? *err->str3 : NULL,
err->int1, err->int2,
"%s", err->message ? *err->message : NULL);
+ if (dom)
+ virDomainFree(dom);
+ if (net)
+ virNetworkFree(dom);
}
/* get_nonnull_domain and get_nonnull_network turn an on-wire
16 years, 7 months
Re: [libvirt] Problems in using Storage APIs in libvirt
by Amudhan Gunasekaran
Hi,
I have got the problem solved. I could now compile the code using Storage APIs also. But I run them I am getting error message: "libvir: Remote error : unknown procedure: 72"
The API I used is: virConnectListStoragePools
What is the problem here? How could I solve this. My OS is SLES 10 sp2 and hypervisor is XEN.
Thanks,
Amudhan.
>>> Chris Lalancette <clalance(a)redhat.com> 05/22/08 12:10 AM >>>
Amudhan Gunasekaran wrote:
> Hi,
>
> I am getting the following the error when I try to use ANY storage related APIs.
>
> undefined reference to '<method name>' for example,
>
> undefined reference to virConnectListStoragePools.
>
> I checked in the libvirt.h and it has the method definition. I checked the libvirt.c and it has the implementations. I can not figure out why I get this error. I could use APIs related the network, for example virConnectListNetworks. Where could I have gone wrong and what are the work-arounds to solve them?
>
> I am using SLES 10 SP2.
This probably means that libvirtd and/or virsh is still using the old copy of
the library. If you have a libvirt package installed, and then you built the
the CVS libvirt by hand, the CVS version probably got installed somewhere to
/usr/local/lib, which is in the search path after where libvirt is probably
installed to /usr/lib. Try removing your libvirt package and doing a "make
install" in the CVS version; you should then have everything matching up.
Chris Lalancette
16 years, 7 months
[libvirt] Problem in attaching a interface to a domain
by sarveswara rao mygapula
Hello,
I am facing problems in creating a network bridge using libvirt. My
requirement is, i need to create a bridge on the host machine. The bridge
shd get ip address from dhcp server(instead of static). I am not getting
what exactly the xml format that virsh is looking for?
I am using the following xml for creating a bridge.
<network>
<name>local</name>
<bridge name="virbr1" />
<source dev="eth1"/>
<mac address="00:11:22:33:44:55"/>
</network>
The bridge is getting created but not with the specified device and mac
address. Bridge is not getting ip address at all.
Can you please tell me the xml format for my requirement?
Thanks.
16 years, 7 months
[libvirt] [PATCH] Free object after *Destroy in python bindings
by Cole Robinson
The patch below fixes an issue in the python bindings with the
vir*Destroy methods. After the object is successfully destroyed,
the payload is cleared, using 'self._o = None'. This unfortunately
screws up virt object reference counts, as the payload should be
free'd using the appropriate vir*Free function.
Thanks,
Cole
diff --git a/python/generator.py b/python/generator.py
index cb57bff..9421981 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -629,10 +629,10 @@ function_classes = {}
function_classes["None"] = []
function_post = {
- 'virDomainDestroy': "self._o = None",
- 'virNetworkDestroy': "self._o = None",
- 'virStoragePoolDestroy': "self._o = None",
- 'virStorageVolDestroy': "self._o = None",
+ 'virDomainDestroy': "del(self)",
+ 'virNetworkDestroy': "del(self)",
+ 'virStoragePoolDestroy': "del(self)",
+ 'virStorageVolDestroy': "del(self)",
}
# Functions returning an integral type which need special rules to
16 years, 7 months
[libvirt] [PATCH] Fix destroy command memory leaks
by Cole Robinson
Some pieces of libvirt currently assume that the vir*Destroy
functions will free the passed object upon success. In
practice none of the current drivers seem to do this,
resulting in memory leaks.
The attached patch fixes the leaks I could find, as well as
changes the comments for virDomainDestroy and virNetworkDestroy
in libvirt.c to reflect reality. I also added a couple debug
statements to hash.c where domain reference counts can be
printed as they are changed.
Thanks,
Cole
diff --git a/qemud/remote.c b/qemud/remote.c
index a97641a..725152e 100644
--- a/qemud/remote.c
+++ b/qemud/remote.c
@@ -940,9 +940,11 @@ remoteDispatchDomainDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
return -2;
}
- if (virDomainDestroy (dom) == -1)
+ if (virDomainDestroy (dom) == -1) {
+ virDomainFree(dom);
return -1;
- /* No need to free dom - destroy does it for us */
+ }
+ virDomainFree(dom);
return 0;
}
diff --git a/src/hash.c b/src/hash.c
index 79421aa..a014990 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -842,6 +842,9 @@ __virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid)
goto error;
}
conn->refs++;
+ DEBUG0("virGetDomain: New hash entry.");
+ } else {
+ DEBUG("virGetDomain: Existing hash entry, refs now %d", ret->refs+1);
}
ret->refs++;
pthread_mutex_unlock(&conn->lock);
diff --git a/src/libvirt.c b/src/libvirt.c
index 97f6bc3..9f6df8e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1390,10 +1390,9 @@ virDomainLookupByName(virConnectPtr conn, const char *name)
* @domain: a domain object
*
* Destroy the domain object. The running instance is shutdown if not down
- * already and all resources used by it are given back to the hypervisor.
- * The data structure is freed and should not be used thereafter if the
- * call does not return an error.
- * This function may requires privileged access
+ * already and all resources used by it are given back to the hypervisor. This
+ * does not free the associated virDomainPtr object.
+ * This function may require privileged access
*
* Returns 0 in case of success and -1 in case of failure.
*/
@@ -3502,10 +3501,9 @@ virNetworkCreate(virNetworkPtr network)
* @network: a network object
*
* Destroy the network object. The running instance is shutdown if not down
- * already and all resources used by it are given back to the hypervisor.
- * The data structure is freed and should not be used thereafter if the
- * call does not return an error.
- * This function may requires privileged access
+ * already and all resources used by it are given back to the hypervisor. This
+ * does not free the associated virNetworkPtr object.
+ * This function may require privileged access
*
* Returns 0 in case of success and -1 in case of failure.
*/
diff --git a/src/virsh.c b/src/virsh.c
index 45af630..234fc36 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -1468,9 +1468,9 @@ cmdDestroy(vshControl * ctl, vshCmd * cmd)
} else {
vshError(ctl, FALSE, _("Failed to destroy domain %s"), name);
ret = FALSE;
- virDomainFree(dom);
}
+ virDomainFree(dom);
return ret;
}
@@ -2433,9 +2433,9 @@ cmdNetworkDestroy(vshControl * ctl, vshCmd * cmd)
} else {
vshError(ctl, FALSE, _("Failed to destroy network %s"), name);
ret = FALSE;
- virNetworkFree(network);
}
+ virNetworkFree(network);
return ret;
}
@@ -3161,9 +3161,9 @@ cmdPoolDestroy(vshControl * ctl, vshCmd * cmd)
} else {
vshError(ctl, FALSE, _("Failed to destroy pool %s"), name);
ret = FALSE;
- virStoragePoolFree(pool);
}
+ virStoragePoolFree(pool);
return ret;
}
16 years, 7 months
Re: [libvirt] Problems in using Storage APIs in libvirt
by Amudhan Gunasekaran
Hi Chris Lalancette,
Thanks for your quick reply. I just removed the already installed libvirt from my machine and did a *make install* in my CVS version of the code (which is in my machine at: /root/libvirt). The *make install* completed without any problems. But when I tried to compile the code, I get other error messages. I actually use the command:
gcc `pkg-config --cflags --libs libvirt` -o myexample myexample.c
The error messages I got are:
Package libvirt was not found in the pkg-config search path.
Perhaps you should add the directory containing `libvirt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libvirt' found
myexample.c:9:29: error: libvirt/libvirt.h: No such file or directory
Previously, I used the same command to compile and it compiled without any problems (if I had not used storage related apis). I think I am doing some silly mistakes. Please help me to rectify it.
Thanks,
Amudhan.
>>> Chris Lalancette <clalance(a)redhat.com> 05/22/08 12:10 AM >>>
Amudhan Gunasekaran wrote:
> Hi,
>
> I am getting the following the error when I try to use ANY storage related APIs.
>
> undefined reference to '<method name>' for example,
>
> undefined reference to virConnectListStoragePools.
>
> I checked in the libvirt.h and it has the method definition. I checked the libvirt.c and it has the implementations. I can not figure out why I get this error. I could use APIs related the network, for example virConnectListNetworks. Where could I have gone wrong and what are the work-arounds to solve them?
>
> I am using SLES 10 SP2.
This probably means that libvirtd and/or virsh is still using the old copy of
the library. If you have a libvirt package installed, and then you built the
the CVS libvirt by hand, the CVS version probably got installed somewhere to
/usr/local/lib, which is in the search path after where libvirt is probably
installed to /usr/lib. Try removing your libvirt package and doing a "make
install" in the CVS version; you should then have everything matching up.
Chris Lalancette
16 years, 7 months
[libvirt] Problems in using Storage APIs in libvirt
by Amudhan Gunasekaran
Hi,
I am getting the following the error when I try to use ANY storage related APIs.
undefined reference to '<method name>' for example,
undefined reference to virConnectListStoragePools.
I checked in the libvirt.h and it has the method definition. I checked the libvirt.c and it has the implementations. I can not figure out why I get this error. I could use APIs related the network, for example virConnectListNetworks. Where could I have gone wrong and what are the work-arounds to solve them?
I am using SLES 10 SP2.
Thanks in advance,
Amudhan.
16 years, 7 months
[libvirt] PATCH: Fix removal of iptables FORWARD rules
by Daniel P. Berrange
The previous patch to add routed networking broke the removal of one of the
FORWARD rules at shutdown. It was adding
/sbin/iptables --table filter --insert FORWARD
--destination 192.168.122.0/255.255.255.0
--out-interface virbr0 --match state
--state ESTABLISHED,RELATED --jump ACCEPT
But trying to remove
/sbin/iptables --table filter --delete FORWARD
--destination 192.168.122.0/255.255.255.0
--out-interface virbr0 --jump ACCEPT
which wasn't matching on the state flags. This patch makes it use the correct
removal code
Dan.
Index: src/qemu_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_driver.c,v
retrieving revision 1.76
diff -u -r1.76 qemu_driver.c
--- src/qemu_driver.c 16 May 2008 16:51:30 -0000 1.76
+++ src/qemu_driver.c 20 May 2008 20:41:03 -0000
@@ -1209,12 +1213,20 @@
struct qemud_network *network) {
if (network->def->forward) {
iptablesRemoveForwardMasquerade(driver->iptables,
- network->def->network,
- network->def->forwardDev);
- iptablesRemoveForwardAllowIn(driver->iptables,
- network->def->network,
- network->bridge,
- network->def->forwardDev);
+ network->def->network,
+ network->def->forwardDev);
+
+ if (network->def->forwardMode == QEMUD_NET_FORWARD_NAT)
+ iptablesRemoveForwardAllowRelatedIn(driver->iptables,
+ network->def->network,
+ network->bridge,
+ network->def->forwardDev);
+ else if (network->def->forwardMode == QEMUD_NET_FORWARD_ROUTE)
+ iptablesRemoveForwardAllowIn(driver->iptables,
+ network->def->network,
+ network->bridge,
+ network->def->forwardDev);
+
iptablesRemoveForwardAllowOut(driver->iptables,
network->def->network,
network->bridge,
--
|: 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, 7 months
[libvirt] virsh create Guest Crashing
by Kenneth Nagin
An image that comes up successfully is crash when be created with virsh:
This is libvirt create config file:
<domain type='xen' >
<name>ken-30</name>
<os>
<type>linux</type>
<kernel>/data/images/boot/vmlinuz-2.6.21.7-3.fc8xen</kernel>
<initrd>/data/images/boot/2.6.21.7-3.fc8xen-fedora.fc8.img</initrd>
</os>
<memory>131072</memory>
<vcpu>1</vcpu>
<devices>
<disk type='file'>
<source file='/data/images/nagin/c1/ken-30/fedora.fc8.img.sd'/>
<target dev='sda1'/>
</disk>
<disk type='file'>
<source file='/data/images/nagin/c1/ken-30/fedora.swap'/>.
<target dev='sda2'/>
</disk>
<interface type='bridge'>
<source bridge='virbr0'/>
<script path='/etc/xen/scripts/vif-bridge'/>
</interface>
</devices>
</domain>
This the original xen configuration file:
kernel = "/data/images/boot/vmlinuz-2.6.21.7-3.fc8xen"
ramdisk = "/data/images/boot/2.6.21.7-3.fc8xen-fedora.fc8.img">.
memory = 128
name = "ken-30"
vif = [ 'bridge=virbr0' ]
disk =
['tap:aio:/data/images/nagin/c1/ken-30/fedora.fc8.img,xvda1,w','tap:aio:/data/images/nagin/c1/ken-30/fedora.swap,xvda2,w']
root = "/dev/xvda1 ro"
vfb = [ "type=vnc, vncdisplay=30" ]
It crashes shortly after creation. This is the snapshot of the xen log:
[2008-05-19 12:00:56 4937] DEBUG (XendDomainInfo:1040)
XendDomainInfo.handleShutdownWatch
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
vif.
[2008-05-19 12:00:56 4937] DEBUG (DevController:155) Waiting for 0.
[2008-05-19 12:00:56 4937] DEBUG (DevController:594)
hotplugStatusCallback /local/domain/0/backend/vif/59/0/hotplug-status.
[2008-05-19 12:00:56 4937] DEBUG (DevController:608) hotplugStatusCallback
1.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
usb.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
vbd.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
irq.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
vkbd.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
vfb..
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
console.
[2008-05-19 12:00:56 4937] DEBUG (DevController:155) Waiting for 0.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
pci.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
ioports.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
tap.
[2008-05-19 12:00:56 4937] DEBUG (DevController:155) Waiting for 51713.
[2008-05-19 12:00:56 4937] DEBUG (DevController:594)
hotplugStatusCallback /local/domain/0/backend/tap/59/51713/hotplug-status.
[2008-05-19 12:00:56 4937] DEBUG (DevController:608) hotplugStatusCallback
1.
[2008-05-19 12:00:56 4937] DEBUG (DevController:155) Waiting for 51714.
[2008-05-19 12:00:56 4937] DEBUG (DevController:594)
hotplugStatusCallback /local/domain/0/backend/tap/59/51714/hotplug-status.
[2008-05-19 12:00:56 4937] DEBUG (DevController:608) hotplugStatusCallback
1.
[2008-05-19 12:00:56 4937] DEBUG (DevController:150) Waiting for devices
vtpm.
[2008-05-19 12:00:56 4937] INFO (XendDomain:1130) Domain ken-30 (59)
unpaused.
[2008-05-19 12:01:00 4937] WARNING (XendDomainInfo:1203) Domain has
crashed: name=ken-30 id=59.
[2008-05-19 12:01:00 4937] DEBUG (XendDomainInfo:1821)
XendDomainInfo.destroyDomain(59)
I've changed the XML configuration many different ways but nothing seems to
help. Any suggestions?
--Kenneth Nagin
16 years, 7 months