We want to be able to pass a NULL instead of the connection and use this function in tests. To achieve this, the virConnectPtr is passed instead of virDomainPtr, and the driver is a new separate parameter.
--- src/qemu/qemu_driver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cda85f6..9d1f256 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7327,16 +7327,16 @@ qemuDomainUndefine(virDomainPtr dom) static int qemuDomainAttachDeviceLive(virDomainObjPtr vm, virDomainDeviceDefPtr dev, - virDomainPtr dom) + virConnectPtr conn, + virQEMUDriverPtr driver) { - virQEMUDriverPtr driver = dom->conn->privateData; int ret = -1; const char *alias = NULL; switch ((virDomainDeviceType) dev->type) { case VIR_DOMAIN_DEVICE_DISK: qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL); - ret = qemuDomainAttachDeviceDiskLive(dom->conn, driver, vm, dev); + ret = qemuDomainAttachDeviceDiskLive(conn, driver, vm, dev); if (!ret) { alias = dev->data.disk->info.alias; dev->data.disk = NULL; @@ -7369,7 +7369,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_HOSTDEV: qemuDomainObjCheckHostdevTaint(driver, vm, dev->data.hostdev, NULL); - ret = qemuDomainAttachHostDevice(dom->conn, driver, vm, + ret = qemuDomainAttachHostDevice(conn, driver, vm, dev->data.hostdev); if (!ret) { alias = dev->data.hostdev->info->alias; @@ -8151,7 +8151,8 @@ qemuDomainAttachDeviceFlags(virDomainPtr dom, VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0) goto endjob; - if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, dom)) < 0) + if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, dom->conn, + dom->conn->privateData)) < 0) goto endjob; /* * update domain status forcibly because the domain status may be -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list