Commit 43666d99 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 63d8eda5
......@@ -5390,8 +5390,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