Commit 04470fa5 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Fix error handling for virNodeDeviceGetParent()

It is valid for virNodeDeviceGetParent() to return NULL in the
case where there is no parent device present.
Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
parent 3cbba2b2
......@@ -5275,8 +5275,10 @@ const char *
get_parent(dev)
virNodeDevicePtr dev;
CODE:
if (!(RETVAL = virNodeDeviceGetParent(dev)))
_croak_error();
if (!(RETVAL = virNodeDeviceGetParent(dev))) {
if (virGetLastError() != NULL)
_croak_error();
}
OUTPUT:
RETVAL
......
#!/usr/bin/perl
use Sys::Virt;
my $conn = Sys::Virt->new();
my @nodelist = $conn->list_all_node_devices();
foreach my $dev (@nodelist){
my $parent = $dev->get_parent();
printf "%s: < %s\n", $dev->get_name(), $parent;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment