if (priv->conn)
virConnectClose(priv->conn);
+ if (priv->interfaceConn)
+ virConnectClose(priv->interfaceConn);
VIR_FREE(priv);
}
if (priv->conn == NULL)
goto cleanup;
+ priv->interfaceConn = virObjectRef(priv->conn);
+
/* force update the @readonly attribute which was inherited from the
* virNetServerService object - this is important for sockets that are RW
* by default, but do accept RO flags, e.g. TCP
}
sub get_conn_arg {
+ my $proc = shift;
+ my $args = shift;
+ my $rets = shift;
+
if ($structprefix eq "admin") {
return "priv->dmn";
}
+
+ my @types;
+ push @types, @{$args} if $args;
+ push @types, @{$rets} if $rets;
+
+ # This correctly detects most APIs
+ foreach my $type (@types) {
+ if ($type =~ /remote_nonnull_interface/) {
+ return "priv->interfaceConn";
+ }
+ }
+
+ # This is for the few virConnect APIs that
+ # return things which aren't objects. eg list
+ # of pool names, or number of pools.
+ if ($proc =~ /Connect.*Interface/ || $proc =~ /InterfaceChange/) {
+ return "priv->interfaceConn";
+ }
+
return "priv->conn";
}
my @free_list = ();
my @free_list_on_error = ("virNetMessageSaveError(rerr);");
- my $conn = get_conn_arg();
+ my $conn = get_conn_arg($call->{ProcName}, $call->{args_members}, $call->{ret_members});
# handle arguments to the function
if ($argtype ne "void") {