mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
libxl: Don't use dom->conn to lookup virNetwork
When using the monolithic daemon, then dom->conn has all driver tables filled in properly and thus it's safe to call an API other than virDomain*(). However, when using split daemons then dom->conn has only hypervisor driver table set (dom->conn->driver) and the rest is NULL. Therefore, if we want to call a non-domain API (virNetworkLookupByName() in this case), we have obtain the cached connection object accessible via virGetConnectNetwork(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
7be63dbe25
commit
068fd891cd
@ -6228,10 +6228,10 @@ static int libxlNodeGetSecurityModel(virConnectPtr conn,
|
||||
}
|
||||
|
||||
static int
|
||||
libxlGetDHCPInterfaces(virDomainPtr dom,
|
||||
virDomainObjPtr vm,
|
||||
libxlGetDHCPInterfaces(virDomainObjPtr vm,
|
||||
virDomainInterfacePtr **ifaces)
|
||||
{
|
||||
g_autoptr(virConnect) conn = NULL;
|
||||
int rv = -1;
|
||||
int n_leases = 0;
|
||||
size_t i, j;
|
||||
@ -6242,12 +6242,8 @@ libxlGetDHCPInterfaces(virDomainPtr dom,
|
||||
virNetworkDHCPLeasePtr *leases = NULL;
|
||||
virDomainInterfacePtr *ifaces_ret = NULL;
|
||||
|
||||
if (!dom->conn->networkDriver ||
|
||||
!dom->conn->networkDriver->networkGetDHCPLeases) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Network driver does not support DHCP lease query"));
|
||||
if (!(conn = virGetConnectNetwork()))
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < vm->def->nnets; i++) {
|
||||
if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK)
|
||||
@ -6255,8 +6251,10 @@ libxlGetDHCPInterfaces(virDomainPtr dom,
|
||||
|
||||
virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr);
|
||||
virObjectUnref(network);
|
||||
network = virNetworkLookupByName(dom->conn,
|
||||
network = virNetworkLookupByName(conn,
|
||||
vm->def->nets[i]->data.network.name);
|
||||
if (!network)
|
||||
goto error;
|
||||
|
||||
if ((n_leases = virNetworkGetDHCPLeases(network, macaddr,
|
||||
&leases, 0)) < 0)
|
||||
@ -6344,7 +6342,7 @@ libxlDomainInterfaceAddresses(virDomainPtr dom,
|
||||
|
||||
switch (source) {
|
||||
case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE:
|
||||
ret = libxlGetDHCPInterfaces(dom, vm, ifaces);
|
||||
ret = libxlGetDHCPInterfaces(vm, ifaces);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user