Jeremy Markle
2020-Aug-22 14:32 UTC
python-libvirt domain.destroy() doesn't appear to be working for me
I'm using the python-libvirt library and finding that I cannot get .destroy() or .shutdown() to work. https://github.com/simora/docker-libvirt-flask/blob/cba6041b47bdf4ccb3b9506a0379cf8c788a9a57/root/app/mqtt.py#L96 That is the line in my code. .create() works fine and using virsh in the docker container works fine to destroy the domain as well. This is based on ubuntu bionic in a docker container with the libvirt socket and such made available. .create() works, listing works and virsh works so permissions are not the issue. I'm confident I have failed to properly use the function or am missing the appropriate logging. Any assistance would be greatly appreciated.
Jeremy Markle
2020-Aug-22 16:25 UTC
Re: python-libvirt domain.destroy() doesn't appear to be working for me
I clearly did something wrong but now it appears to be operating as expected. Sorry and thank you. On Sat, Aug 22, 2020 at 10:32 AM Jeremy Markle <jeremy.markle@gmail.com> wrote:> I'm using the python-libvirt library and finding that I cannot get > .destroy() or .shutdown() to work. > > > https://github.com/simora/docker-libvirt-flask/blob/cba6041b47bdf4ccb3b9506a0379cf8c788a9a57/root/app/mqtt.py#L96 > > That is the line in my code. .create() works fine and using virsh in the > docker container works fine to destroy the domain as well. > > This is based on ubuntu bionic in a docker container with the libvirt > socket and such made available. .create() works, listing works and virsh > works so permissions are not the issue. I'm confident I have failed to > properly use the function or am missing the appropriate logging. > > Any assistance would be greatly appreciated. >
Daniel P. Berrangé
2020-Aug-24 09:31 UTC
Re: python-libvirt domain.destroy() doesn't appear to be working for me
On Sat, Aug 22, 2020 at 10:32:09AM -0400, Jeremy Markle wrote:> I'm using the python-libvirt library and finding that I cannot get > .destroy() or .shutdown() to work. > > https://github.com/simora/docker-libvirt-flask/blob/cba6041b47bdf4ccb3b9506a0379cf8c788a9a57/root/app/mqtt.py#L96Your code has alot of "< 0" checks. This is the C API behaviour to return -1 on error. In python we raise exceptions on error. so you try try/except to catch them Daniel
Jeremy Markle
2020-Aug-24 09:38 UTC
Re: python-libvirt domain.destroy() doesn't appear to be working for me
I was simply following the examples in the python-libvirt repo. If those methods raise exceptions I'll definitely change to try/catch. Thank you. The maintainer of the repo should update the examples and documentation if exceptions are raised by those. On Mon, Aug 24, 2020, 05:31 Daniel P. Berrangé <berrange@redhat.com> wrote:> On Sat, Aug 22, 2020 at 10:32:09AM -0400, Jeremy Markle wrote: > > I'm using the python-libvirt library and finding that I cannot get > > .destroy() or .shutdown() to work. > > > > > https://github.com/simora/docker-libvirt-flask/blob/cba6041b47bdf4ccb3b9506a0379cf8c788a9a57/root/app/mqtt.py#L96 > > Your code has alot of "< 0" checks. This is the C API behaviour to return > -1 > on error. In python we raise exceptions on error. so you try try/except to > catch them > > Daniel > >
Seemingly Similar Threads
- Re: python-libvirt domain.destroy() doesn't appear to be working for me
- Re: python-libvirt domain.destroy() doesn't appear to be working for me
- Using 'dummy.ups' for a real application, not just testing...
- R CMD building SPEEDY
- Introducing an Alignment object in LLVM