[Libvir] Record an error when refusing a read-only operation

The libvirt.c front-end can be compiled in 'pedantic' mode in which case it explicitly refuses operations with side-effects in read-only connections. When doing so, however, it was not recording any error message so feedback to the user was misleading / obsure. This patch adds an extra error code VIR_ERR_READ_ONLY which is used when an operation is denied due to a read only connection. This patch also passes 'VIR_DRV_OPEN_QUIET' to the 'open' method so tell the XenD driver not complain if it fails to open a HV connection. This is because it was complaining whenever trying to open a test:///default connection. 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 -=|

On Wed, Aug 16, 2006 at 03:30:30PM +0100, Daniel P. Berrange wrote:
The libvirt.c front-end can be compiled in 'pedantic' mode in which case it explicitly refuses operations with side-effects in read-only connections. When doing so, however, it was not recording any error message so feedback to the user was misleading / obsure. This patch adds an extra error code VIR_ERR_READ_ONLY which is used when an operation is denied due to a read only connection.
argh, I developped a similar patch independantly, using "VIR_ERR_OPERATION_DENIED" instead, it also reports the operation name and drop the #ifdef PEDANTIC , making it the default behaviour.
This patch also passes 'VIR_DRV_OPEN_QUIET' to the 'open' method so tell the XenD driver not complain if it fails to open a HV connection. This is because it was complaining whenever trying to open a test:///default connection.
That should not conflict, yeah it's probably better to have the libvirt front-end function report the connection error than letting the drivers emit errors themselves. The only problem is that you won't detect hypervisor connection failure say if you manage to connect with xend, because at least one access method succeeded ...
Index: src/libvirt.c =================================================================== RCS file: /data/cvs/libvirt/src/libvirt.c,v retrieving revision 1.42 diff -c -r1.42 libvirt.c *** src/libvirt.c 11 Aug 2006 14:40:04 -0000 1.42 --- src/libvirt.c 16 Aug 2006 15:17:43 -0000 *************** *** 240,246 ****
for (i = 0;i < MAX_DRIVERS;i++) { if ((virDriverTab[i] != NULL) && (virDriverTab[i]->open != NULL)) { ! res = virDriverTab[i]->open(ret, name, 0); /* * For a default connect to Xen make sure we manage to contact * all related drivers. --- 240,246 ----
for (i = 0;i < MAX_DRIVERS;i++) { if ((virDriverTab[i] != NULL) && (virDriverTab[i]->open != NULL)) { ! res = virDriverTab[i]->open(ret, name, VIR_DRV_OPEN_QUIET); /* * For a default connect to Xen make sure we manage to contact * all related drivers.
Okay, I'm afraid everything else clashes with my own patch <grin/> which is attached below. I also swapped a few function entry tests. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Wed, Aug 16, 2006 at 10:57:16AM -0400, Daniel Veillard wrote:
On Wed, Aug 16, 2006 at 03:30:30PM +0100, Daniel P. Berrange wrote:
The libvirt.c front-end can be compiled in 'pedantic' mode in which case it explicitly refuses operations with side-effects in read-only connections. When doing so, however, it was not recording any error message so feedback to the user was misleading / obsure. This patch adds an extra error code VIR_ERR_READ_ONLY which is used when an operation is denied due to a read only connection.
argh, I developped a similar patch independantly, using "VIR_ERR_OPERATION_DENIED" instead, it also reports the operation name and drop the #ifdef PEDANTIC , making it the default behaviour.
Resolving my changes with the ones you committed was pretty trivial so its committed now.
This patch also passes 'VIR_DRV_OPEN_QUIET' to the 'open' method so tell the XenD driver not complain if it fails to open a HV connection. This is because it was complaining whenever trying to open a test:///default connection.
That should not conflict, yeah it's probably better to have the libvirt front-end function report the connection error than letting the drivers emit errors themselves. The only problem is that you won't detect hypervisor connection failure say if you manage to connect with xend, because at least one access method succeeded ...
Ok, this is committed. 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 -=|
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard