search for: virgetlasterror

Displaying 20 results from an estimated 58 matches for "virgetlasterror".

2012 Feb 22
1
Bug? virGetLastError() returns NULL after virDomainCreate() if Domain running already
Hi, As the subject line indicates, when I'm calling virDomainCreate() to start a defined domain, and that command fails because the domain is already running at that point, virGetLastError() will return NULL, instead of a proper pointer to an error code. Libvirt will, however, print an error to the console: libvir: QEMU error : Requested operation is not valid: domain is already running This looks like a bug to me, and I'm fairly certain that earlier version would return an...
2013 Oct 14
2
event handler
good day to all. i still have not solved my problem with event handling. currently i have following code void libvirt_eventloop_thr_func() { while(true) //TODO: stop somehow on exit { if(virEventRunDefaultImpl() < 0) { virErrorPtr err = virGetLastError(); fprintf(stderr, "Failed to run event loop: %s\n", err && err->message ? err->message : "Unknown error"); } } } ... virSetErrorFunc(NULL, libvirt_error_handler); libvirt_connection = virConnectOpen("qemu:///system"); if (virEventRegisterDe...
2013 Oct 14
2
Re: event handler
...ing. >> currently i have following code >> >> >> void libvirt_eventloop_thr_func() >> { >> while(true) //TODO: stop somehow on exit >> { >> if(virEventRunDefaultImpl() < 0) >> { >> virErrorPtr err = virGetLastError(); >> fprintf(stderr, "Failed to run event loop: %s\n", err && >> err->message ? err->message : "Unknown error"); >> } >> } >> } >> >> >> >> ... >> >> virSetErrorFunc(...
2013 Oct 14
2
Re: event handler
...>> >>>> void libvirt_eventloop_thr_func() >>>> { >>>> while(true) //TODO: stop somehow on exit >>>> { >>>> if(virEventRunDefaultImpl() < 0) >>>> { >>>> virErrorPtr err = virGetLastError(); >>>> fprintf(stderr, "Failed to run event loop: %s\n", err && >>>> err->message ? err->message : "Unknown error"); >>>> } >>>> } >>>> } >>>> >>>> >&g...
2016 Sep 20
1
[PATCH] libvirt: read disk paths from pools (RHBZ#1366049)
...const char *pool_name, const char *volume_name) +{ + char *filename = NULL; + virErrorPtr err; + virStoragePoolPtr pool = NULL; + virStorageVolPtr vol = NULL; + virStorageVolInfo info; + int ret; + + pool = virStoragePoolLookupByName (conn, pool_name); + if (pool == NULL) { + err = virGetLastError (); + error (g, _("no libvirt pool called '%s': %s"), + pool_name, err->message); + goto cleanup; + } + + vol = virStorageVolLookupByName (pool, volume_name); + if (vol == NULL) { + err = virGetLastError (); + error (g, _("no volume called '%s&...
2015 Jun 11
2
Re: [PATCH 3/5] threads: Use thread-local storage for errors.
...r handler > in the second thread appears to have reset itself back to the default > error handler). I haven't yet worked out a better way to solve this. Do you have a feeling whether the error handler function push/pop is a commonly used feature or not ? In libvirt we originally had virGetLastError (global error) virConnGetLastError (per connection error) virSetErrorFunc (global error handler func) When we introduced thread support we didn't try to make the virConnGetLastError/SetErrorFun work. We just updated the docs to tell applications to /never/ use them in threaded appl...
2016 Nov 16
0
[PATCH 2/2] libvirt: read secrets of disks (RHBZ#1392798)
.... We cannot open the connection + * in read-only mode (VIR_CONNECT_RO), as that kind of connection + * is considered untrusted, and thus libvirt will prevent to read + * the values of secrets. + */ + conn = guestfs_int_open_libvirt_connection (g, libvirturi, 0); if (!conn) { err = virGetLastError (); error (g, _("could not connect to libvirt (code %d, domain %d): %s"), @@ -163,7 +169,7 @@ guestfs_impl_add_domain (guestfs_h *g, const char *domain_name, return r; } -static int add_disk (guestfs_h *g, const char *filename, const char *format, int readonly, const char *prot...
2016 Nov 16
3
[PATCH 1/2] libvirt: un-duplicate XPath code
Move the checks for empty xmlXPathObjectPtr, and for extracting the result string out of it, to a new helper functions. This is just code motion, there should be no behaviour changes. --- src/libvirt-domain.c | 122 +++++++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 72 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 4d4142d..baab307
2016 Sep 22
1
[PATCH v2] libvirt: read disk paths from pools (RHBZ#1366049)
...const char *pool_name, const char *volume_name) +{ + char *filename = NULL; + virErrorPtr err; + virStoragePoolPtr pool = NULL; + virStorageVolPtr vol = NULL; + virStorageVolInfo info; + int ret; + + pool = virStoragePoolLookupByName (conn, pool_name); + if (pool == NULL) { + err = virGetLastError (); + error (g, _("no libvirt pool called '%s': %s"), + pool_name, err->message); + goto cleanup; + } + + vol = virStorageVolLookupByName (pool, volume_name); + if (vol == NULL) { + err = virGetLastError (); + error (g, _("no volume called '%s&...
2010 May 21
2
Better error codes when stopping a VM that is already stopped
...rDomainDestroy(), I come across a domain that is already stopped. (For example when someone already stopped the domain manually using virsh or because the guest OS issued a shutdown.) This is a special case that I absolutely need to catch and handle. Unfortunately, when this happens, and I call virGetLastError() afterwards, I always just get the error code VIR_ERR_OPERATION_INVALID, which doesn't look very precise to me... Two questions about this: Is the domain not running at that moment the only possible condition that can trigger this particular error code when calling virDomainDestroy()? Ca...
2013 Aug 22
1
Re: virConnectDomainEventRegisterAny problem
...event_handler(virConnectPtr conn, virDomainPtr dom, int event, int detail, void * opaque) { std::cout<<"domain event handler called\n"; } void libvirt_eventloop_thr_func() { while(true) //TODO: stop somehow on exit { if(virEventRunDefaultImpl() < 0) { virErrorPtr err = virGetLastError(); fprintf(stderr, "Failed to run event loop: %s\n", err && err->message ? err->message : "Unknown error"); } } } .... virSetErrorFunc(NULL, libvirt_error_handler); libvirt_connection = virConnectOpen("qemu:///system"); if(libvirt_connection =...
2019 Apr 08
0
[PATCH v4 3/7] v2v: switch to ocaml-libvirt
...not implemented, fall back to - * virDomainGetInfo. See equivalent code in virsh. - */ -static int -get_dom_state (virDomainPtr dom) -{ - int state, reason; - virErrorPtr err; - virDomainInfo info; - - if (virDomainGetState (dom, &state, &reason, 0) == 0) - return state; - - err = virGetLastError (); - if (!err || err->code != VIR_ERR_NO_SUPPORT) - return -1; - - if (virDomainGetInfo (dom, &info) == 0) - return info.state; - - return -1; -} - -/* See lib/libvirt-auth.c for why we need this. */ -static int -libvirt_auth_default_wrapper (virConnectCredentialPtr cred, -...
2013 Oct 14
0
Re: event handler
...e not solved my problem with event handling. > currently i have following code > > > void libvirt_eventloop_thr_func() > { > while(true) //TODO: stop somehow on exit > { > if(virEventRunDefaultImpl() < 0) > { > virErrorPtr err = virGetLastError(); > fprintf(stderr, "Failed to run event loop: %s\n", err && > err->message ? err->message : "Unknown error"); > } > } > } > > > > ... > > virSetErrorFunc(NULL, libvirt_error_handler); > libvi...
2013 Oct 14
0
Re: event handler
...lowing code >>> >>> >>> void libvirt_eventloop_thr_func() >>> { >>> while(true) //TODO: stop somehow on exit >>> { >>> if(virEventRunDefaultImpl() < 0) >>> { >>> virErrorPtr err = virGetLastError(); >>> fprintf(stderr, "Failed to run event loop: %s\n", err && >>> err->message ? err->message : "Unknown error"); >>> } >>> } >>> } >>> >>> >>> >>> ... >&g...
2013 Oct 14
0
Re: event handler
...t; void libvirt_eventloop_thr_func() >>>>> { >>>>> while(true) //TODO: stop somehow on exit >>>>> { >>>>> if(virEventRunDefaultImpl() < 0) >>>>> { >>>>> virErrorPtr err = virGetLastError(); >>>>> fprintf(stderr, "Failed to run event loop: %s\n", err && >>>>> err->message ? err->message : "Unknown error"); >>>>> } >>>>> } >>>>> } >>>>> &...
2015 Jun 11
0
Re: [PATCH 3/5] threads: Use thread-local storage for errors.
...er the error handler function push/pop > is a commonly used feature or not ? All the time, in our code: $ git grep -E 'guestfs_(push|pop)_error_handler' -- *.c | wc -l 83 Of course we could change those, but it is still an API guarantee. > In libvirt we originally had > > virGetLastError (global error) > virConnGetLastError (per connection error) > virSetErrorFunc (global error handler func) > > When we introduced thread support we didn't try to make the > virConnGetLastError/SetErrorFun work. We just updated the docs > to tell applications to /ne...
2015 Dec 07
2
libvirt logging of virDomainAttachDeviceFlags()
Hi, When using « virsh attach-device ....." to add a channel device to a Guest , I see following entry in libvirt log : 2015-12-07 11:14:47.307+0000: 14551: debug : virDomainAttachDeviceFlags:10433 : dom=0x7f2a58252fc0, ........ Great !! But , when calling virDomainAttachDeviceFlags( ) from a C program , I got return code -1 but nothing appears related to virDomainAttachDeviceFlags(
2012 Oct 10
1
[PATCH] launch: show hint to resolve authentication failure from libvirt
...tested. src/libvirtdomain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libvirtdomain.c b/src/libvirtdomain.c index eecea26..110ee86 100644 --- a/src/libvirtdomain.c +++ b/src/libvirtdomain.c @@ -104,6 +104,8 @@ guestfs__add_domain (guestfs_h *g, const char *domain_name, err = virGetLastError (); error (g, _("could not connect to libvirt (code %d, domain %d): %s"), err->code, err->domain, err->message); + if (err->code == VIR_ERR_AUTH_FAILED) + error (g, _("Possible fix: 'polkit-auth --user <username> --grant org.libvirt.unix...
2016 Jan 19
2
[PATCH libguestfs v3] lib: Handle slow USB devices more gracefully.
...flags = check_for_errors ? VIR_DOMAIN_DESTROY_GRACEFUL : 0; + virErrorPtr err; + + again: + debug (g, "calling virDomainDestroy flags=%s", + check_for_errors ? "VIR_DOMAIN_DESTROY_GRACEFUL" : "0"); + if (virDomainDestroyFlags (dom, flags) == -1) { + err = virGetLastError (); + + /* Second chance if we're just waiting for qemu to shut down. See: + * https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html + */ + if ((flags & VIR_DOMAIN_DESTROY_GRACEFUL) && + err && err->code == VIR_ERR_SYSTEM_ERROR &...
2013 Feb 28
7
[PATCH 0/7] Fix SELinux security contexts so we can access shared disks (RHBZ#912499).
https://bugzilla.redhat.com/show_bug.cgi?id=912499 (especially comments 7 & 10) This patch set is the final fix so that we can access disks in use by other guests when SELinux and sVirt are enabled. Previously such disks were inaccessible because sVirt labels the disks with a random SELinux label to prevent other instances of qemu from being able to read them. So naturally the libguestfs