[libvirt] [PATCH 0/4] Remove use of virConnectPtr from more internal APIs

Following on from Matthias' work http://www.redhat.com/archives/libvir-list/2010-February/msg00198.html This series kills the virConnectPtr from QEMU, and LXC drivers, the security driver support code and the domain XML handling code.

The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Rename qemudReportError to qemuReportError and remove the conn, dom & net parameters all of which are unused. Remove virConnectPtr from all internal QEMU driver APIs with exception of APIs which need it to resolve a virNetworkPtr into a bridge device name --- src/qemu/qemu_conf.c | 471 +++++++++--------- src/qemu/qemu_conf.h | 21 +- src/qemu/qemu_driver.c | 1127 +++++++++++++++++++++--------------------- src/qemu/qemu_monitor.c | 38 +- src/qemu/qemu_monitor_json.c | 200 ++++---- src/qemu/qemu_monitor_text.c | 232 +++++----- tests/qemuargv2xmltest.c | 2 +- 7 files changed, 1026 insertions(+), 1065 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index e3769c8..fb06cd0 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -137,7 +137,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, #define CHECK_TYPE(name,typ) if (p && p->type != (typ)) { \ - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \ + qemuReportError(VIR_ERR_INTERNAL_ERROR, \ "remoteReadConfigFile: %s: %s: expected type " #typ "\n", \ filename, (name)); \ virConfFree(conf); \ @@ -1305,9 +1305,9 @@ fail: if (p) p = strndup(help, p - help); - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse QEMU version number in '%s'"), - p ? p : help); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse QEMU version number in '%s'"), + p ? p : help); VIR_FREE(p); @@ -1451,8 +1451,8 @@ qemudNetworkIfaceConnect(virConnectPtr conn, return -1; } } else { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Network type %d is not supported"), net->type); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Network type %d is not supported"), net->type); return -1; } @@ -1482,9 +1482,9 @@ qemudNetworkIfaceConnect(virConnectPtr conn, &net->ifname, vnet_hdr, &tapfd))) { if (errno == ENOTSUP) { /* In this particular case, give a better diagnostic. */ - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Failed to add tap interface to bridge. " - "%s is not a bridge device"), brname); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to add tap interface to bridge. " + "%s is not a bridge device"), brname); } else if (template_ifname) { virReportSystemError(err, _("Failed to add tap interface to bridge '%s'"), @@ -1566,9 +1566,9 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk) char *devname; if (virDiskNameToBusDeviceIndex(disk, &busid, &devid) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot convert disk '%s' to bus/device index"), - disk->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot convert disk '%s' to bus/device index"), + disk->dst); return -1; } @@ -1595,9 +1595,9 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk) ret = virAsprintf(&devname, "xenblk%d", devid); break; default: - qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, - _("Unsupported disk name mapping for bus '%s'"), - virDomainDiskBusTypeToString(disk->bus)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("Unsupported disk name mapping for bus '%s'"), + virDomainDiskBusTypeToString(disk->bus)); return -1; } @@ -1659,8 +1659,8 @@ qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx) for (i = 0 ; i < def->nnets ; i++) { int thisidx; if ((thisidx = qemuDomainDeviceAliasIndex(&def->nets[i]->info, "net")) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to determine device index for network device")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to determine device index for network device")); return -1; } if (thisidx >= idx) @@ -1686,8 +1686,8 @@ qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr hostdev for (i = 0 ; i < def->nhostdevs ; i++) { int thisidx; if ((thisidx = qemuDomainDeviceAliasIndex(&def->hostdevs[i]->info, "hostdev")) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to determine device index for hostdevwork device")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to determine device index for hostdevwork device")); return -1; } if (thisidx >= idx) @@ -1798,8 +1798,8 @@ static char *qemuPCIAddressAsString(virDomainDeviceInfoPtr dev) if (dev->addr.pci.domain != 0 || dev->addr.pci.bus != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Only PCI domain 0 and bus 0 are available")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only PCI domain 0 and bus 0 are available")); return NULL; } @@ -1869,8 +1869,8 @@ int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs, VIR_DEBUG("Reserving PCI addr %s", addr); if (virHashLookup(addrs->used, addr)) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unable to reserve PCI address %s"), addr); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to reserve PCI address %s"), addr); VIR_FREE(addr); return -1; } @@ -1982,8 +1982,8 @@ int qemuDomainPCIAddressSetNextAddr(qemuDomainPCIAddressSetPtr addrs, return 0; } - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("No more available PCI addresses")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("No more available PCI addresses")); return -1; } @@ -2056,8 +2056,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs) def->videos[i]->info.addr.pci.bus != 0 || def->videos[i]->info.addr.pci.slot != 2 || def->videos[i]->info.addr.pci.function != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Primary video card must have PCI address 0:0:2.0")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Primary video card must have PCI address 0:0:2.0")); goto error; } } else { @@ -2089,8 +2089,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs) def->videos[i]->info.addr.pci.bus != 0 || def->videos[i]->info.addr.pci.slot != 2 || def->videos[i]->info.addr.pci.function != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Primary IDE controller must have PCI address 0:0:1.1")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Primary IDE controller must have PCI address 0:0:1.1")); goto error; } } else { @@ -2141,18 +2141,18 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, { if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { if (info->addr.pci.domain != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Only PCI device addresses with domain=0 are supported")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only PCI device addresses with domain=0 are supported")); return -1; } if (info->addr.pci.bus != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Only PCI device addresses with bus=0 are supported")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only PCI device addresses with bus=0 are supported")); return -1; } if (info->addr.pci.function != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("Only PCI device addresses with function=0 are supported")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only PCI device addresses with function=0 are supported")); return -1; } @@ -2172,13 +2172,12 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" static int -qemuSafeSerialParamValue(virConnectPtr conn, - const char *value) +qemuSafeSerialParamValue(const char *value) { if (strspn(value, QEMU_SERIAL_PARAM_ACCEPTED_CHARS) != strlen (value)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("driver serial '%s' contains unsafe characters"), - value); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("driver serial '%s' contains unsafe characters"), + value); return -1; } @@ -2197,16 +2196,16 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, int busid = -1, unitid = -1; if (idx < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported disk type '%s'"), disk->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported disk type '%s'"), disk->dst); goto error; } switch (disk->bus) { case VIR_DOMAIN_DISK_BUS_SCSI: if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("unexpected address type for scsi disk")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unexpected address type for scsi disk")); goto error; } @@ -2214,8 +2213,8 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, * to be created. Yes this is slightly odd. It is not possible * to have > 1 bus on a SCSI controller (yet). */ if (disk->info.addr.drive.bus != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("SCSI controller only supports 1 bus")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("SCSI controller only supports 1 bus")); goto error; } busid = disk->info.addr.drive.controller; @@ -2224,14 +2223,14 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, case VIR_DOMAIN_DISK_BUS_IDE: if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("unexpected address type for ide disk")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unexpected address type for ide disk")); goto error; } /* We can only have 1 IDE controller (currently) */ if (disk->info.addr.drive.controller != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Only 1 %s controller is supported"), bus); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Only 1 %s controller is supported"), bus); goto error; } busid = disk->info.addr.drive.bus; @@ -2240,20 +2239,20 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, case VIR_DOMAIN_DISK_BUS_FDC: if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("unexpected address type for fdc disk")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unexpected address type for fdc disk")); goto error; } /* We can only have 1 FDC controller (currently) */ if (disk->info.addr.drive.controller != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Only 1 %s controller is supported"), bus); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Only 1 %s controller is supported"), bus); goto error; } /* We can only have 1 FDC bus (currently) */ if (disk->info.addr.drive.bus != 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Only 1 %s bus is supported"), bus); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Only 1 %s bus is supported"), bus); goto error; } unitid = disk->info.addr.drive.unit; @@ -2275,14 +2274,14 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, /* QEMU only supports magic FAT format for now */ if (disk->driverType && STRNEQ(disk->driverType, "fat")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported disk driver type for '%s'"), - disk->driverType); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported disk driver type for '%s'"), + disk->driverType); goto error; } if (!disk->readonly) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create virtual FAT disks in read-write mode")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create virtual FAT disks in read-write mode")); goto error; } if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) @@ -2323,7 +2322,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferVSprintf(&opt, ",format=%s", disk->driverType); if (disk->serial && (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_SERIAL)) { - if (qemuSafeSerialParamValue(NULL, disk->serial) < 0) + if (qemuSafeSerialParamValue(disk->serial) < 0) goto error; virBufferVSprintf(&opt, ",serial=%s", disk->serial); } @@ -2353,16 +2352,15 @@ error: char * -qemuBuildDriveDevStr(virConnectPtr conn, - virDomainDiskDefPtr disk) +qemuBuildDriveDevStr(virDomainDiskDefPtr disk) { virBuffer opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); int idx = virDiskNameToIndex(disk->dst); if (idx < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported disk type '%s'"), disk->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported disk type '%s'"), disk->dst); goto error; } @@ -2388,8 +2386,8 @@ qemuBuildDriveDevStr(virConnectPtr conn, virBufferAddLit(&opt, "usb-storage"); break; default: - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported disk bus '%s' with device setup"), bus); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported disk bus '%s' with device setup"), bus); goto error; } virBufferVSprintf(&opt, ",drive=drive-%s", disk->info.alias); @@ -2442,8 +2440,7 @@ error: char * -qemuBuildNicStr(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - virDomainNetDefPtr net, +qemuBuildNicStr(virDomainNetDefPtr net, const char *prefix, int vlan) { @@ -2508,8 +2505,7 @@ error: char * -qemuBuildHostNetStr(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - virDomainNetDefPtr net, +qemuBuildHostNetStr(virDomainNetDefPtr net, char type_sep, int vlan, const char *tapfd) @@ -2597,8 +2593,8 @@ qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev) const char *model = virDomainWatchdogModelTypeToString(dev->model); if (!model) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("missing watchdog model")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing watchdog model")); goto error; } @@ -2650,8 +2646,8 @@ qemuBuildSoundDevStr(virDomainSoundDefPtr sound) const char *model = virDomainSoundModelTypeToString(sound->model); if (!model) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid sound model")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid sound model")); goto error; } @@ -2728,8 +2724,8 @@ qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev) if (!dev->source.subsys.u.usb.bus && !dev->source.subsys.u.usb.device) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("USB host device is missing bus/device information")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("USB host device is missing bus/device information")); return NULL; } @@ -2750,8 +2746,8 @@ qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev) if (!dev->source.subsys.u.usb.bus && !dev->source.subsys.u.usb.device) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("USB host device is missing bus/device information")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("USB host device is missing bus/device information")); return NULL; } @@ -2925,8 +2921,7 @@ error: static int -qemuBuildCpuArgStr(virConnectPtr conn, - const struct qemud_driver *driver, +qemuBuildCpuArgStr(const struct qemud_driver *driver, const virDomainDefPtr def, const char *emulator, const struct utsname *ut, @@ -2948,11 +2943,11 @@ qemuBuildCpuArgStr(virConnectPtr conn, if (ncpus > 0 && host) { virCPUCompareResult cmp; - cmp = cpuGuestData(conn, host, def->cpu, &data); + cmp = cpuGuestData(NULL, host, def->cpu, &data); switch (cmp) { case VIR_CPU_COMPARE_INCOMPATIBLE: - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("guest CPU is not compatible with host CPU")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("guest CPU is not compatible with host CPU")); /* fall through */ case VIR_CPU_COMPARE_ERROR: goto cleanup; @@ -2964,7 +2959,7 @@ qemuBuildCpuArgStr(virConnectPtr conn, if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(ut->machine))) goto no_memory; - if (cpuDecode(conn, guest, data, ncpus, cpus) < 0) + if (cpuDecode(NULL, guest, data, ncpus, cpus) < 0) goto cleanup; virBufferVSprintf(&buf, "%s", guest->model); @@ -3000,7 +2995,7 @@ qemuBuildCpuArgStr(virConnectPtr conn, cleanup: virCPUDefFree(guest); - cpuDataFree(conn, ut->machine, data); + cpuDataFree(NULL, ut->machine, data); if (cpus) { for (i = 0; i < ncpus; i++) @@ -3051,6 +3046,9 @@ qemuBuildSmpArgStr(const virDomainDefPtr def, /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. + * + * XXX 'conn' is only required to resolve network -> bridge name + * figure out how to remove this requirement some day */ int qemudBuildCommandLine(virConnectPtr conn, struct qemud_driver *driver, @@ -3093,22 +3091,22 @@ int qemudBuildCommandLine(virConnectPtr conn, if (migrateFrom) { if (STRPREFIX(migrateFrom, "tcp")) { if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("TCP migration is not supported with this QEMU binary")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("TCP migration is not supported with this QEMU binary")); return -1; } } else if (STREQ(migrateFrom, "stdio")) { if (qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC) { migrateFrom = "exec:cat"; } else if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("STDIO migration is not supported with this QEMU binary")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("STDIO migration is not supported with this QEMU binary")); return -1; } } else if (STRPREFIX(migrateFrom, "exec")) { if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("STDIO migration is not supported with this QEMU binary")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("STDIO migration is not supported with this QEMU binary")); return -1; } } @@ -3243,7 +3241,7 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG_LIT(def->os.machine); } - if (qemuBuildCpuArgStr(conn, driver, def, emulator, &ut, &cpu) < 0) + if (qemuBuildCpuArgStr(driver, def, emulator, &ut, &cpu) < 0) goto error; if (cpu) { @@ -3262,19 +3260,19 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG_LIT(memory); if (def->hugepage_backed) { if (!driver->hugetlbfs_mount) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("hugetlbfs filesystem is not mounted")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("hugetlbfs filesystem is not mounted")); goto error; } if (!driver->hugepage_path) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("hugepages are disabled by administrator config")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("hugepages are disabled by administrator config")); goto error; } if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MEM_PATH)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("hugepage backing not supported by '%s'"), - def->emulator); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("hugepage backing not supported by '%s'"), + def->emulator); goto error; } ADD_ARG_LIT("-mem-prealloc"); @@ -3306,9 +3304,9 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG_LIT("-xen-domid"); ADD_ARG_LIT(domid); } else { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("qemu emulator '%s' does not support xen"), - def->emulator); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("qemu emulator '%s' does not support xen"), + def->emulator); goto error; } } @@ -3411,9 +3409,9 @@ int qemudBuildCommandLine(virConnectPtr conn, if (disk->driverName != NULL && !STREQ(disk->driverName, "qemu")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported driver name '%s' for disk '%s'"), - disk->driverName, disk->src); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported driver name '%s' for disk '%s'"), + disk->driverName, disk->src); goto error; } } @@ -3431,8 +3429,8 @@ int qemudBuildCommandLine(virConnectPtr conn, /* QEMU doesn't implement a SATA driver */ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("SATA is not supported with this QEMU binary")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("SATA is not supported with this QEMU binary")); goto error; } @@ -3480,8 +3478,8 @@ int qemudBuildCommandLine(virConnectPtr conn, if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { ADD_USBDISK(disk->src); } else { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported usb disk type for '%s'"), disk->src); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported usb disk type for '%s'"), disk->src); goto error; } continue; @@ -3531,7 +3529,7 @@ int qemudBuildCommandLine(virConnectPtr conn, } else { ADD_ARG_LIT("-device"); - if (!(optstr = qemuBuildDriveDevStr(conn, disk))) + if (!(optstr = qemuBuildDriveDevStr(disk))) goto error; ADD_ARG(optstr); } @@ -3547,8 +3545,8 @@ int qemudBuildCommandLine(virConnectPtr conn, if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { ADD_USBDISK(disk->src); } else { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported usb disk type for '%s'"), disk->src); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported usb disk type for '%s'"), disk->src); goto error; } continue; @@ -3566,8 +3564,8 @@ int qemudBuildCommandLine(virConnectPtr conn, STRPREFIX(disk->dst, "fd")) { snprintf(dev, NAME_MAX, "-%s", disk->dst); } else { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported disk type '%s'"), disk->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported disk type '%s'"), disk->dst); goto error; } } @@ -3576,14 +3574,14 @@ int qemudBuildCommandLine(virConnectPtr conn, /* QEMU only supports magic FAT format for now */ if (disk->driverType && STRNEQ(disk->driverType, "fat")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported disk driver type for '%s'"), - disk->driverType); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported disk driver type for '%s'"), + disk->driverType); goto error; } if (!disk->readonly) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create virtual FAT disks in read-write mode")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create virtual FAT disks in read-write mode")); goto error; } if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) @@ -3647,7 +3645,7 @@ int qemudBuildCommandLine(virConnectPtr conn, if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) && (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { ADD_ARG_LIT("-netdev"); - if (!(host = qemuBuildHostNetStr(conn, net, ',', + if (!(host = qemuBuildHostNetStr(net, ',', vlan, tapfd_name))) goto error; ADD_ARG(host); @@ -3659,14 +3657,14 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG(nic); } else { ADD_ARG_LIT("-net"); - if (!(nic = qemuBuildNicStr(conn, net, "nic,", vlan))) + if (!(nic = qemuBuildNicStr(net, "nic,", vlan))) goto error; ADD_ARG(nic); } if (!((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) && (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))) { ADD_ARG_LIT("-net"); - if (!(host = qemuBuildHostNetStr(conn, net, ',', + if (!(host = qemuBuildHostNetStr(net, ',', vlan, tapfd_name))) goto error; ADD_ARG(host); @@ -3746,8 +3744,8 @@ int qemudBuildCommandLine(virConnectPtr conn, case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: if (!(qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) || !(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("guestfwd requires QEMU to support -chardev & -device")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("guestfwd requires QEMU to support -chardev & -device")); goto error; } @@ -3888,8 +3886,8 @@ int qemudBuildCommandLine(virConnectPtr conn, if (def->nvideos) { if (def->nvideos > 1) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("only one video card is currently supported")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("only one video card is currently supported")); goto error; } @@ -3899,9 +3897,9 @@ int qemudBuildCommandLine(virConnectPtr conn, } else { const char *vgastr = qemuVideoTypeToString(def->videos[0]->type); if (!vgastr || STREQ(vgastr, "")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("video type %s is not supported with QEMU"), - virDomainVideoTypeToString(def->videos[0]->type)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("video type %s is not supported with QEMU"), + virDomainVideoTypeToString(def->videos[0]->type)); goto error; } @@ -3925,9 +3923,9 @@ int qemudBuildCommandLine(virConnectPtr conn, break; default: - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("video type %s is not supported with QEMU"), - virDomainVideoTypeToString(def->videos[0]->type)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("video type %s is not supported with QEMU"), + virDomainVideoTypeToString(def->videos[0]->type)); goto error; } } @@ -3973,8 +3971,8 @@ int qemudBuildCommandLine(virConnectPtr conn, const char *model = virDomainSoundModelTypeToString(sound->model); if (!model) { VIR_FREE(modstr); - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid sound model")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid sound model")); goto error; } strncat(modstr, model, size); @@ -4003,8 +4001,8 @@ int qemudBuildCommandLine(virConnectPtr conn, const char *model = virDomainWatchdogModelTypeToString(watchdog->model); if (!model) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("missing watchdog model")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing watchdog model")); goto error; } @@ -4015,8 +4013,8 @@ int qemudBuildCommandLine(virConnectPtr conn, const char *action = virDomainWatchdogActionTypeToString(watchdog->action); if (!action) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid watchdog action")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid watchdog action")); goto error; } ADD_ARG_LIT("-watchdog-action"); @@ -4059,8 +4057,8 @@ int qemudBuildCommandLine(virConnectPtr conn, goto error; ADD_ARG(devstr); } else { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s", - _("PCI device assignment is not supported by this version of qemu")); + qemuReportError(VIR_ERR_NO_SUPPORT, "%s", + _("PCI device assignment is not supported by this version of qemu")); goto error; } } @@ -4257,8 +4255,7 @@ static const char *qemuFindEnv(const char **progenv, * NULL is be placed into corresponding place in retvalues. */ static int -qemuParseCommandLineKeywords(virConnectPtr conn, - const char *str, +qemuParseCommandLineKeywords(const char *str, char ***retkeywords, char ***retvalues, int allowEmptyValue) @@ -4288,8 +4285,8 @@ qemuParseCommandLineKeywords(virConnectPtr conn, if (separator >= endmark) { if (!allowEmptyValue) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("malformed keyword arguments in '%s'"), str); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("malformed keyword arguments in '%s'"), str); goto error; } separator = endmark; @@ -4348,8 +4345,7 @@ error: * Will fail if not using the 'index' keyword */ static virDomainDiskDefPtr -qemuParseCommandLineDisk(virConnectPtr conn, - const char *val, +qemuParseCommandLineDisk(const char *val, int nvirtiodisk) { virDomainDiskDefPtr def = NULL; @@ -4361,7 +4357,7 @@ qemuParseCommandLineDisk(virConnectPtr conn, int busid = -1; int unitid = -1; - if ((nkeywords = qemuParseCommandLineKeywords(conn, val, + if ((nkeywords = qemuParseCommandLineKeywords(val, &keywords, &values, 0)) < 0) return NULL; @@ -4425,24 +4421,24 @@ qemuParseCommandLineDisk(virConnectPtr conn, if (virStrToLong_i(values[i], NULL, 10, &idx) < 0) { virDomainDiskDefFree(def); def = NULL; - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse drive index '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse drive index '%s'"), val); goto cleanup; } } else if (STREQ(keywords[i], "bus")) { if (virStrToLong_i(values[i], NULL, 10, &busid) < 0) { virDomainDiskDefFree(def); def = NULL; - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse drive bus '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse drive bus '%s'"), val); goto cleanup; } } else if (STREQ(keywords[i], "unit")) { if (virStrToLong_i(values[i], NULL, 10, &unitid) < 0) { virDomainDiskDefFree(def); def = NULL; - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse drive unit '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse drive unit '%s'"), val); goto cleanup; } } @@ -4450,8 +4446,8 @@ qemuParseCommandLineDisk(virConnectPtr conn, if (!def->src && def->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("missing file parameter in drive '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("missing file parameter in drive '%s'"), val); virDomainDiskDefFree(def); def = NULL; goto cleanup; @@ -4463,8 +4459,8 @@ qemuParseCommandLineDisk(virConnectPtr conn, if (idx == -1 && unitid == -1 && busid == -1) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("missing index/unit/bus parameter in drive '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("missing index/unit/bus parameter in drive '%s'"), val); virDomainDiskDefFree(def); def = NULL; goto cleanup; @@ -4527,8 +4523,7 @@ cleanup: * Tries to find a NIC definition matching a vlan we want */ static const char * -qemuFindNICForVLAN(virConnectPtr conn, - int nnics, +qemuFindNICForVLAN(int nnics, const char **nics, int wantvlan) { @@ -4543,8 +4538,8 @@ qemuFindNICForVLAN(virConnectPtr conn, tmp += strlen("vlan="); if (virStrToLong_i(tmp, &end, 10, &gotvlan) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse NIC vlan in '%s'"), nics[i]); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse NIC vlan in '%s'"), nics[i]); return NULL; } @@ -4555,8 +4550,8 @@ qemuFindNICForVLAN(virConnectPtr conn, if (wantvlan == 0 && nnics > 0) return nics[0]; - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find NIC definition for vlan %d"), wantvlan); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find NIC definition for vlan %d"), wantvlan); return NULL; } @@ -4567,8 +4562,7 @@ qemuFindNICForVLAN(virConnectPtr conn, * match up against. Horribly complicated stuff */ static virDomainNetDefPtr -qemuParseCommandLineNet(virConnectPtr conn, - virCapsPtr caps, +qemuParseCommandLineNet(virCapsPtr caps, const char *val, int nnics, const char **nics) @@ -4586,8 +4580,7 @@ qemuParseCommandLineNet(virConnectPtr conn, tmp = strchr(val, ','); if (tmp) { - if ((nkeywords = qemuParseCommandLineKeywords(conn, - tmp+1, + if ((nkeywords = qemuParseCommandLineKeywords(tmp+1, &keywords, &values, 0)) < 0) return NULL; @@ -4614,8 +4607,8 @@ qemuParseCommandLineNet(virConnectPtr conn, for (i = 0 ; i < nkeywords ; i++) { if (STREQ(keywords[i], "vlan")) { if (virStrToLong_i(values[i], NULL, 10, &wantvlan) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse vlan in '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse vlan in '%s'"), val); virDomainNetDefFree(def); def = NULL; goto cleanup; @@ -4636,7 +4629,7 @@ qemuParseCommandLineNet(virConnectPtr conn, * frontend, based off vlan number. NB this assumes a 1-1 mapping */ - nic = qemuFindNICForVLAN(conn, nnics, nics, wantvlan); + nic = qemuFindNICForVLAN(nnics, nics, wantvlan); if (!nic) { virDomainNetDefFree(def); def = NULL; @@ -4644,8 +4637,8 @@ qemuParseCommandLineNet(virConnectPtr conn, } if (!STRPREFIX(nic, "nic")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse NIC definition '%s'"), nic); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse NIC definition '%s'"), nic); virDomainNetDefFree(def); def = NULL; goto cleanup; @@ -4659,8 +4652,7 @@ qemuParseCommandLineNet(virConnectPtr conn, VIR_FREE(values); if (STRPREFIX(nic, "nic,")) { - if ((nkeywords = qemuParseCommandLineKeywords(conn, - nic + strlen("nic,"), + if ((nkeywords = qemuParseCommandLineKeywords(nic + strlen("nic,"), &keywords, &values, 0)) < 0) { virDomainNetDefFree(def); @@ -4675,9 +4667,9 @@ qemuParseCommandLineNet(virConnectPtr conn, if (STREQ(keywords[i], "macaddr")) { genmac = 0; if (virParseMacAddr(values[i], def->mac) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unable to parse mac address '%s'"), - values[i]); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to parse mac address '%s'"), + values[i]); virDomainNetDefFree(def); def = NULL; goto cleanup; @@ -4706,8 +4698,7 @@ cleanup: * Tries to parse a QEMU PCI device */ static virDomainHostdevDefPtr -qemuParseCommandLinePCI(virConnectPtr conn, - const char *val) +qemuParseCommandLinePCI(const char *val) { virDomainHostdevDefPtr def = NULL; int bus = 0, slot = 0, func = 0; @@ -4715,30 +4706,30 @@ qemuParseCommandLinePCI(virConnectPtr conn, char *end; if (!STRPREFIX(val, "host=")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown PCI device syntax '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown PCI device syntax '%s'"), val); VIR_FREE(def); goto cleanup; } start = val + strlen("host="); if (virStrToLong_i(start, &end, 16, &bus) < 0 || !end || *end != ':') { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device bus '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot extract PCI device bus '%s'"), val); VIR_FREE(def); goto cleanup; } start = end + 1; if (virStrToLong_i(start, &end, 16, &slot) < 0 || !end || *end != '.') { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device slot '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot extract PCI device slot '%s'"), val); VIR_FREE(def); goto cleanup; } start = end + 1; if (virStrToLong_i(start, NULL, 16, &func) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device function '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot extract PCI device function '%s'"), val); VIR_FREE(def); goto cleanup; } @@ -4764,8 +4755,7 @@ cleanup: * Tries to parse a QEMU USB device */ static virDomainHostdevDefPtr -qemuParseCommandLineUSB(virConnectPtr conn, - const char *val) +qemuParseCommandLineUSB(const char *val) { virDomainHostdevDefPtr def = NULL; int first = 0, second = 0; @@ -4773,8 +4763,8 @@ qemuParseCommandLineUSB(virConnectPtr conn, char *end; if (!STRPREFIX(val, "host:")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown PCI device syntax '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown PCI device syntax '%s'"), val); VIR_FREE(def); goto cleanup; } @@ -4782,29 +4772,29 @@ qemuParseCommandLineUSB(virConnectPtr conn, start = val + strlen("host:"); if (strchr(start, ':')) { if (virStrToLong_i(start, &end, 16, &first) < 0 || !end || *end != ':') { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot extract USB device vendor '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot extract USB device vendor '%s'"), val); VIR_FREE(def); goto cleanup; } start = end + 1; if (virStrToLong_i(start, NULL, 16, &second) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device product '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot extract PCI device product '%s'"), val); VIR_FREE(def); goto cleanup; } } else { if (virStrToLong_i(start, &end, 10, &first) < 0 || !end || *end != '.') { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + qemuReportError(VIR_ERR_INTERNAL_ERROR, _("cannot extract PCI device bus '%s'"), val); VIR_FREE(def); goto cleanup; } start = end + 1; if (virStrToLong_i(start, NULL, 10, &second) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot extract PCI device address '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot extract PCI device address '%s'"), val); VIR_FREE(def); goto cleanup; } @@ -4835,8 +4825,7 @@ cleanup: * Tries to parse a QEMU serial/parallel device */ static virDomainChrDefPtr -qemuParseCommandLineChr(virConnectPtr conn, - const char *val) +qemuParseCommandLineChr(const char *val) { virDomainChrDefPtr def; @@ -4916,8 +4905,8 @@ qemuParseCommandLineChr(virConnectPtr conn, } svc = strchr(val, ':'); if (!svc) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find port number in character device %s"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find port number in character device %s"), val); goto error; } opt = strchr(svc, ','); @@ -4956,8 +4945,8 @@ qemuParseCommandLineChr(virConnectPtr conn, if (!def->data.file.path) goto no_memory; } else { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown character device syntax %s"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown character device syntax %s"), val); goto error; } @@ -4992,8 +4981,7 @@ qemuInitGuestCPU(virDomainDefPtr dom) static int -qemuParseCommandLineCPU(virConnectPtr conn, - virDomainDefPtr dom, +qemuParseCommandLineCPU(virDomainDefPtr dom, const char *val) { virCPUDefPtr cpu; @@ -5038,7 +5026,7 @@ qemuParseCommandLineCPU(virConnectPtr conn, else feature = strdup(p); - ret = virCPUDefAddFeature(conn, cpu, feature, policy); + ret = virCPUDefAddFeature(NULL, cpu, feature, policy); VIR_FREE(feature); if (ret < 0) goto error; @@ -5048,8 +5036,8 @@ qemuParseCommandLineCPU(virConnectPtr conn, return 0; syntax: - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown CPU syntax '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown CPU syntax '%s'"), val); goto error; no_memory: @@ -5060,8 +5048,7 @@ error: static int -qemuParseCommandLineSmp(virConnectPtr conn, - virDomainDefPtr dom, +qemuParseCommandLineSmp(virDomainDefPtr dom, const char *val) { unsigned int sockets = 0; @@ -5075,7 +5062,7 @@ qemuParseCommandLineSmp(virConnectPtr conn, char *end; int ret; - nkws = qemuParseCommandLineKeywords(conn, val, &kws, &vals, 1); + nkws = qemuParseCommandLineKeywords(val, &kws, &vals, 1); if (nkws < 0) return -1; @@ -5125,8 +5112,8 @@ cleanup: return ret; syntax: - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse CPU topology '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse CPU topology '%s'"), val); error: ret = -1; goto cleanup; @@ -5138,8 +5125,7 @@ error: * virDomainDefPtr representing these settings as closely * as is practical. This is not an exact science.... */ -virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, const char **progenv, const char **progargv) { @@ -5154,8 +5140,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, int nvirtiodisk = 0; if (!progargv[0]) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("no emulator path found")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no emulator path found")); return NULL; } @@ -5206,8 +5192,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, #define WANT_VALUE() \ const char *val = progargv[++i]; \ if (!val) { \ - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \ - _("missing value for %s argument"), arg); \ + qemuReportError(VIR_ERR_INTERNAL_ERROR, \ + _("missing value for %s argument"), arg); \ goto error; \ } @@ -5251,8 +5237,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, char *opts; if (virStrToLong_i(tmp+1, &opts, 10, &vnc->data.vnc.port) < 0) { VIR_FREE(vnc); - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \ - _("cannot parse VNC port '%s'"), tmp+1); + qemuReportError(VIR_ERR_INTERNAL_ERROR, \ + _("cannot parse VNC port '%s'"), tmp+1); goto error; } vnc->data.vnc.listenAddr = strndup(val, tmp-val); @@ -5275,20 +5261,20 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, int mem; WANT_VALUE(); if (virStrToLong_i(val, NULL, 10, &mem) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \ - _("cannot parse memory level '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, \ + _("cannot parse memory level '%s'"), val); goto error; } def->memory = def->maxmem = mem * 1024; } else if (STREQ(arg, "-smp")) { WANT_VALUE(); - if (qemuParseCommandLineSmp(conn, def, val) < 0) + if (qemuParseCommandLineSmp(def, val) < 0) goto error; } else if (STREQ(arg, "-uuid")) { WANT_VALUE(); if (virUUIDParse(val, def->uuid) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \ - _("cannot parse UUID '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, \ + _("cannot parse UUID '%s'"), val); goto error; } } else if (STRPREFIX(arg, "-hd") || @@ -5385,7 +5371,7 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, WANT_VALUE(); if (STRNEQ(val, "none")) { virDomainChrDefPtr chr; - if (!(chr = qemuParseCommandLineChr(conn, val))) + if (!(chr = qemuParseCommandLineChr(val))) goto error; if (VIR_REALLOC_N(def->serials, def->nserials+1) < 0) { virDomainChrDefFree(chr); @@ -5399,7 +5385,7 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, WANT_VALUE(); if (STRNEQ(val, "none")) { virDomainChrDefPtr chr; - if (!(chr = qemuParseCommandLineChr(conn, val))) + if (!(chr = qemuParseCommandLineChr(val))) goto error; if (VIR_REALLOC_N(def->parallels, def->nparallels+1) < 0) { virDomainChrDefFree(chr); @@ -5452,7 +5438,7 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, def->disks[def->ndisks++] = disk; } else { virDomainHostdevDefPtr hostdev; - if (!(hostdev = qemuParseCommandLineUSB(conn, val))) + if (!(hostdev = qemuParseCommandLineUSB(val))) goto error; if (VIR_REALLOC_N(def->hostdevs, def->nhostdevs+1) < 0) { virDomainHostdevDefFree(hostdev); @@ -5464,7 +5450,7 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, WANT_VALUE(); if (!STRPREFIX(val, "nic") && STRNEQ(val, "none")) { virDomainNetDefPtr net; - if (!(net = qemuParseCommandLineNet(conn, caps, val, nnics, nics))) + if (!(net = qemuParseCommandLineNet(caps, val, nnics, nics))) goto error; if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0) { virDomainNetDefFree(net); @@ -5475,7 +5461,7 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, } else if (STREQ(arg, "-drive")) { virDomainDiskDefPtr disk; WANT_VALUE(); - if (!(disk = qemuParseCommandLineDisk(conn, val, nvirtiodisk))) + if (!(disk = qemuParseCommandLineDisk(val, nvirtiodisk))) goto error; if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) { virDomainDiskDefFree(disk); @@ -5488,7 +5474,7 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, } else if (STREQ(arg, "-pcidevice")) { virDomainHostdevDefPtr hostdev; WANT_VALUE(); - if (!(hostdev = qemuParseCommandLinePCI(conn, val))) + if (!(hostdev = qemuParseCommandLinePCI(val))) goto error; if (VIR_REALLOC_N(def->hostdevs, def->nhostdevs+1) < 0) { virDomainHostdevDefFree(hostdev); @@ -5558,14 +5544,14 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, if (STRNEQ(val, "none")) { video = qemuVideoTypeFromString(val); if (video < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown video adapter type '%s'"), val); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown video adapter type '%s'"), val); goto error; } } } else if (STREQ(arg, "-cpu")) { WANT_VALUE(); - if (qemuParseCommandLineCPU(conn, def, val) < 0) + if (qemuParseCommandLineCPU(def, val) < 0) goto error; } else if (STREQ(arg, "-domid")) { WANT_VALUE(); @@ -5586,8 +5572,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, } else { VIR_WARN(_("unknown QEMU argument '%s' during conversion"), arg); #if 0 - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown argument '%s'"), arg); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown argument '%s'"), arg); goto error; #endif } @@ -5660,8 +5646,7 @@ error: } -virDomainDefPtr qemuParseCommandLineString(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps, const char *args) { const char **progenv = NULL; @@ -5672,7 +5657,7 @@ virDomainDefPtr qemuParseCommandLineString(virConnectPtr conn, if (qemuStringToArgvEnv(args, &progenv, &progargv) < 0) goto cleanup; - def = qemuParseCommandLine(conn, caps, progenv, progargv); + def = qemuParseCommandLine(caps, progenv, progargv); cleanup: for (i = 0 ; progargv && progargv[i] ; i++) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index f6397b7..5c41a1a 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -157,9 +157,9 @@ typedef qemuDomainPCIAddressSet *qemuDomainPCIAddressSetPtr; /* Config type for XML import/export conversions */ #define QEMU_CONFIG_FORMAT_ARGV "qemu-argv" -#define qemudReportError(conn, dom, net, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define qemuReportError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_QEMU, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) int qemudLoadDriverConfig(struct qemud_driver *driver, @@ -191,15 +191,13 @@ int qemudBuildCommandLine (virConnectPtr conn, const char *migrateFrom); /* With vlan == -1, use netdev syntax, else old hostnet */ -char * qemuBuildHostNetStr(virConnectPtr conn, - virDomainNetDefPtr net, +char * qemuBuildHostNetStr(virDomainNetDefPtr net, char type_sep, int vlan, const char *tapfd); /* Legacy, pre device support */ -char * qemuBuildNicStr(virConnectPtr conn, - virDomainNetDefPtr net, +char * qemuBuildNicStr(virDomainNetDefPtr net, const char *prefix, int vlan); @@ -213,8 +211,7 @@ char *qemuBuildDriveStr(virDomainDiskDefPtr disk, unsigned long long qemuCmdFlags); /* Current, best practice */ -char * qemuBuildDriveDevStr(virConnectPtr conn, - virDomainDiskDefPtr disk); +char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk); /* Current, best practice */ char * qemuBuildControllerDevStr(virDomainControllerDefPtr def); @@ -258,12 +255,10 @@ int qemudProbeCPUModels (const char *qemu, int qemudCanonicalizeMachine (struct qemud_driver *driver, virDomainDefPtr def); -virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, const char **progenv, const char **progargv); -virDomainDefPtr qemuParseCommandLineString(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr qemuParseCommandLineString(virCapsPtr caps, const char *args); qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cac5b8a..da13473 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -124,8 +124,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, static int qemudDomainGetMaxVcpus(virDomainPtr dom); -static int qemuDetectVcpuPIDs(virConnectPtr conn, - struct qemud_driver *driver, +static int qemuDetectVcpuPIDs(struct qemud_driver *driver, virDomainObjPtr vm); static int qemuUpdateActivePciHostdevs(struct qemud_driver *driver, @@ -218,8 +217,8 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) if (!(monitorpath = virXPathString("string(./monitor[1]/@path)", ctxt))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("no monitor path")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no monitor path")); goto error; } @@ -245,9 +244,9 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) break; default: VIR_FREE(monitorpath); - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported monitor type '%s'"), - virDomainChrTypeToString(priv->monConfig->type)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported monitor type '%s'"), + virDomainChrTypeToString(priv->monConfig->type)); goto error; } @@ -320,8 +319,8 @@ static int qemuDomainObjBeginJob(virDomainObjPtr obj) if (virCondWaitUntil(&priv->jobCond, &obj->lock, then) < 0) { virDomainObjUnref(obj); if (errno == ETIMEDOUT) - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_TIMEOUT, - "%s", _("cannot acquire state change lock")); + qemuReportError(VIR_ERR_OPERATION_TIMEOUT, + "%s", _("cannot acquire state change lock")); else virReportSystemError(errno, "%s", _("cannot acquire job mutex")); @@ -363,8 +362,8 @@ static int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver, if (virCondWaitUntil(&priv->jobCond, &obj->lock, then) < 0) { virDomainObjUnref(obj); if (errno == ETIMEDOUT) - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_TIMEOUT, - "%s", _("cannot acquire state change lock")); + qemuReportError(VIR_ERR_OPERATION_TIMEOUT, + "%s", _("cannot acquire state change lock")); else virReportSystemError(errno, "%s", _("cannot acquire job mutex")); @@ -534,7 +533,7 @@ qemudLogFD(struct qemud_driver *driver, const char* name) static int -qemudLogReadFD(virConnectPtr conn, const char* logDir, const char* name, off_t pos) +qemudLogReadFD(const char* logDir, const char* name, off_t pos) { char logfile[PATH_MAX]; mode_t logmode = O_RDONLY; @@ -542,9 +541,9 @@ qemudLogReadFD(virConnectPtr conn, const char* logDir, const char* name, off_t p if ((ret = snprintf(logfile, sizeof(logfile), "%s/%s.log", logDir, name)) < 0 || ret >= sizeof(logfile)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("failed to build logfile name %s/%s.log"), - logDir, name); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to build logfile name %s/%s.log"), + logDir, name); return -1; } @@ -697,7 +696,7 @@ qemuHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED, static virStorageEncryptionPtr -findDomainDiskEncryption(virConnectPtr conn, virDomainObjPtr vm, +findDomainDiskEncryption(virDomainObjPtr vm, const char *path) { bool seen_volume; @@ -715,12 +714,12 @@ findDomainDiskEncryption(virConnectPtr conn, virDomainObjPtr vm, } } if (seen_volume) - qemudReportError(conn, NULL, NULL, VIR_ERR_INVALID_DOMAIN, - _("missing <encryption> for volume %s"), path); + qemuReportError(VIR_ERR_INVALID_DOMAIN, + _("missing <encryption> for volume %s"), path); else - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unexpected passphrase request for volume %s"), - path); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected passphrase request for volume %s"), + path); return NULL; } @@ -743,20 +742,20 @@ findVolumeQcowPassphrase(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDomainObjLock(vm); if (!conn) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("cannot find secrets without a connection")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("cannot find secrets without a connection")); goto cleanup; } if (conn->secretDriver == NULL || conn->secretDriver->lookupByUUID == NULL || conn->secretDriver->getValue == NULL) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s", - _("secret storage not supported")); + qemuReportError(VIR_ERR_NO_SUPPORT, "%s", + _("secret storage not supported")); goto cleanup; } - enc = findDomainDiskEncryption(conn, vm, path); + enc = findDomainDiskEncryption(vm, path); if (enc == NULL) return -1; @@ -764,8 +763,8 @@ findVolumeQcowPassphrase(qemuMonitorPtr mon ATTRIBUTE_UNUSED, enc->nsecrets != 1 || enc->secrets[0]->type != VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INVALID_DOMAIN, - _("invalid <encryption> for volume %s"), path); + qemuReportError(VIR_ERR_INVALID_DOMAIN, + _("invalid <encryption> for volume %s"), path); goto cleanup; } @@ -782,9 +781,9 @@ findVolumeQcowPassphrase(qemuMonitorPtr mon ATTRIBUTE_UNUSED, if (memchr(data, '\0', size) != NULL) { memset(data, 0, size); VIR_FREE(data); - qemudReportError(conn, NULL, NULL, VIR_ERR_INVALID_SECRET, - _("format='qcow' passphrase for %s must not contain a " - "'\\0'"), path); + qemuReportError(VIR_ERR_INVALID_SECRET, + _("format='qcow' passphrase for %s must not contain a " + "'\\0'"), path); goto cleanup; } @@ -1313,8 +1312,7 @@ qemudShutdown(void) { return 0; } -typedef int qemuLogHandleOutput(virConnectPtr conn, - virDomainObjPtr vm, +typedef int qemuLogHandleOutput(virDomainObjPtr vm, const char *output, int fd); @@ -1322,8 +1320,7 @@ typedef int qemuLogHandleOutput(virConnectPtr conn, * Returns -1 for error, 0 on success */ static int -qemudReadLogOutput(virConnectPtr conn, - virDomainObjPtr vm, +qemudReadLogOutput(virDomainObjPtr vm, int fd, char *buf, size_t buflen, @@ -1339,7 +1336,7 @@ qemudReadLogOutput(virConnectPtr conn, ssize_t func_ret, ret; int isdead = 0; - func_ret = func(conn, vm, buf, fd); + func_ret = func(vm, buf, fd); if (kill(vm->pid, 0) == -1 && errno == ESRCH) isdead = 1; @@ -1357,16 +1354,16 @@ qemudReadLogOutput(virConnectPtr conn, got += ret; buf[got] = '\0'; if (got == buflen-1) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Out of space while reading %s log output"), - what); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Out of space while reading %s log output"), + what); return -1; } if (isdead) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Process exited while reading %s log output"), - what); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Process exited while reading %s log output"), + what); return -1; } @@ -1377,8 +1374,8 @@ qemudReadLogOutput(virConnectPtr conn, retries--; } - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Timed out while reading %s log output"), what); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Timed out while reading %s log output"), what); return -1; } @@ -1436,8 +1433,7 @@ qemudExtractTTYPath(const char *haystack, } static int -qemudFindCharDevicePTYsMonitor(virConnectPtr conn, - virDomainObjPtr vm, +qemudFindCharDevicePTYsMonitor(virDomainObjPtr vm, virHashTablePtr paths) { int i; @@ -1456,9 +1452,9 @@ qemudFindCharDevicePTYsMonitor(virConnectPtr conn, if (chr->data.file.path == NULL) { \ /* neither the log output nor 'info chardev' had a */ \ /* pty path for this chardev, report an error */ \ - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, \ - _("no assigned pty for device %s"), id); \ - return -1; \ + qemuReportError(VIR_ERR_INTERNAL_ERROR, \ + _("no assigned pty for device %s"), id); \ + return -1; \ } else { \ /* 'info chardev' had no pty path for this chardev, */\ /* but the log output had, so we're fine */ \ @@ -1485,8 +1481,7 @@ qemudFindCharDevicePTYsMonitor(virConnectPtr conn, } static int -qemudFindCharDevicePTYs(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - virDomainObjPtr vm, +qemudFindCharDevicePTYs(virDomainObjPtr vm, const char *output, int fd ATTRIBUTE_UNUSED) { @@ -1536,19 +1531,18 @@ static void qemudFreePtyPath(void *payload, const char *name ATTRIBUTE_UNUSED) } static int -qemudWaitForMonitor(virConnectPtr conn, - struct qemud_driver* driver, +qemudWaitForMonitor(struct qemud_driver* driver, virDomainObjPtr vm, off_t pos) { char buf[4096]; /* Plenty of space to get startup greeting */ int logfd; int ret = -1; - if ((logfd = qemudLogReadFD(conn, driver->logDir, vm->def->name, pos)) + if ((logfd = qemudLogReadFD(driver->logDir, vm->def->name, pos)) < 0) return -1; - ret = qemudReadLogOutput(conn, vm, logfd, buf, sizeof(buf), + ret = qemudReadLogOutput(vm, logfd, buf, sizeof(buf), qemudFindCharDevicePTYs, "console", 3); if (close(logfd) < 0) { @@ -1559,8 +1553,8 @@ qemudWaitForMonitor(virConnectPtr conn, if (ret < 0) { /* Unexpected end of file - inform user of QEMU log data */ - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unable to start guest: %s"), buf); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to start guest: %s"), buf); return -1; } @@ -1585,7 +1579,7 @@ qemudWaitForMonitor(virConnectPtr conn, VIR_DEBUG("qemuMonitorGetPtyPaths returned %i", ret); if (ret == 0) { - ret = qemudFindCharDevicePTYsMonitor(conn, vm, paths); + ret = qemudFindCharDevicePTYsMonitor(vm, paths); } cleanup: @@ -1597,8 +1591,7 @@ cleanup: } static int -qemuDetectVcpuPIDs(virConnectPtr conn, - struct qemud_driver *driver, +qemuDetectVcpuPIDs(struct qemud_driver *driver, virDomainObjPtr vm) { pid_t *cpupids = NULL; int ncpupids; @@ -1628,9 +1621,9 @@ qemuDetectVcpuPIDs(virConnectPtr conn, return 0; if (ncpupids != vm->def->vcpus) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("got wrong number of vCPU pids from QEMU monitor. got %d, wanted %d"), - ncpupids, (int)vm->def->vcpus); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("got wrong number of vCPU pids from QEMU monitor. got %d, wanted %d"), + ncpupids, (int)vm->def->vcpus); VIR_FREE(cpupids); return -1; } @@ -1641,15 +1634,15 @@ qemuDetectVcpuPIDs(virConnectPtr conn, } static int -qemudInitCpuAffinity(virConnectPtr conn, - virDomainObjPtr vm) { +qemudInitCpuAffinity(virDomainObjPtr vm) +{ int i, hostcpus, maxcpu = QEMUD_CPUMASK_LEN; virNodeInfo nodeinfo; unsigned char *cpumap; int cpumaplen; qemuDomainObjPrivatePtr priv = vm->privateData; - if (nodeGetInfo(conn, &nodeinfo) < 0) + if (nodeGetInfo(NULL, &nodeinfo) < 0) return -1; /* setaffinity fails if you set bits for CPUs which @@ -1963,9 +1956,9 @@ qemuAssignPCIAddresses(virDomainObjPtr vm, if (qemuAssignNextPCIAddress(&(vm->def->disks[i]->info), vendor, product, addrs, naddrs) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find PCI address for VirtIO disk %s"), - vm->def->disks[i]->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find PCI address for VirtIO disk %s"), + vm->def->disks[i]->dst); return -1; } } @@ -1977,9 +1970,9 @@ qemuAssignPCIAddresses(virDomainObjPtr vm, if (qemuAssignNextPCIAddress(&(vm->def->nets[i]->info), vendor, product, addrs, naddrs) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find PCI address for %s NIC"), - vm->def->nets[i]->model); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find PCI address for %s NIC"), + vm->def->nets[i]->model); return -1; } } @@ -1991,9 +1984,9 @@ qemuAssignPCIAddresses(virDomainObjPtr vm, if (qemuAssignNextPCIAddress(&(vm->def->controllers[i]->info), vendor, product, addrs, naddrs) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find PCI address for controller %s"), - virDomainControllerTypeToString(vm->def->controllers[i]->type)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find PCI address for controller %s"), + virDomainControllerTypeToString(vm->def->controllers[i]->type)); return -1; } } @@ -2005,9 +1998,9 @@ qemuAssignPCIAddresses(virDomainObjPtr vm, if (qemuAssignNextPCIAddress(&(vm->def->videos[i]->info), vendor, product, addrs, naddrs) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find PCI address for video adapter %s"), - virDomainVideoTypeToString(vm->def->videos[i]->type)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find PCI address for video adapter %s"), + virDomainVideoTypeToString(vm->def->videos[i]->type)); return -1; } } @@ -2019,9 +2012,9 @@ qemuAssignPCIAddresses(virDomainObjPtr vm, if (qemuAssignNextPCIAddress(&(vm->def->sounds[i]->info), vendor, product, addrs, naddrs) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find PCI address for sound adapter %s"), - virDomainSoundModelTypeToString(vm->def->sounds[i]->model)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find PCI address for sound adapter %s"), + virDomainSoundModelTypeToString(vm->def->sounds[i]->model)); return -1; } } @@ -2032,9 +2025,9 @@ qemuAssignPCIAddresses(virDomainObjPtr vm, if (qemuAssignNextPCIAddress(&(vm->def->watchdog->info), vendor, product, addrs, naddrs) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find PCI address for watchdog %s"), - virDomainWatchdogModelTypeToString(vm->def->watchdog->model)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find PCI address for watchdog %s"), + virDomainWatchdogModelTypeToString(vm->def->watchdog->model)); return -1; } } @@ -2406,8 +2399,7 @@ cleanup: } -static int qemuRemoveCgroup(virConnectPtr conn, - struct qemud_driver *driver, +static int qemuRemoveCgroup(struct qemud_driver *driver, virDomainObjPtr vm, int quiet) { @@ -2420,9 +2412,9 @@ static int qemuRemoveCgroup(virConnectPtr conn, rc = virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0); if (rc != 0) { if (!quiet) - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Unable to find cgroup for %s\n"), - vm->def->name); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find cgroup for %s\n"), + vm->def->name); return rc; } @@ -2538,8 +2530,8 @@ static int qemudStartVMDaemon(virConnectPtr conn, FD_ZERO(&keepfd); if (virDomainObjIsActive(vm)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("VM is already active")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("VM is already active")); return -1; } @@ -2556,15 +2548,15 @@ static int qemudStartVMDaemon(virConnectPtr conn, goto cleanup; /* Ensure no historical cgroup for this VM is lieing around bogus settings */ - qemuRemoveCgroup(conn, driver, vm, 1); + qemuRemoveCgroup(driver, vm, 1); if ((vm->def->ngraphics == 1) && vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && vm->def->graphics[0]->data.vnc.autoport) { int port = qemudNextFreeVNCPort(driver); if (port < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("Unable to find an unused VNC port")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Unable to find an unused VNC port")); goto cleanup; } vm->def->graphics[0]->data.vnc.port = port; @@ -2691,8 +2683,8 @@ static int qemudStartVMDaemon(virConnectPtr conn, /* wait for qemu process to to show up */ if (ret == 0) { if (virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Domain %s didn't show up\n"), vm->def->name); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Domain %s didn't show up\n"), vm->def->name); ret = -1; } } else if (ret == -2) { @@ -2727,13 +2719,13 @@ static int qemudStartVMDaemon(virConnectPtr conn, if (ret == -1) /* The VM failed to start */ goto cleanup; - if (qemudWaitForMonitor(conn, driver, vm, pos) < 0) + if (qemudWaitForMonitor(driver, vm, pos) < 0) goto abort; - if (qemuDetectVcpuPIDs(conn, driver, vm) < 0) + if (qemuDetectVcpuPIDs(driver, vm) < 0) goto abort; - if (qemudInitCpuAffinity(conn, vm) < 0) + if (qemudInitCpuAffinity(vm) < 0) goto abort; if (qemuInitPasswords(driver, vm) < 0) @@ -2756,8 +2748,8 @@ static int qemudStartVMDaemon(virConnectPtr conn, /* Allow the CPUS to start executing */ if (qemuMonitorStartCPUs(priv->mon, conn) < 0) { if (virGetLastError() == NULL) - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("resume operation failed")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("resume operation failed")); qemuDomainObjExitMonitorWithDriver(driver, vm); goto abort; } @@ -2782,7 +2774,7 @@ cleanup: if (driver->securityDriver && driver->securityDriver->domainReleaseSecurityLabel) driver->securityDriver->domainReleaseSecurityLabel(conn, vm); - qemuRemoveCgroup(conn, driver, vm, 0); + qemuRemoveCgroup(driver, vm, 0); if ((vm->def->ngraphics == 1) && vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && vm->def->graphics[0]->data.vnc.autoport) @@ -2882,7 +2874,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, qemuDomainReAttachHostDevices(driver, vm->def); retry: - if ((ret = qemuRemoveCgroup(conn, driver, vm, 0)) < 0) { + if ((ret = qemuRemoveCgroup(driver, vm, 0)) < 0) { if (ret == -EBUSY && (retries++ < 5)) { usleep(200*1000); goto retry; @@ -2938,33 +2930,33 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn, return VIR_DRV_OPEN_DECLINED; if (qemu_driver == NULL) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu state driver is not active")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("qemu state driver is not active")); return VIR_DRV_OPEN_ERROR; } if (conn->uri->path == NULL) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("no QEMU URI path given, try %s"), - qemu_driver->privileged - ? "qemu:///system" - : "qemu:///session"); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("no QEMU URI path given, try %s"), + qemu_driver->privileged + ? "qemu:///system" + : "qemu:///session"); return VIR_DRV_OPEN_ERROR; } if (qemu_driver->privileged) { if (STRNEQ (conn->uri->path, "/system") && STRNEQ (conn->uri->path, "/session")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:///system"), - conn->uri->path); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected QEMU URI path '%s', try qemu:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } } else { if (STRNEQ (conn->uri->path, "/session")) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:///session"), - conn->uri->path); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected QEMU URI path '%s', try qemu:///session"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } } @@ -3038,7 +3030,7 @@ static int kvmGetMaxVCPUs(void) { } -static int qemudGetMaxVCPUs(virConnectPtr conn, const char *type) { +static int qemudGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED, const char *type) { if (!type) return 16; @@ -3051,8 +3043,8 @@ static int qemudGetMaxVCPUs(virConnectPtr conn, const char *type) { if (STRCASEEQ(type, "kqemu")) return 1; - qemudReportError(conn, NULL, NULL, VIR_ERR_INVALID_ARG, - _("unknown type '%s'"), type); + qemuReportError(VIR_ERR_INVALID_ARG, + _("unknown type '%s'"), type); return -1; } @@ -3156,8 +3148,8 @@ static virDomainPtr qemudDomainLookupByID(virConnectPtr conn, qemuDriverUnlock(driver); if (!vm) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching id %d"), id); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching id %d"), id); goto cleanup; } @@ -3183,8 +3175,8 @@ static virDomainPtr qemudDomainLookupByUUID(virConnectPtr conn, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(uuid, uuidstr); - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3208,8 +3200,8 @@ static virDomainPtr qemudDomainLookupByName(virConnectPtr conn, qemuDriverUnlock(driver); if (!vm) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching name '%s'"), name); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching name '%s'"), name); goto cleanup; } @@ -3233,7 +3225,7 @@ static int qemuDomainIsActive(virDomainPtr dom) obj = virDomainFindByUUID(&driver->domains, dom->uuid); qemuDriverUnlock(driver); if (!obj) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_NO_DOMAIN, NULL); + qemuReportError(VIR_ERR_NO_DOMAIN, NULL); goto cleanup; } ret = virDomainObjIsActive(obj); @@ -3254,7 +3246,7 @@ static int qemuDomainIsPersistent(virDomainPtr dom) obj = virDomainFindByUUID(&driver->domains, dom->uuid); qemuDriverUnlock(driver); if (!obj) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_NO_DOMAIN, NULL); + qemuReportError(VIR_ERR_NO_DOMAIN, NULL); goto cleanup; } ret = obj->persistent; @@ -3377,16 +3369,16 @@ static int qemudDomainSuspend(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } if (vm->state != VIR_DOMAIN_PAUSED) { @@ -3433,8 +3425,8 @@ static int qemudDomainResume(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3442,8 +3434,8 @@ static int qemudDomainResume(virDomainPtr dom) { goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } if (vm->state == VIR_DOMAIN_PAUSED) { @@ -3452,8 +3444,8 @@ static int qemudDomainResume(virDomainPtr dom) { if (qemuMonitorStartCPUs(priv->mon, dom->conn) < 0) { qemuDomainObjExitMonitorWithDriver(driver, vm); if (virGetLastError() == NULL) - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("resume operation failed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("resume operation failed")); goto endjob; } qemuDomainObjExitMonitorWithDriver(driver, vm); @@ -3492,8 +3484,8 @@ static int qemudDomainShutdown(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3501,8 +3493,8 @@ static int qemudDomainShutdown(virDomainPtr dom) { goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } @@ -3533,8 +3525,8 @@ static int qemudDomainDestroy(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3542,8 +3534,8 @@ static int qemudDomainDestroy(virDomainPtr dom) { goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } @@ -3585,8 +3577,8 @@ static char *qemudDomainGetOSType(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3612,8 +3604,8 @@ static unsigned long qemudDomainGetMaxMemory(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3637,14 +3629,14 @@ static int qemudDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (newmax < vm->def->memory) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - "%s", _("cannot set max memory lower than current memory")); + qemuReportError(VIR_ERR_INVALID_ARG, + "%s", _("cannot set max memory lower than current memory")); goto cleanup;; } @@ -3669,14 +3661,14 @@ static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (newmem > vm->def->maxmem) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - "%s", _("cannot set memory higher than max memory")); + qemuReportError(VIR_ERR_INVALID_ARG, + "%s", _("cannot set memory higher than max memory")); goto cleanup; } @@ -3693,8 +3685,8 @@ static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { /* Lack of balloon support is a fatal error */ if (r == 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("cannot set memory of an active domain")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("cannot set memory of an active domain")); goto endjob; } } else { @@ -3726,8 +3718,8 @@ static int qemudDomainGetInfo(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3737,7 +3729,7 @@ static int qemudDomainGetInfo(virDomainPtr dom, info->cpuTime = 0; } else { if (qemudGetProcessInfo(&(info->cpuTime), NULL, vm->pid, 0) < 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, ("cannot read cputime for domain")); + qemuReportError(VIR_ERR_OPERATION_FAILED, ("cannot read cputime for domain")); goto cleanup; } } @@ -3846,9 +3838,9 @@ static int qemudDomainSave(virDomainPtr dom, header.compressed = qemudSaveCompressionTypeFromString(driver->saveImageFormat); if (header.compressed < 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("Invalid save image format specified " - "in configuration file")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("Invalid save image format specified " + "in configuration file")); goto cleanup; } } @@ -3858,8 +3850,8 @@ static int qemudDomainSave(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -3867,8 +3859,8 @@ static int qemudDomainSave(virDomainPtr dom, goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } @@ -3888,27 +3880,27 @@ static int qemudDomainSave(virDomainPtr dom, /* Get XML for the domain */ xml = virDomainDefFormat(dom->conn, vm->def, VIR_DOMAIN_XML_SECURE); if (!xml) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to get domain xml")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to get domain xml")); goto endjob; } header.xml_len = strlen(xml) + 1; /* Write header to file, followed by XML */ if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to create '%s'"), path); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to create '%s'"), path); goto endjob; } if (safewrite(fd, &header, sizeof(header)) != sizeof(header)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to write save header")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to write save header")); goto endjob; } if (safewrite(fd, xml, header.xml_len) != header.xml_len) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, + qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to write xml")); goto endjob; } @@ -4007,8 +3999,8 @@ static int qemudDomainCoreDump(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -4016,15 +4008,15 @@ static int qemudDomainCoreDump(virDomainPtr dom, goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } /* Create an empty file with appropriate ownership. */ if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to create '%s'"), path); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to create '%s'"), path); goto endjob; } @@ -4082,8 +4074,8 @@ endjob: qemuDomainObjEnterMonitor(vm); if (qemuMonitorStartCPUs(priv->mon, dom->conn) < 0) { if (virGetLastError() == NULL) - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("resuming after dump failed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("resuming after dump failed")); } qemuDomainObjExitMonitor(vm); } @@ -4121,8 +4113,8 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -4130,28 +4122,28 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) { goto cleanup; if (virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, "%s", - _("cannot change vcpu count of an active domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot change vcpu count of an active domain")); goto endjob; } if (!(type = virDomainVirtTypeToString(vm->def->virtType))) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown virt type in domain definition '%d'"), - vm->def->virtType); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown virt type in domain definition '%d'"), + vm->def->virtType); goto endjob; } - if ((max = qemudGetMaxVCPUs(dom->conn, type)) < 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("could not determine max vcpus for the domain")); + if ((max = qemudGetMaxVCPUs(NULL, type)) < 0) { + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not determine max vcpus for the domain")); goto endjob; } if (nvcpus > max) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - _("requested vcpus is greater than max allowable" - " vcpus for the domain: %d > %d"), nvcpus, max); + qemuReportError(VIR_ERR_INVALID_ARG, + _("requested vcpus is greater than max allowable" + " vcpus for the domain: %d > %d"), nvcpus, max); goto endjob; } @@ -4188,23 +4180,23 @@ qemudDomainPinVcpu(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s",_("cannot pin vcpus on an inactive domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s",_("cannot pin vcpus on an inactive domain")); goto cleanup; } priv = vm->privateData; if (vcpu > (priv->nvcpupids-1)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - _("vcpu number out of range %d > %d"), - vcpu, priv->nvcpupids); + qemuReportError(VIR_ERR_INVALID_ARG, + _("vcpu number out of range %d > %d"), + vcpu, priv->nvcpupids); goto cleanup; } @@ -4221,8 +4213,8 @@ qemudDomainPinVcpu(virDomainPtr dom, cpumap, maplen, maxcpu) < 0) goto cleanup; } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("cpu affinity is not supported")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("cpu affinity is not supported")); goto cleanup; } ret = 0; @@ -4253,15 +4245,15 @@ qemudDomainGetVcpus(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", - _("cannot list vcpu pinning for an inactive domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", + _("cannot list vcpu pinning for an inactive domain")); goto cleanup; } @@ -4309,8 +4301,8 @@ qemudDomainGetVcpus(virDomainPtr dom, goto cleanup; } } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("cpu affinity is not available")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("cpu affinity is not available")); goto cleanup; } } @@ -4337,19 +4329,19 @@ static int qemudDomainGetMaxVcpus(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!(type = virDomainVirtTypeToString(vm->def->virtType))) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown virt type in domain definition '%d'"), - vm->def->virtType); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown virt type in domain definition '%d'"), + vm->def->virtType); goto cleanup; } - ret = qemudGetMaxVCPUs(dom->conn, type); + ret = qemudGetMaxVCPUs(NULL, type); cleanup: if (vm) @@ -4372,15 +4364,15 @@ static int qemudDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr sec if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!(type = virDomainVirtTypeToString(vm->def->virtType))) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("unknown virt type in domain definition '%d'"), - vm->def->virtType); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown virt type in domain definition '%d'"), + vm->def->virtType); goto cleanup; } @@ -4401,8 +4393,8 @@ static int qemudDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr sec if (virDomainObjIsActive(vm)) { if (driver->securityDriver && driver->securityDriver->domainGetSecurityProcessLabel) { if (driver->securityDriver->domainGetSecurityProcessLabel(dom->conn, vm, seclabel) == -1) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to get security label")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to get security label")); goto cleanup; } } @@ -4432,9 +4424,9 @@ static int qemudNodeGetSecurityModel(virConnectPtr conn, p = driver->caps->host.secModel.model; if (strlen(p) >= VIR_SECURITY_MODEL_BUFLEN-1) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("security model string exceeds max %d bytes"), - VIR_SECURITY_MODEL_BUFLEN-1); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("security model string exceeds max %d bytes"), + VIR_SECURITY_MODEL_BUFLEN-1); ret = -1; goto cleanup; } @@ -4442,9 +4434,9 @@ static int qemudNodeGetSecurityModel(virConnectPtr conn, p = driver->caps->host.secModel.doi; if (strlen(p) >= VIR_SECURITY_DOI_BUFLEN-1) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("security DOI string exceeds max %d bytes"), - VIR_SECURITY_DOI_BUFLEN-1); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("security DOI string exceeds max %d bytes"), + VIR_SECURITY_DOI_BUFLEN-1); ret = -1; goto cleanup; } @@ -4473,27 +4465,27 @@ static int qemudDomainRestore(virConnectPtr conn, qemuDriverLock(driver); /* Verify the header and read the XML */ if ((fd = open(path, O_RDONLY)) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("cannot read domain image")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("cannot read domain image")); goto cleanup; } if (saferead(fd, &header, sizeof(header)) != sizeof(header)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to read qemu header")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to read qemu header")); goto cleanup; } if (memcmp(header.magic, QEMUD_SAVE_MAGIC, sizeof(header.magic)) != 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("image magic is incorrect")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("image magic is incorrect")); goto cleanup; } if (header.version > QEMUD_SAVE_VERSION) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("image version is not supported (%d > %d)"), - header.version, QEMUD_SAVE_VERSION); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("image version is not supported (%d > %d)"), + header.version, QEMUD_SAVE_VERSION); goto cleanup; } @@ -4503,16 +4495,16 @@ static int qemudDomainRestore(virConnectPtr conn, } if (saferead(fd, xml, header.xml_len) != header.xml_len) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to read XML")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to read XML")); goto cleanup; } /* Create a domain from this XML */ if (!(def = virDomainDefParseString(conn, driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to parse XML")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to parse XML")); goto cleanup; } @@ -4523,8 +4515,8 @@ static int qemudDomainRestore(virConnectPtr conn, driver->caps, &driver->domains, def))) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to assign new VM")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to assign new VM")); goto cleanup; } def = NULL; @@ -4536,9 +4528,9 @@ static int qemudDomainRestore(virConnectPtr conn, const char *intermediate_argv[3] = { NULL, "-dc", NULL }; const char *prog = qemudSaveCompressionTypeToString(header.compressed); if (prog == NULL) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("Invalid compressed save format %d"), - header.compressed); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("Invalid compressed save format %d"), + header.compressed); goto endjob; } @@ -4548,9 +4540,9 @@ static int qemudDomainRestore(virConnectPtr conn, fd = -1; if (virExec(intermediate_argv, NULL, NULL, &intermediate_pid, intermediatefd, &fd, NULL, 0) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Failed to start decompression binary %s"), - intermediate_argv[0]); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to start decompression binary %s"), + intermediate_argv[0]); goto endjob; } } @@ -4586,8 +4578,8 @@ static int qemudDomainRestore(virConnectPtr conn, qemuDomainObjEnterMonitorWithDriver(driver, vm); if (qemuMonitorStartCPUs(priv->mon, conn) < 0) { if (virGetLastError() == NULL) - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to resume domain")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to resume domain")); qemuDomainObjExitMonitorWithDriver(driver,vm); goto endjob; } @@ -4631,8 +4623,8 @@ static char *qemudDomainDumpXML(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -4681,13 +4673,13 @@ static char *qemuDomainXMLFromNative(virConnectPtr conn, char *xml = NULL; if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INVALID_ARG, - _("unsupported config type %s"), format); + qemuReportError(VIR_ERR_INVALID_ARG, + _("unsupported config type %s"), format); goto cleanup; } qemuDriverLock(driver); - def = qemuParseCommandLineString(conn, driver->caps, config); + def = qemuParseCommandLineString(driver->caps, config); qemuDriverUnlock(driver); if (!def) goto cleanup; @@ -4719,8 +4711,8 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, qemuDriverLock(driver); if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INVALID_ARG, - _("unsupported config type %s"), format); + qemuReportError(VIR_ERR_INVALID_ARG, + _("unsupported config type %s"), format); goto cleanup; } @@ -4778,9 +4770,9 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, if (qemudExtractVersionInfo(emulator, NULL, &qemuCmdFlags) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Cannot determine QEMU argv syntax %s"), - emulator); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot determine QEMU argv syntax %s"), + emulator); goto cleanup; } @@ -4866,8 +4858,8 @@ static int qemudDomainStart(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -4875,8 +4867,8 @@ static int qemudDomainStart(virDomainPtr dom) { goto cleanup; if (virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is already running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is already running")); goto endjob; } @@ -5072,20 +5064,20 @@ static int qemudDomainUndefine(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("cannot delete active domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot delete active domain")); goto cleanup; } if (!vm->persistent) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot undefine transient domain")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot undefine transient domain")); goto cleanup; } @@ -5130,24 +5122,24 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn, } if (!origdisk) { - qemudReportError(conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("No device with bus '%s' and target '%s'"), - virDomainDiskBusTypeToString(disk->bus), - disk->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("No device with bus '%s' and target '%s'"), + virDomainDiskBusTypeToString(disk->bus), + disk->dst); return -1; } if (!origdisk->info.alias) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("missing disk device alias name for %s"), origdisk->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("missing disk device alias name for %s"), origdisk->dst); return -1; } if (origdisk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && origdisk->device != VIR_DOMAIN_DISK_DEVICE_CDROM) { - qemudReportError(conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("Removable media not supported for %s device"), - virDomainDiskDeviceTypeToString(disk->device)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Removable media not supported for %s device"), + virDomainDiskDeviceTypeToString(disk->device)); return -1; } @@ -5200,8 +5192,7 @@ error: } -static int qemudDomainAttachPciDiskDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainAttachPciDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, int qemuCmdFlags) @@ -5214,15 +5205,15 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn, for (i = 0 ; i < vm->def->ndisks ; i++) { if (STREQ(vm->def->disks[i]->dst, disk->dst)) { - qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - _("target %s already exists"), disk->dst); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("target %s already exists"), disk->dst); return -1; } } if (driver->securityDriver && driver->securityDriver->domainSetSecurityImageLabel && - driver->securityDriver->domainSetSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainSetSecurityImageLabel(NULL, vm, disk) < 0) return -1; if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { @@ -5234,7 +5225,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn, if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags))) goto error; - if (!(devstr = qemuBuildDriveDevStr(NULL, disk))) + if (!(devstr = qemuBuildDriveDevStr(disk))) goto error; } @@ -5283,15 +5274,14 @@ error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, disk) < 0) VIR_WARN("Unable to restore security label on %s", disk->src); return -1; } -static int qemudDomainAttachPciControllerDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainAttachPciControllerDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainControllerDefPtr controller, int qemuCmdFlags) @@ -5305,9 +5295,9 @@ static int qemudDomainAttachPciControllerDevice(virConnectPtr conn, for (i = 0 ; i < vm->def->ncontrollers ; i++) { if ((vm->def->controllers[i]->type == controller->type) && (vm->def->controllers[i]->idx == controller->idx)) { - qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - _("target %s:%d already exists"), - type, controller->idx); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("target %s:%d already exists"), + type, controller->idx); return -1; } } @@ -5357,8 +5347,7 @@ cleanup: static virDomainControllerDefPtr -qemuDomainFindOrCreateSCSIDiskController(virConnectPtr conn, - struct qemud_driver *driver, +qemuDomainFindOrCreateSCSIDiskController(struct qemud_driver *driver, virDomainObjPtr vm, int controller, int qemuCmdFlags) @@ -5385,7 +5374,7 @@ qemuDomainFindOrCreateSCSIDiskController(virConnectPtr conn, cont->idx = 0; VIR_INFO0("No SCSI controller present, hotplugging one"); - if (qemudDomainAttachPciControllerDevice(conn, driver, + if (qemudDomainAttachPciControllerDevice(driver, vm, cont, qemuCmdFlags) < 0) { VIR_FREE(cont); return NULL; @@ -5394,8 +5383,7 @@ qemuDomainFindOrCreateSCSIDiskController(virConnectPtr conn, } -static int qemudDomainAttachSCSIDisk(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainAttachSCSIDisk(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, int qemuCmdFlags) @@ -5409,8 +5397,8 @@ static int qemudDomainAttachSCSIDisk(virConnectPtr conn, for (i = 0 ; i < vm->def->ndisks ; i++) { if (STREQ(vm->def->disks[i]->dst, disk->dst)) { - qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - _("target %s already exists"), disk->dst); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("target %s already exists"), disk->dst); return -1; } } @@ -5418,21 +5406,21 @@ static int qemudDomainAttachSCSIDisk(virConnectPtr conn, if (driver->securityDriver && driver->securityDriver->domainSetSecurityImageLabel && - driver->securityDriver->domainSetSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainSetSecurityImageLabel(NULL, vm, disk) < 0) return -1; /* We should have an address already, so make sure */ if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unexpected disk address type %s"), - virDomainDeviceAddressTypeToString(disk->info.type)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk address type %s"), + virDomainDeviceAddressTypeToString(disk->info.type)); goto error; } if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { if (qemuAssignDeviceDiskAlias(disk, qemuCmdFlags) < 0) goto error; - if (!(devstr = qemuBuildDriveDevStr(NULL, disk))) + if (!(devstr = qemuBuildDriveDevStr(disk))) goto error; } @@ -5440,14 +5428,14 @@ static int qemudDomainAttachSCSIDisk(virConnectPtr conn, goto error; for (i = 0 ; i <= disk->info.addr.drive.controller ; i++) { - cont = qemuDomainFindOrCreateSCSIDiskController(conn, driver, vm, i, qemuCmdFlags); + cont = qemuDomainFindOrCreateSCSIDiskController(driver, vm, i, qemuCmdFlags); if (!cont) goto error; } if (cont->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("SCSI controller %d was missing its PCI address"), cont->idx); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("SCSI controller %d was missing its PCI address"), cont->idx); goto error; } @@ -5495,15 +5483,14 @@ error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, disk) < 0) VIR_WARN("Unable to restore security label on %s", disk->src); return -1; } -static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainAttachUsbMassstorageDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, int qemuCmdFlags) @@ -5515,20 +5502,20 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn, for (i = 0 ; i < vm->def->ndisks ; i++) { if (STREQ(vm->def->disks[i]->dst, disk->dst)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("target %s already exists"), disk->dst); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("target %s already exists"), disk->dst); return -1; } } if (driver->securityDriver && driver->securityDriver->domainSetSecurityImageLabel && - driver->securityDriver->domainSetSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainSetSecurityImageLabel(NULL, vm, disk) < 0) return -1; if (!disk->src) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("disk source path is missing")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("disk source path is missing")); goto error; } @@ -5537,7 +5524,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn, goto error; if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags))) goto error; - if (!(devstr = qemuBuildDriveDevStr(NULL, disk))) + if (!(devstr = qemuBuildDriveDevStr(disk))) goto error; } @@ -5575,13 +5562,14 @@ error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, disk) < 0) VIR_WARN("Unable to restore security label on %s", disk->src); return -1; } +/* XXX conn required for network -> bridge resolution */ static int qemudDomainAttachNetDevice(virConnectPtr conn, struct qemud_driver *driver, virDomainObjPtr vm, @@ -5598,18 +5586,18 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, int vlan; if (!(qemuCmdFlags & QEMUD_CMD_FLAG_HOST_NET_ADD)) { - qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, "%s", - _("installed qemu version does not support host_net_add")); + qemuReportError(VIR_ERR_NO_SUPPORT, "%s", + _("installed qemu version does not support host_net_add")); return -1; } if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE || net->type == VIR_DOMAIN_NET_TYPE_NETWORK) { if (priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) { - qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("network device type '%s' cannot be attached: " - "qemu is not using a unix socket monitor"), - virDomainNetTypeToString(net->type)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("network device type '%s' cannot be attached: " + "qemu is not using a unix socket monitor"), + virDomainNetTypeToString(net->type)); return -1; } @@ -5633,8 +5621,8 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, vlan = qemuDomainNetVLAN(net); if (vlan < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s", - _("Unable to attach network devices without vlan")); + qemuReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Unable to attach network devices without vlan")); goto cleanup; } @@ -5650,7 +5638,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, qemuDomainObjExitMonitorWithDriver(driver, vm); } - if (!(netstr = qemuBuildHostNetStr(conn, net, ' ', + if (!(netstr = qemuBuildHostNetStr(net, ' ', vlan, tapfd_name))) goto try_tapfd_close; @@ -5665,7 +5653,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn, close(tapfd); tapfd = -1; - if (!(nicstr = qemuBuildNicStr(conn, net, NULL, vlan))) + if (!(nicstr = qemuBuildNicStr(net, NULL, vlan))) goto try_remove; qemuDomainObjEnterMonitorWithDriver(driver, vm); @@ -5852,9 +5840,9 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn, int qemuCmdFlags) { if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { - qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("hostdev mode '%s' not supported"), - virDomainHostdevModeTypeToString(hostdev->mode)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("hostdev mode '%s' not supported"), + virDomainHostdevModeTypeToString(hostdev->mode)); return -1; } @@ -5877,9 +5865,9 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn, break; default: - qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("hostdev subsys type '%s' not supported"), - virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("hostdev subsys type '%s' not supported"), + virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type)); goto error; } @@ -5910,8 +5898,8 @@ static int qemudDomainAttachDevice(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -5919,8 +5907,8 @@ static int qemudDomainAttachDevice(virDomainPtr dom, goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("cannot attach device on inactive domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot attach device on inactive domain")); goto endjob; } @@ -5937,18 +5925,18 @@ static int qemudDomainAttachDevice(virDomainPtr dom, if (dev->type == VIR_DOMAIN_DEVICE_DISK) { if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_DEVICES)) { if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) !=0 ) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Unable to find cgroup for %s\n"), - vm->def->name); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find cgroup for %s\n"), + vm->def->name); goto endjob; } if (dev->data.disk->src != NULL && dev->data.disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK && virCgroupAllowDevicePath(cgroup, dev->data.disk->src) < 0) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unable to allow device %s"), - dev->data.disk->src); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to allow device %s"), + dev->data.disk->src); goto endjob; } } @@ -5963,32 +5951,32 @@ static int qemudDomainAttachDevice(virDomainPtr dom, case VIR_DOMAIN_DISK_DEVICE_DISK: if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_USB) { - ret = qemudDomainAttachUsbMassstorageDevice(dom->conn, driver, vm, + ret = qemudDomainAttachUsbMassstorageDevice(driver, vm, dev->data.disk, qemuCmdFlags); if (ret == 0) dev->data.disk = NULL; } else if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) { - ret = qemudDomainAttachPciDiskDevice(dom->conn, driver, vm, + ret = qemudDomainAttachPciDiskDevice(driver, vm, dev->data.disk, qemuCmdFlags); if (ret == 0) dev->data.disk = NULL; } else if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) { - ret = qemudDomainAttachSCSIDisk(dom->conn, driver, vm, + ret = qemudDomainAttachSCSIDisk(driver, vm, dev->data.disk, qemuCmdFlags); if (ret == 0) dev->data.disk = NULL; } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("disk bus '%s' cannot be hotplugged."), - virDomainDiskBusTypeToString(dev->data.disk->bus)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("disk bus '%s' cannot be hotplugged."), + virDomainDiskBusTypeToString(dev->data.disk->bus)); /* fallthrough */ } break; default: - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("disk device type '%s' cannot be hotplugged"), - virDomainDiskDeviceTypeToString(dev->data.disk->device)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("disk device type '%s' cannot be hotplugged"), + virDomainDiskDeviceTypeToString(dev->data.disk->device)); /* Fallthrough */ } if (ret != 0 && cgroup) { @@ -5997,12 +5985,12 @@ static int qemudDomainAttachDevice(virDomainPtr dom, } } else if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) { if (dev->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - ret = qemudDomainAttachPciControllerDevice(dom->conn, driver, vm, + ret = qemudDomainAttachPciControllerDevice(driver, vm, dev->data.controller, qemuCmdFlags); } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("disk controller bus '%s' cannot be hotplugged."), - virDomainControllerTypeToString(dev->data.controller->type)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("disk controller bus '%s' cannot be hotplugged."), + virDomainControllerTypeToString(dev->data.controller->type)); /* fallthrough */ } } else if (dev->type == VIR_DOMAIN_DEVICE_NET) { @@ -6016,9 +6004,9 @@ static int qemudDomainAttachDevice(virDomainPtr dom, if (ret == 0) dev->data.hostdev = NULL; } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("device type '%s' cannot be attached"), - virDomainDeviceTypeToString(dev->type)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("device type '%s' cannot be attached"), + virDomainDeviceTypeToString(dev->type)); goto endjob; } @@ -6044,16 +6032,15 @@ static int qemudDomainAttachDeviceFlags(virDomainPtr dom, const char *xml, unsigned int flags) { if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("cannot modify the persistent configuration of a domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot modify the persistent configuration of a domain")); return -1; } return qemudDomainAttachDevice(dom, xml); } -static int qemudDomainDetachPciDiskDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) { @@ -6069,15 +6056,15 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn, } if (!detach) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("disk %s not found"), dev->data.disk->dst); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("disk %s not found"), dev->data.disk->dst); goto cleanup; } if (!virDomainDeviceAddressIsValid(&detach->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); + qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); goto cleanup; } @@ -6106,7 +6093,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn, if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(conn, vm, dev->data.disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, dev->data.disk) < 0) VIR_WARN("Unable to restore security label on %s", dev->data.disk->src); ret = 0; @@ -6115,8 +6102,7 @@ cleanup: return ret; } -static int qemudDomainDetachPciControllerDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainDetachPciControllerDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) { @@ -6133,17 +6119,17 @@ static int qemudDomainDetachPciControllerDevice(virConnectPtr conn, } if (!detach) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("disk controller %s:%d not found"), - virDomainControllerTypeToString(dev->data.controller->type), - dev->data.controller->idx); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("disk controller %s:%d not found"), + virDomainControllerTypeToString(dev->data.controller->type), + dev->data.controller->idx); goto cleanup; } if (!virDomainDeviceAddressIsValid(&detach->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, "%s", - _("device cannot be detached without a PCI address")); + qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("device cannot be detached without a PCI address")); goto cleanup; } @@ -6177,8 +6163,7 @@ cleanup: } static int -qemudDomainDetachNetDevice(virConnectPtr conn, - struct qemud_driver *driver, +qemudDomainDetachNetDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) { @@ -6198,24 +6183,24 @@ qemudDomainDetachNetDevice(virConnectPtr conn, } if (!detach) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("network device %02x:%02x:%02x:%02x:%02x:%02x not found"), - dev->data.net->mac[0], dev->data.net->mac[1], - dev->data.net->mac[2], dev->data.net->mac[3], - dev->data.net->mac[4], dev->data.net->mac[5]); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("network device %02x:%02x:%02x:%02x:%02x:%02x not found"), + dev->data.net->mac[0], dev->data.net->mac[1], + dev->data.net->mac[2], dev->data.net->mac[3], + dev->data.net->mac[4], dev->data.net->mac[5]); goto cleanup; } if (!virDomainDeviceAddressIsValid(&detach->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("device cannot be detached without a PCI address")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("device cannot be detached without a PCI address")); goto cleanup; } if ((vlan = qemuDomainNetVLAN(detach)) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("unable to determine original VLAN")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("unable to determine original VLAN")); goto cleanup; } @@ -6269,8 +6254,7 @@ cleanup: return ret; } -static int qemudDomainDetachHostPciDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainDetachHostPciDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) { @@ -6295,19 +6279,19 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn, } if (!detach) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("host pci device %.4x:%.2x:%.2x.%.1x not found"), - dev->data.hostdev->source.subsys.u.pci.domain, - dev->data.hostdev->source.subsys.u.pci.bus, - dev->data.hostdev->source.subsys.u.pci.slot, - dev->data.hostdev->source.subsys.u.pci.function); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("host pci device %.4x:%.2x:%.2x.%.1x not found"), + dev->data.hostdev->source.subsys.u.pci.domain, + dev->data.hostdev->source.subsys.u.pci.bus, + dev->data.hostdev->source.subsys.u.pci.slot, + dev->data.hostdev->source.subsys.u.pci.function); return -1; } if (!virDomainDeviceAddressIsValid(&detach->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) { - qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("device cannot be detached without a PCI address")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("device cannot be detached without a PCI address")); return -1; } @@ -6354,8 +6338,7 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn, return ret; } -static int qemudDomainDetachHostDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainDetachHostDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) { @@ -6363,26 +6346,26 @@ static int qemudDomainDetachHostDevice(virConnectPtr conn, int ret; if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { - qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("hostdev mode '%s' not supported"), - virDomainHostdevModeTypeToString(hostdev->mode)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("hostdev mode '%s' not supported"), + virDomainHostdevModeTypeToString(hostdev->mode)); return -1; } switch (hostdev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - ret = qemudDomainDetachHostPciDevice(conn, driver, vm, dev); + ret = qemudDomainDetachHostPciDevice(driver, vm, dev); break; default: - qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("hostdev subsys type '%s' not supported"), - virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("hostdev subsys type '%s' not supported"), + virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type)); return -1; } if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityHostdevLabel && - driver->securityDriver->domainRestoreSecurityHostdevLabel(conn, vm, dev->data.hostdev) < 0) + driver->securityDriver->domainRestoreSecurityHostdevLabel(NULL, vm, dev->data.hostdev) < 0) VIR_WARN0("Failed to restore host device labelling"); return ret; @@ -6400,8 +6383,8 @@ static int qemudDomainDetachDevice(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -6409,8 +6392,8 @@ static int qemudDomainDetachDevice(virDomainPtr dom, goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("cannot detach device on inactive domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot detach device on inactive domain")); goto endjob; } @@ -6423,23 +6406,23 @@ static int qemudDomainDetachDevice(virDomainPtr dom, if (dev->type == VIR_DOMAIN_DEVICE_DISK && dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_DISK && dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) { - ret = qemudDomainDetachPciDiskDevice(dom->conn, driver, vm, dev); + ret = qemudDomainDetachPciDiskDevice(driver, vm, dev); } else if (dev->type == VIR_DOMAIN_DEVICE_NET) { - ret = qemudDomainDetachNetDevice(dom->conn, driver, vm, dev); + ret = qemudDomainDetachNetDevice(driver, vm, dev); } else if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) { if (dev->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - ret = qemudDomainDetachPciControllerDevice(dom->conn, driver, vm, dev); + ret = qemudDomainDetachPciControllerDevice(driver, vm, dev); } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - _("disk controller bus '%s' cannot be hotunplugged."), - virDomainControllerTypeToString(dev->data.controller->type)); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("disk controller bus '%s' cannot be hotunplugged."), + virDomainControllerTypeToString(dev->data.controller->type)); /* fallthrough */ } } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { - ret = qemudDomainDetachHostDevice(dom->conn, driver, vm, dev); + ret = qemudDomainDetachHostDevice(driver, vm, dev); } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("This type of device cannot be hot unplugged")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("This type of device cannot be hot unplugged")); } if (!ret && virDomainSaveStatus(dom->conn, driver->caps, driver->stateDir, vm) < 0) @@ -6461,8 +6444,8 @@ static int qemudDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, unsigned int flags) { if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("cannot modify the persistent configuration of a domain")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot modify the persistent configuration of a domain")); return -1; } @@ -6482,8 +6465,8 @@ static int qemudDomainGetAutostart(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -6509,14 +6492,14 @@ static int qemudDomainSetAutostart(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!vm->persistent) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot set autostart for transient domain")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot set autostart for transient domain")); goto cleanup; } @@ -6575,8 +6558,8 @@ static char *qemuGetSchedulerType(virDomainPtr dom, qemuDriverLock(driver); if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - __FUNCTION__); + qemuReportError(VIR_ERR_NO_SUPPORT, + __FUNCTION__); goto cleanup; } @@ -6604,22 +6587,22 @@ static int qemuSetSchedulerParameters(virDomainPtr dom, qemuDriverLock(driver); if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - __FUNCTION__); + qemuReportError(VIR_ERR_NO_SUPPORT, + __FUNCTION__); goto cleanup; } vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (vm == NULL) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("No such domain %s"), dom->uuid); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("No such domain %s"), dom->uuid); goto cleanup; } if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find cgroup for domain %s"), vm->def->name); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find cgroup for domain %s"), vm->def->name); goto cleanup; } @@ -6629,8 +6612,8 @@ static int qemuSetSchedulerParameters(virDomainPtr dom, if (STREQ(param->field, "cpu_shares")) { int rc; if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, "%s", - _("invalid type for cpu_shares tunable, expected a 'ullong'")); + qemuReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid type for cpu_shares tunable, expected a 'ullong'")); goto cleanup; } @@ -6641,8 +6624,8 @@ static int qemuSetSchedulerParameters(virDomainPtr dom, goto cleanup; } } else { - qemudReportError(dom->conn, domain, NULL, VIR_ERR_INVALID_ARG, - _("Invalid parameter `%s'"), param->field); + qemuReportError(VIR_ERR_INVALID_ARG, + _("Invalid parameter `%s'"), param->field); goto cleanup; } } @@ -6669,28 +6652,28 @@ static int qemuGetSchedulerParameters(virDomainPtr dom, qemuDriverLock(driver); if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - __FUNCTION__); + qemuReportError(VIR_ERR_NO_SUPPORT, + __FUNCTION__); goto cleanup; } if ((*nparams) != 1) { - qemudReportError(dom->conn, domain, NULL, VIR_ERR_INVALID_ARG, - "%s", _("Invalid parameter count")); + qemuReportError(VIR_ERR_INVALID_ARG, + "%s", _("Invalid parameter count")); goto cleanup; } vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (vm == NULL) { - qemudReportError(dom->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR, - _("No such domain %s"), dom->uuid); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("No such domain %s"), dom->uuid); goto cleanup; } if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find cgroup for domain %s"), vm->def->name); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find cgroup for domain %s"), vm->def->name); goto cleanup; } @@ -6703,8 +6686,8 @@ static int qemuGetSchedulerParameters(virDomainPtr dom, params[0].value.ul = val; params[0].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; if (virStrcpyStatic(params[0].field, "cpu_shares") == NULL) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("Field cpu_shares too long for destination")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Field cpu_shares too long for destination")); goto cleanup; } @@ -6739,8 +6722,8 @@ qemudDomainBlockStats (virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -6748,8 +6731,8 @@ qemudDomainBlockStats (virDomainPtr dom, goto cleanup; if (!virDomainObjIsActive (vm)) { - qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } @@ -6761,14 +6744,14 @@ qemudDomainBlockStats (virDomainPtr dom, } if (!disk) { - qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - _("invalid path: %s"), path); + qemuReportError(VIR_ERR_INVALID_ARG, + _("invalid path: %s"), path); goto endjob; } if (!disk->info.alias) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("missing disk device alias name for %s"), disk->dst); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("missing disk device alias name for %s"), disk->dst); goto endjob; } @@ -6811,14 +6794,14 @@ qemudDomainInterfaceStats (virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto cleanup; } @@ -6834,8 +6817,8 @@ qemudDomainInterfaceStats (virDomainPtr dom, if (ret == 0) ret = linuxDomainInterfaceStats(path, stats); else - qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - _("invalid path, '%s' is not a known interface"), path); + qemuReportError(VIR_ERR_INVALID_ARG, + _("invalid path, '%s' is not a known interface"), path); cleanup: if (vm) @@ -6847,8 +6830,8 @@ static int qemudDomainInterfaceStats (virDomainPtr dom, const char *path ATTRIBUTE_UNUSED, struct _virDomainInterfaceStats *stats ATTRIBUTE_UNUSED) - qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, - "%s", __FUNCTION__); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", __FUNCTION__); return -1; } #endif @@ -6869,8 +6852,8 @@ qemudDomainMemoryStats (virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -6880,8 +6863,8 @@ qemudDomainMemoryStats (virDomainPtr dom, ret = qemuMonitorTextGetMemoryStats(priv->mon, stats, nr_stats); qemuDomainObjExitMonitor(vm); } else { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); } cleanup: @@ -6908,14 +6891,14 @@ qemudDomainBlockPeek (virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!path || path[0] == '\0') { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - "%s", _("NULL or empty path")); + qemuReportError(VIR_ERR_INVALID_ARG, + "%s", _("NULL or empty path")); goto cleanup; } @@ -6951,8 +6934,8 @@ qemudDomainBlockPeek (virDomainPtr dom, ret = 0; } else { - qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - "%s", _("invalid path")); + qemuReportError(VIR_ERR_INVALID_ARG, + "%s", _("invalid path")); } cleanup: @@ -6981,14 +6964,14 @@ qemudDomainMemoryPeek (virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (flags != VIR_MEMORY_VIRTUAL && flags != VIR_MEMORY_PHYSICAL) { - qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, - "%s", _("flags parameter must be VIR_MEMORY_VIRTUAL or VIR_MEMORY_PHYSICAL")); + qemuReportError(VIR_ERR_INVALID_ARG, + "%s", _("flags parameter must be VIR_MEMORY_VIRTUAL or VIR_MEMORY_PHYSICAL")); goto cleanup; } @@ -6996,8 +6979,8 @@ qemudDomainMemoryPeek (virDomainPtr dom, goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } @@ -7163,15 +7146,15 @@ static int qemuStreamMigRemoveCallback(virStreamPtr stream) int ret = -1; if (!qemust) { - qemudReportError(stream->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("stream is not open")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("stream is not open")); return -1; } qemuDriverLock(driver); if (qemust->watch == 0) { - qemudReportError(stream->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("stream does not have a callback registered")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("stream does not have a callback registered")); goto cleanup; } @@ -7200,15 +7183,15 @@ static int qemuStreamMigUpdateCallback(virStreamPtr stream, int events) int ret = -1; if (!qemust) { - qemudReportError(stream->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("stream is not open")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("stream is not open")); return -1; } qemuDriverLock(driver); if (qemust->watch == 0) { - qemudReportError(stream->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("stream does not have a callback registered")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("stream does not have a callback registered")); goto cleanup; } @@ -7266,15 +7249,15 @@ qemuStreamMigAddCallback(virStreamPtr st, int ret = -1; if (!qemust) { - qemudReportError(st->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("stream is not open")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("stream is not open")); return -1; } qemuDriverLock(driver); if (qemust->watch != 0) { - qemudReportError(st->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("stream already has a callback registered")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("stream already has a callback registered")); goto cleanup; } @@ -7283,8 +7266,8 @@ qemuStreamMigAddCallback(virStreamPtr st, qemuStreamMigEvent, st, NULL)) < 0) { - qemudReportError(st->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot register file watch on stream")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot register file watch on stream")); goto cleanup; } @@ -7382,8 +7365,8 @@ static int qemuStreamMigWrite(virStreamPtr st, const char *bytes, size_t nbytes) int ret; if (!qemust) { - qemudReportError(st->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("stream is not open")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("stream is not open")); return -1; } @@ -7442,26 +7425,26 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, qemuDriverLock(driver); if (!dom_xml) { - qemudReportError(dconn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("no domain XML passed")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no domain XML passed")); goto cleanup; } if (!(flags & VIR_MIGRATE_TUNNELLED)) { - qemudReportError(dconn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PrepareTunnel called but no TUNNELLED flag set")); goto cleanup; } if (st == NULL) { - qemudReportError(dconn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("tunnelled migration requested but NULL stream passed")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("tunnelled migration requested but NULL stream passed")); goto cleanup; } /* Parse the domain XML. */ if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml, VIR_DOMAIN_XML_INACTIVE))) { - qemudReportError(dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to parse XML")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to parse XML")); goto cleanup; } @@ -7475,8 +7458,8 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, driver->caps, &driver->domains, def))) { - qemudReportError(dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to assign new VM")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to assign new VM")); goto cleanup; } def = NULL; @@ -7496,9 +7479,9 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, /* check that this qemu version supports the interactive exec */ if (qemudExtractVersionInfo(vm->def->emulator, NULL, &qemuCmdFlags) < 0) { - qemudReportError(dconn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Cannot determine QEMU argv syntax %s"), - vm->def->emulator); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot determine QEMU argv syntax %s"), + vm->def->emulator); goto endjob; } if (qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX) @@ -7506,8 +7489,8 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, else if (qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC) internalret = virAsprintf(&migrateFrom, "exec:nc -U -l %s", unixfile); else { - qemudReportError(dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("Destination qemu is too old to support tunnelled migration")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("Destination qemu is too old to support tunnelled migration")); goto endjob; } if (internalret < 0) { @@ -7604,14 +7587,14 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, /* this is a logical error; we never should have gotten here with * VIR_MIGRATE_TUNNELLED set */ - qemudReportError(dconn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("Tunnelled migration requested but invalid RPC method called")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Tunnelled migration requested but invalid RPC method called")); goto cleanup; } if (!dom_xml) { - qemudReportError (dconn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("no domain XML passed")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no domain XML passed")); goto cleanup; } @@ -7651,8 +7634,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, * characters in hostname part don't matter. */ if (!STRPREFIX (uri_in, "tcp:")) { - qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, - "%s", _("only tcp URIs are supported for KVM/QEMU migrations")); + qemuReportError (VIR_ERR_INVALID_ARG, + "%s", _("only tcp URIs are supported for KVM/QEMU migrations")); goto cleanup; } @@ -7674,8 +7657,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, p++; /* definitely has a ':' in it, see above */ this_port = virParseNumber (&p); if (this_port == -1 || p-uri_in != strlen (uri_in)) { - qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, - "%s", _("URI ended with incorrect ':port'")); + qemuReportError(VIR_ERR_INVALID_ARG, + "%s", _("URI ended with incorrect ':port'")); goto cleanup; } } @@ -7687,8 +7670,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, /* Parse the domain XML. */ if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml, VIR_DOMAIN_XML_INACTIVE))) { - qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to parse XML")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to parse XML")); goto cleanup; } @@ -7702,8 +7685,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, driver->caps, &driver->domains, def))) { - qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to assign new VM")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to assign new VM")); goto cleanup; } def = NULL; @@ -7758,8 +7741,7 @@ cleanup: /* Perform migration using QEMU's native TCP migrate support, * not encrypted obviously */ -static int doNativeMigrate(virDomainPtr dom, - struct qemud_driver *driver, +static int doNativeMigrate(struct qemud_driver *driver, virDomainObjPtr vm, const char *uri, unsigned long flags ATTRIBUTE_UNUSED, @@ -7786,8 +7768,8 @@ static int doNativeMigrate(virDomainPtr dom, uribits = xmlParseURI(uri); } if (!uribits) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse URI %s"), uri); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse URI %s"), uri); goto cleanup; } @@ -7817,8 +7799,8 @@ static int doNativeMigrate(virDomainPtr dom, qemuDomainObjExitMonitorWithDriver(driver, vm); if (status != QEMU_MONITOR_MIGRATION_STATUS_COMPLETED) { - qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("migrate did not successfully complete")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("migrate did not successfully complete")); goto cleanup; } @@ -7830,8 +7812,7 @@ cleanup: } -static int doTunnelSendAll(virDomainPtr dom, - virStreamPtr st, +static int doTunnelSendAll(virStreamPtr st, int sock) { char buffer[65536]; @@ -7851,8 +7832,8 @@ static int doTunnelSendAll(virDomainPtr dom, break; if (virStreamSend(st, buffer, nbytes) < 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, "%s", - _("Failed to write migration data to remote libvirtd")); + qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("Failed to write migration data to remote libvirtd")); return -1; } } @@ -7917,9 +7898,9 @@ static int doTunnelMigrate(virDomainPtr dom, sa_qemu.sun_family = AF_UNIX; if (virStrcpy(sa_qemu.sun_path, unixfile, sizeof(sa_qemu.sun_path)) == NULL) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Unix socket '%s' too big for destination"), - unixfile); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Unix socket '%s' too big for destination"), + unixfile); goto cleanup; } unlink(unixfile); @@ -7938,16 +7919,16 @@ static int doTunnelMigrate(virDomainPtr dom, /* check that this qemu version supports the unix migration */ if (qemudExtractVersionInfo(vm->def->emulator, NULL, &qemuCmdFlags) < 0) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Cannot extract Qemu version from '%s'"), - vm->def->emulator); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot extract Qemu version from '%s'"), + vm->def->emulator); goto cleanup; } if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX) && !(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC)) { - qemudReportError(dom->conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("Source qemu is too old to support tunnelled migration")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("Source qemu is too old to support tunnelled migration")); goto cleanup; } @@ -7982,8 +7963,8 @@ static int doTunnelMigrate(virDomainPtr dom, } qemuDomainObjExitMonitorWithDriver(driver, vm); if (internalret < 0) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("tunnelled migration monitor command failed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("tunnelled migration monitor command failed")); goto finish; } @@ -8005,8 +7986,8 @@ static int doTunnelMigrate(virDomainPtr dom, qemuDomainObjExitMonitorWithDriver(driver, vm); if (status == QEMU_MONITOR_MIGRATION_STATUS_ERROR) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s",_("migrate failed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s",_("migrate failed")); goto cancel; } @@ -8019,7 +8000,7 @@ static int doTunnelMigrate(virDomainPtr dom, goto cancel; } - retval = doTunnelSendAll(dom, st, client_sock); + retval = doTunnelSendAll(st, client_sock); cancel: if (retval != 0) { @@ -8084,12 +8065,12 @@ static int doNonTunnelMigrate(virDomainPtr dom, goto cleanup; if (uri_out == NULL) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("domainMigratePrepare2 did not set uri")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domainMigratePrepare2 did not set uri")); goto cleanup; } - if (doNativeMigrate(dom, driver, vm, uri_out, flags, dname, resource) < 0) + if (doNativeMigrate(driver, vm, uri_out, flags, dname, resource) < 0) goto finish; retval = 0; @@ -8125,21 +8106,21 @@ static int doPeer2PeerMigrate(virDomainPtr dom, dconn = virConnectOpen(uri); if (dconn == NULL) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - _("Failed to connect to remote libvirt URI %s"), uri); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("Failed to connect to remote libvirt URI %s"), uri); return -1; } if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_P2P)) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, "%s", - _("Destination libvirt does not support peer-to-peer migration protocol")); + qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("Destination libvirt does not support peer-to-peer migration protocol")); goto cleanup; } dom_xml = virDomainDefFormat(dom->conn, vm->def, VIR_DOMAIN_XML_SECURE); if (!dom_xml) { - qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to get domain xml")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to get domain xml")); goto cleanup; } @@ -8178,8 +8159,8 @@ qemudDomainMigratePerform (virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -8187,8 +8168,8 @@ qemudDomainMigratePerform (virDomainPtr dom, goto cleanup; if (!virDomainObjIsActive(vm)) { - qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); goto endjob; } @@ -8217,7 +8198,7 @@ qemudDomainMigratePerform (virDomainPtr dom, /* doPeer2PeerMigrate already set the error, so just get out */ goto endjob; } else { - if (doNativeMigrate(dom, driver, vm, uri, flags, dname, resource) < 0) + if (doNativeMigrate(driver, vm, uri, flags, dname, resource) < 0) goto endjob; } @@ -8292,8 +8273,8 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn, qemuDriverLock(driver); vm = virDomainFindByName(&driver->domains, dname); if (!vm) { - qemudReportError (dconn, NULL, NULL, VIR_ERR_NO_DOMAIN, - _("no domain with matching name '%s'"), dname); + qemuReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching name '%s'"), dname); goto cleanup; } @@ -8344,8 +8325,8 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn, qemuDomainObjEnterMonitorWithDriver(driver, vm); if (qemuMonitorStartCPUs(priv->mon, dconn) < 0) { if (virGetLastError() == NULL) - qemudReportError(dconn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("resume operation failed")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("resume operation failed")); qemuDomainObjExitMonitorWithDriver(driver, vm); goto endjob; } @@ -8428,8 +8409,8 @@ qemudNodeDeviceGetPciInfo (virNodeDevicePtr dev, } if (!cap) { - qemudReportError(dev->conn, NULL, NULL, VIR_ERR_INVALID_ARG, - _("device %s is not a PCI device"), dev->name); + qemuReportError(VIR_ERR_INVALID_ARG, + _("device %s is not a PCI device"), dev->name); goto out; } @@ -8524,8 +8505,8 @@ qemuCPUCompare(virConnectPtr conn, qemuDriverLock(driver); if (!driver->caps || !driver->caps->host.cpu) { - qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", _("cannot get host CPU capabilities")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", _("cannot get host CPU capabilities")); } else ret = cpuCompareXML(conn, driver->caps->host.cpu, xmlDesc); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b702a81..64c6cba 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -240,8 +240,8 @@ qemuMonitorOpenUnix(const char *monitor) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; if (virStrcpyStatic(addr.sun_path, monitor) == NULL) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Monitor path %s too big for destination"), monitor); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Monitor path %s too big for destination"), monitor); goto error; } @@ -282,8 +282,8 @@ qemuMonitorOpenPty(const char *monitor) int monfd; if ((monfd = open(monitor, O_RDWR)) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Unable to open monitor path %s"), monitor); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open monitor path %s"), monitor); return -1; } @@ -569,8 +569,8 @@ qemuMonitorOpen(virDomainObjPtr vm, qemuMonitorPtr mon; if (!cb || !cb->eofNotify) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("EOF notify callback must be supplied")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("EOF notify callback must be supplied")); return NULL; } @@ -580,14 +580,14 @@ qemuMonitorOpen(virDomainObjPtr vm, } if (virMutexInit(&mon->lock) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize monitor mutex")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot initialize monitor mutex")); VIR_FREE(mon); return NULL; } if (virCondInit(&mon->notify) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize monitor condition")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot initialize monitor condition")); virMutexDestroy(&mon->lock); VIR_FREE(mon); return NULL; @@ -610,22 +610,22 @@ qemuMonitorOpen(virDomainObjPtr vm, break; default: - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unable to handle monitor type: %s"), - virDomainChrTypeToString(config->type)); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to handle monitor type: %s"), + virDomainChrTypeToString(config->type)); goto cleanup; } if (mon->fd == -1) goto cleanup; if (virSetCloseExec(mon->fd) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("Unable to set monitor close-on-exec flag")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Unable to set monitor close-on-exec flag")); goto cleanup; } if (virSetNonBlock(mon->fd) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("Unable to put monitor into non-blocking mode")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Unable to put monitor into non-blocking mode")); goto cleanup; } @@ -636,8 +636,8 @@ qemuMonitorOpen(virDomainObjPtr vm, VIR_EVENT_HANDLE_READABLE, qemuMonitorIO, mon, NULL)) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("unable to register monitor events")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unable to register monitor events")); goto cleanup; } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 25ddfa9..e5288ce 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -215,8 +215,8 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon, if (ret == 0) { if (!((*reply) = virJSONValueFromString(msg.rxBuffer))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse JSON doc '%s'"), msg.rxBuffer); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse JSON doc '%s'"), msg.rxBuffer); goto cleanup; } } @@ -269,15 +269,15 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd, if (!error) { VIR_DEBUG("Saw a JSON error, but value is null for %s: %s", cmdstr, replystr); - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("error running QEMU command '%s': '%s'"), - cmdstr, replystr); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("error running QEMU command '%s': '%s'"), + cmdstr, replystr); } else { VIR_DEBUG("Got a JSON error set for %s", cmdstr); char *detail = qemuMonitorJSONStringifyError(error); - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("error running QEMU command '%s': %s ('%s')"), - cmdstr, detail, replystr); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("error running QEMU command '%s': %s ('%s')"), + cmdstr, detail, replystr); VIR_FREE(detail); } VIR_FREE(cmdstr); @@ -289,8 +289,8 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd, VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s", cmdstr, replystr); - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("error running QEMU command '%s': '%s'"), cmdstr, replystr); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("error running QEMU command '%s': '%s'"), cmdstr, replystr); VIR_FREE(cmdstr); VIR_FREE(replystr); return -1; @@ -380,9 +380,9 @@ qemuMonitorJSONMakeCommand(const char *cmdname, char type; if (strlen(key) < 3) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("argument key '%s' is too short, missing type prefix"), - key); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("argument key '%s' is too short, missing type prefix"), + key); goto error; } @@ -429,8 +429,8 @@ qemuMonitorJSONMakeCommand(const char *cmdname, ret = virJSONValueObjectAppendNull(jargs, key); } break; default: - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unsupported data type '%c' for arg '%s'"), type, key - 2); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported data type '%c' for arg '%s'"), type, key - 2); goto error; } if (ret < 0) @@ -551,20 +551,20 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply, int ncpus; if (!(data = virJSONValueObjectGet(reply, "return"))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cpu reply was missing return data")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cpu reply was missing return data")); goto cleanup; } if (data->type != VIR_JSON_TYPE_ARRAY) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cpu information was not an array")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cpu information was not an array")); goto cleanup; } if ((ncpus = virJSONValueArraySize(data)) <= 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cpu information was empty")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cpu information was empty")); goto cleanup; } @@ -578,27 +578,27 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply, int cpu; int thread; if (!entry) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("character device information was missing aray element")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("character device information was missing aray element")); goto cleanup; } if (virJSONValueObjectGetNumberInt(entry, "CPU", &cpu) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cpu information was missing cpu number")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cpu information was missing cpu number")); goto cleanup; } if (virJSONValueObjectGetNumberInt(entry, "thread_id", &thread) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("cpu information was missing thread ID")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cpu information was missing thread ID")); goto cleanup; } if (cpu != i) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unexpected cpu index %d expecting %d"), - i, cpu); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected cpu index %d expecting %d"), + i, cpu); goto cleanup; } @@ -676,15 +676,15 @@ int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon, unsigned long long mem; if (!(data = virJSONValueObjectGet(reply, "return"))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("info balloon reply was missing return data")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("info balloon reply was missing return data")); ret = -1; goto cleanup; } if (virJSONValueObjectGetNumberUlong(data, "balloon", &mem) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("info balloon reply was missing balloon data")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("info balloon reply was missing balloon data")); ret = -1; goto cleanup; } @@ -733,8 +733,8 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon, devices = virJSONValueObjectGet(reply, "return"); if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("blockstats reply was missing device list")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("blockstats reply was missing device list")); goto cleanup; } @@ -743,14 +743,14 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon, virJSONValuePtr stats; const char *thisdev; if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("blockstats device entry was not in expected format")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("blockstats device entry was not in expected format")); goto cleanup; } if ((thisdev = virJSONValueObjectGetString(dev, "device")) == NULL) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("blockstats device entry was not in expected format")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("blockstats device entry was not in expected format")); goto cleanup; } @@ -760,40 +760,40 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon, found = 1; if ((stats = virJSONValueObjectGet(dev, "stats")) == NULL || stats->type != VIR_JSON_TYPE_OBJECT) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("blockstats stats entry was not in expected format")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("blockstats stats entry was not in expected format")); goto cleanup; } if (virJSONValueObjectGetNumberLong(stats, "rd_bytes", rd_bytes) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot read %s statistic"), - "rd_bytes"); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot read %s statistic"), + "rd_bytes"); goto cleanup; } if (virJSONValueObjectGetNumberLong(stats, "rd_operations", rd_req) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot read %s statistic"), - "rd_operations"); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot read %s statistic"), + "rd_operations"); goto cleanup; } if (virJSONValueObjectGetNumberLong(stats, "wr_bytes", wr_bytes) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot read %s statistic"), - "wr_bytes"); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot read %s statistic"), + "wr_bytes"); goto cleanup; } if (virJSONValueObjectGetNumberLong(stats, "wr_operations", wr_req) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot read %s statistic"), - "wr_operations"); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot read %s statistic"), + "wr_operations"); goto cleanup; } } if (!found) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot find statistics for device '%s'"), devname); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find statistics for device '%s'"), devname); goto cleanup; } ret = 0; @@ -1007,44 +1007,44 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply, const char *statusstr; if (!(ret = virJSONValueObjectGet(reply, "return"))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("info migration reply was missing return data")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("info migration reply was missing return data")); return -1; } if (!(statusstr = virJSONValueObjectGetString(ret, "status"))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("info migration reply was missing return status")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("info migration reply was missing return status")); return -1; } if ((*status = qemuMonitorMigrationStatusTypeFromString(statusstr)) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unexpected migration status in %s"), statusstr); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected migration status in %s"), statusstr); return -1; } if (*status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE) { virJSONValuePtr ram = virJSONValueObjectGet(ret, "ram"); if (!ram) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but no RAM info was set")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but no RAM info was set")); return -1; } if (virJSONValueObjectGetNumberUlong(ram, "transferred", transferred) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'transferred' data was missing")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'transferred' data was missing")); return -1; } if (virJSONValueObjectGetNumberUlong(ram, "remaining", remaining) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'remaining' data was missing")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'remaining' data was missing")); return -1; } if (virJSONValueObjectGetNumberUlong(ram, "total", total) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("migration was active, but RAM 'total' data was missing")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("migration was active, but RAM 'total' data was missing")); return -1; } } @@ -1299,32 +1299,32 @@ qemuMonitorJSONGetGuestPCIAddress(virJSONValuePtr reply, addr = virJSONValueObjectGet(reply, "return"); if (!addr || addr->type != VIR_JSON_TYPE_OBJECT) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("pci_add reply was missing device address")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pci_add reply was missing device address")); return -1; } if (virJSONValueObjectGetNumberUint(addr, "domain", &guestAddr->domain) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("pci_add reply was missing device domain number")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pci_add reply was missing device domain number")); return -1; } if (virJSONValueObjectGetNumberUint(addr, "bus", &guestAddr->bus) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("pci_add reply was missing device bus number")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pci_add reply was missing device bus number")); return -1; } if (virJSONValueObjectGetNumberUint(addr, "slot", &guestAddr->slot) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("pci_add reply was missing device slot number")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pci_add reply was missing device slot number")); return -1; } if (virJSONValueObjectGetNumberUint(addr, "function", &guestAddr->function) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("pci_add reply was missing device function number")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pci_add reply was missing device function number")); return -1; } @@ -1589,14 +1589,14 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply, int i; if (!(data = virJSONValueObjectGet(reply, "return"))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("character device reply was missing return data")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("character device reply was missing return data")); goto cleanup; } if (data->type != VIR_JSON_TYPE_ARRAY) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("character device information was not an array")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("character device information was not an array")); goto cleanup; } @@ -1605,20 +1605,20 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply, const char *type; const char *id; if (!entry) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("character device information was missing aray element")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("character device information was missing aray element")); goto cleanup; } if (!(type = virJSONValueObjectGetString(entry, "filename"))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("character device information was missing filename")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("character device information was missing filename")); goto cleanup; } if (!(id = virJSONValueObjectGetString(entry, "label"))) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("character device information was missing filename")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("character device information was missing filename")); goto cleanup; } @@ -1630,8 +1630,8 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply, } if (virHashAddEntry(paths, id, path) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to save chardev path '%s'"), path); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to save chardev path '%s'"), path); VIR_FREE(path); goto cleanup; } @@ -1718,20 +1718,20 @@ qemuMonitorJSONGetGuestDriveAddress(virJSONValuePtr reply, addr = virJSONValueObjectGet(reply, "return"); if (!addr || addr->type != VIR_JSON_TYPE_OBJECT) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("drive_add reply was missing device address")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("drive_add reply was missing device address")); return -1; } if (virJSONValueObjectGetNumberUint(addr, "bus", &driveAddr->bus) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("drive_add reply was missing device bus number")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("drive_add reply was missing device bus number")); return -1; } if (virJSONValueObjectGetNumberUint(addr, "unit", &driveAddr->unit) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("drive_add reply was missing device unit number")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("drive_add reply was missing device unit number")); return -1; } @@ -1781,8 +1781,8 @@ int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon, int qemuMonitorJSONGetAllPCIAddresses(qemuMonitorPtr mon ATTRIBUTE_UNUSED, qemuMonitorPCIAddress **addrs ATTRIBUTE_UNUSED) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("query-pci not suppported in JSON mode")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-pci not suppported in JSON mode")); return -1; } diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index b8fa64f..23fc4cf 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -366,8 +366,8 @@ qemuMonitorTextStopCPUs(qemuMonitorPtr mon) { char *info; if (qemuMonitorCommand(mon, "stop", &info) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("cannot stop CPU execution")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("cannot stop CPU execution")); return -1; } VIR_FREE(info); @@ -379,8 +379,8 @@ int qemuMonitorTextSystemPowerdown(qemuMonitorPtr mon) { char *info; if (qemuMonitorCommand(mon, "system_powerdown", &info) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("system shutdown operation failed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("system shutdown operation failed")); return -1; } VIR_FREE(info); @@ -398,8 +398,8 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon, size_t ncpupids = 0; if (qemuMonitorCommand(mon, "info cpus", &qemucpus) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot run monitor command to fetch CPU thread info")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot run monitor command to fetch CPU thread info")); return -1; } @@ -550,8 +550,8 @@ int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon, char *offset; if (qemuMonitorCommand(mon, "info balloon", &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("could not query memory balloon allocation")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("could not query memory balloon allocation")); return -1; } @@ -560,8 +560,8 @@ int qemuMonitorTextGetBalloonInfo(qemuMonitorPtr mon, char *end; offset += strlen(BALLOON_PREFIX); if (virStrToLong_ui(offset, &end, 10, &memMB) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("could not parse memory balloon allocation from '%s'"), reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("could not parse memory balloon allocation from '%s'"), reply); goto cleanup; } *currmem = memMB * 1024; @@ -587,8 +587,8 @@ int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon, char *offset; if (qemuMonitorCommand(mon, "info balloon", &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("could not query memory balloon statistics")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("could not query memory balloon statistics")); return -1; } @@ -618,8 +618,8 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon, int devnamelen = strlen(devname); if (qemuMonitorCommand (mon, "info blockstats", &info) < 0) { - qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("'info blockstats' command failed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("'info blockstats' command failed")); goto cleanup; } @@ -629,9 +629,9 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon, * to detect if qemu supports the command. */ if (strstr(info, "\ninfo ")) { - qemudReportError (NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, - "%s", - _("'info blockstats' not supported by this qemu")); + qemuReportError(VIR_ERR_NO_SUPPORT, + "%s", + _("'info blockstats' not supported by this qemu")); goto cleanup; } @@ -694,8 +694,8 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon, } /* If we reach here then the device was not found. */ - qemudReportError (NULL, NULL, NULL, VIR_ERR_INVALID_ARG, - _("no stats found for device %s"), devname); + qemuReportError (VIR_ERR_INVALID_ARG, + _("no stats found for device %s"), devname); cleanup: VIR_FREE(info); @@ -741,8 +741,8 @@ int qemuMonitorTextSetVNCPassword(qemuMonitorPtr mon, qemuMonitorSendVNCPassphrase, (char *)password, -1, &info) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("setting VNC password failed")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("setting VNC password failed")); return -1; } VIR_FREE(info); @@ -770,8 +770,8 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("could not balloon memory allocation")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("could not balloon memory allocation")); VIR_FREE(cmd); return -1; } @@ -803,8 +803,8 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("could not eject media on %s"), devname); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("could not eject media on %s"), devname); goto cleanup; } @@ -812,8 +812,8 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon, * device not found, device is locked ... * No message is printed on success it seems */ if (strstr(reply, "\ndevice ")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("could not eject media on %s: %s"), devname, reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("could not eject media on %s: %s"), devname, reply); goto cleanup; } @@ -847,8 +847,8 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("could not eject media on %s"), devname); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("could not eject media on %s"), devname); goto cleanup; } @@ -856,8 +856,8 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon, * device not found, device is locked ... * No message is printed on success it seems */ if (strstr(reply, "\ndevice ")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("could not eject media on %s: %s"), devname, reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("could not eject media on %s: %s"), devname, reply); goto cleanup; } @@ -892,8 +892,8 @@ static int qemuMonitorTextSaveMemory(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("could save memory region to '%s'"), path); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("could save memory region to '%s'"), path); goto cleanup; } @@ -939,8 +939,8 @@ int qemuMonitorTextSetMigrationSpeed(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &info) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("could restrict migration speed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("could restrict migration speed")); goto cleanup; } @@ -974,8 +974,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, *total = 0; if (qemuMonitorCommand(mon, "info migrate", &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("cannot query migration status")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("cannot query migration status")); return -1; } @@ -985,8 +985,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, *end = '\0'; if ((*status = qemuMonitorMigrationStatusTypeFromString(tmp)) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unexpected migration status in %s"), reply); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected migration status in %s"), reply); goto cleanup; } @@ -998,8 +998,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, tmp += strlen(MIGRATION_TRANSFER_PREFIX); if (virStrToLong_ull(tmp, NULL, 10, transferred) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse migration data transferred statistic %s"), tmp); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse migration data transferred statistic %s"), tmp); goto cleanup; } *transferred *= 1024; @@ -1009,8 +1009,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, tmp += strlen(MIGRATION_REMAINING_PREFIX); if (virStrToLong_ull(tmp, NULL, 10, remaining) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse migration data remaining statistic %s"), tmp); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse migration data remaining statistic %s"), tmp); goto cleanup; } *remaining *= 1024; @@ -1020,8 +1020,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, tmp += strlen(MIGRATION_TOTAL_PREFIX); if (virStrToLong_ull(tmp, NULL, 10, total) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse migration data total statistic %s"), tmp); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse migration data total statistic %s"), tmp); goto cleanup; } *total *= 1024; @@ -1064,22 +1064,22 @@ static int qemuMonitorTextMigrate(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &info) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("unable to start migration to %s"), dest); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to start migration to %s"), dest); goto cleanup; } /* Now check for "fail" in the output string */ if (strstr(info, "fail") != NULL) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("migration to '%s' failed: %s"), dest, info); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("migration to '%s' failed: %s"), dest, info); goto cleanup; } /* If the command isn't supported then qemu prints: * unknown command: migrate" */ if (strstr(info, "unknown command:")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, - _("migration to '%s' not supported by this qemu: %s"), dest, info); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("migration to '%s' not supported by this qemu: %s"), dest, info); goto cleanup; } @@ -1175,8 +1175,8 @@ int qemuMonitorTextMigrateCancel(qemuMonitorPtr mon) char *info = NULL; if (qemuMonitorCommand(mon, "migrate_cancel", &info) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot run monitor command to cancel migration")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot run monitor command to cancel migration")); return -1; } VIR_FREE(info); @@ -1204,16 +1204,16 @@ int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &info) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot run monitor command to add usb disk")); + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot run monitor command to add usb disk")); goto cleanup; } /* If the command failed qemu prints: * Could not add ... */ if (strstr(info, "Could not add ")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("unable to add USB disk %s: %s"), path, info); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("unable to add USB disk %s: %s"), path, info); goto cleanup; } @@ -1239,16 +1239,16 @@ static int qemuMonitorTextAddUSBDevice(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("cannot attach usb device")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("cannot attach usb device")); goto cleanup; } /* If the command failed qemu prints: * Could not add ... */ if (strstr(reply, "Could not add ")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("adding usb device failed")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("adding usb device failed")); goto cleanup; } @@ -1380,20 +1380,20 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("cannot attach host pci device")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("cannot attach host pci device")); goto cleanup; } if (strstr(reply, "invalid type: host")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s", - _("PCI device assignment is not supported by this version of qemu")); + qemuReportError(VIR_ERR_NO_SUPPORT, "%s", + _("PCI device assignment is not supported by this version of qemu")); goto cleanup; } if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("parsing pci_add reply failed: %s"), reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("parsing pci_add reply failed: %s"), reply); goto cleanup; } @@ -1431,8 +1431,8 @@ try_command: } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("cannot attach %s disk %s"), bus, path); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("cannot attach %s disk %s"), bus, path); goto cleanup; } @@ -1444,8 +1444,8 @@ try_command: goto try_command; } - qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("adding %s disk failed %s: %s"), bus, path, reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("adding %s disk failed %s: %s"), bus, path, reply); goto cleanup; } @@ -1473,14 +1473,14 @@ int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to add NIC with '%s'"), cmd); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to add NIC with '%s'"), cmd); goto cleanup; } if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("parsing pci_add reply failed: %s"), reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("parsing pci_add reply failed: %s"), reply); goto cleanup; } @@ -1517,8 +1517,8 @@ try_command: } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - "%s", _("failed to remove PCI device")); + qemuReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("failed to remove PCI device")); goto cleanup; } @@ -1536,9 +1536,9 @@ try_command: * nothing is printed on success */ if (strstr(reply, "invalid slot") || strstr(reply, "Invalid pci address")) { - qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to detach PCI device, invalid address %.4x:%.2x:%.2x: %s"), - guestAddr->domain, guestAddr->bus, guestAddr->slot, reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to detach PCI device, invalid address %.4x:%.2x:%.2x: %s"), + guestAddr->domain, guestAddr->bus, guestAddr->slot, reply); goto cleanup; } @@ -1565,17 +1565,17 @@ int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon, } if (qemuMonitorCommandWithFd(mon, cmd, fd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to pass fd to qemu with '%s'"), cmd); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to pass fd to qemu with '%s'"), cmd); goto cleanup; } /* If the command isn't supported then qemu prints: * unknown command: getfd" */ if (strstr(reply, "unknown command:")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, - _("qemu does not support sending of file handles: %s"), - reply); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("qemu does not support sending of file handles: %s"), + reply); goto cleanup; } @@ -1601,17 +1601,17 @@ int qemuMonitorTextCloseFileHandle(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to close fd in qemu with '%s'"), cmd); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to close fd in qemu with '%s'"), cmd); goto cleanup; } /* If the command isn't supported then qemu prints: * unknown command: getfd" */ if (strstr(reply, "unknown command:")) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SUPPORT, - _("qemu does not support closing of file handles: %s"), - reply); + qemuReportError(VIR_ERR_NO_SUPPORT, + _("qemu does not support closing of file handles: %s"), + reply); goto cleanup; } @@ -1637,8 +1637,8 @@ int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to close fd in qemu with '%s'"), cmd); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to close fd in qemu with '%s'"), cmd); goto cleanup; } @@ -1667,8 +1667,8 @@ int qemuMonitorTextRemoveHostNetwork(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to remove host network in qemu with '%s'"), cmd); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to remove host network in qemu with '%s'"), cmd); goto cleanup; } @@ -1702,8 +1702,8 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon, int ret = -1; if (qemuMonitorCommand(mon, "info chardev", &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, "%s", - _("failed to retrieve chardev info in qemu with 'info chardev'")); + qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("failed to retrieve chardev info in qemu with 'info chardev'")); goto cleanup; } @@ -1753,9 +1753,9 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon, } if (virHashAddEntry(paths, id, path) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to save chardev path '%s'"), - path); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to save chardev path '%s'"), + path); VIR_FREE(path); goto cleanup; } @@ -1787,8 +1787,8 @@ try_command: } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("cannot attach %s disk controller"), bus); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("cannot attach %s disk controller"), bus); goto cleanup; } @@ -1800,8 +1800,8 @@ try_command: goto try_command; } - qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("adding %s disk controller failed: %s"), bus, reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("adding %s disk controller failed: %s"), bus, reply); goto cleanup; } @@ -1887,8 +1887,8 @@ try_command: } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to close fd in qemu with '%s'"), cmd); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to close fd in qemu with '%s'"), cmd); goto cleanup; } @@ -1899,8 +1899,8 @@ try_command: tryOldSyntax = 1; goto try_command; } - qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("adding %s disk failed: %s"), drivestr, reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("adding %s disk failed: %s"), drivestr, reply); goto cleanup; } @@ -1954,8 +1954,8 @@ cleanup: (p) += strlen(lbl); #define GET_INT(p, base, val) \ if (virStrToLong_ui((p), &(p), (base), &(val)) < 0) { \ - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, \ - _("cannot parse value for %s"), #val); \ + qemuReportError(VIR_ERR_OPERATION_FAILED, \ + _("cannot parse value for %s"), #val); \ break; \ } #define SKIP_SPACE(p) \ @@ -1972,7 +1972,7 @@ int qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon, *retaddrs = NULL; if (qemuMonitorCommand(mon, "info pci", &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, + qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("cannot query PCI addresses")); return -1; } @@ -2064,14 +2064,14 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("cannot attach %s device"), devicestr); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("cannot attach %s device"), devicestr); goto cleanup; } if (STRNEQ(reply, "")) { - qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("adding %s device failed: %s"), devicestr, reply); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("adding %s device failed: %s"), devicestr, reply); goto cleanup; } @@ -2107,8 +2107,8 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon, } if (qemuMonitorCommand(mon, cmd, &reply) < 0) { - qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("failed to close fd in qemu with '%s'"), cmd); + qemuReportError(VIR_ERR_OPERATION_FAILED, + _("failed to close fd in qemu with '%s'"), cmd); goto cleanup; } diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index c125a34..694c552 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -49,7 +49,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (virtTestLoadFile(xml, &expectxml, MAX_FILE) < 0) goto fail; - if (!(vmdef = qemuParseCommandLineString(NULL, driver.caps, cmd))) + if (!(vmdef = qemuParseCommandLineString(driver.caps, cmd))) goto fail; if (!(actualxml = virDomainDefFormat(NULL, vmdef, 0))) -- 1.6.6

On Tue, Feb 09, 2010 at 07:20:32PM +0000, Daniel P. Berrange wrote:
The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Rename qemudReportError to qemuReportError and remove the conn, dom & net parameters all of which are unused. Remove virConnectPtr from all internal QEMU driver APIs with exception of APIs which need it to resolve a virNetworkPtr into a bridge device name --- src/qemu/qemu_conf.c | 471 +++++++++--------- src/qemu/qemu_conf.h | 21 +- src/qemu/qemu_driver.c | 1127 +++++++++++++++++++++--------------------- src/qemu/qemu_monitor.c | 38 +- src/qemu/qemu_monitor_json.c | 200 ++++---- src/qemu/qemu_monitor_text.c | 232 +++++----- tests/qemuargv2xmltest.c | 2 +- 7 files changed, 1026 insertions(+), 1065 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Remove the conn & dom parameters from lxcError since they're unused. Remove virConnectPtr from all other internal LXC driver APIs with exception of APIs which need it to resolve a virNetworkPtr into a bridge device name --- src/lxc/lxc_conf.h | 6 +- src/lxc/lxc_container.c | 6 +- src/lxc/lxc_controller.c | 10 ++-- src/lxc/lxc_driver.c | 142 ++++++++++++++++++++++----------------------- 4 files changed, 80 insertions(+), 84 deletions(-) diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index 499617f..d0c5bb1 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -63,8 +63,8 @@ struct __lxc_driver { int lxcLoadDriverConfig(lxc_driver_t *driver); virCapsPtr lxcCapsInit(void); -#define lxcError(conn, dom, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_LXC, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define lxcError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_LXC, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) #endif /* LXC_CONF_H */ diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 1cc7ed0..c425154 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -684,13 +684,13 @@ static int lxcContainerDropCapabilities(void) CAP_AUDIT_CONTROL, /* No messing with auditing status */ CAP_MAC_ADMIN, /* No messing with LSM config */ -1 /* sentinal */)) < 0) { - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Failed to remove capabilities: %d"), ret); return -1; } if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) { - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Failed to apply capabilities: %d"), ret); return -1; } @@ -729,7 +729,7 @@ static int lxcContainerChild( void *data ) virDomainFSDefPtr root; if (NULL == vmDef) { - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, "%s", _("lxcChild() passed invalid vm definition")); return -1; } diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 7a45989..3d45ad2 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -179,7 +179,7 @@ static int lxcMonitorServer(const char *sockpath) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; if (virStrcpyStatic(addr.sun_path, sockpath) == NULL) { - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Socket path %s too long for destination"), sockpath); goto error; } @@ -253,7 +253,7 @@ static int lxcControllerClearCapabilities(void) capng_clear(CAPNG_SELECT_BOTH); if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) { - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("failed to apply capabilities: %d"), ret); return -1; } @@ -380,7 +380,7 @@ static int lxcControllerMain(int monitor, DEBUG("EPOLLHUP from fd %d", epollEvent.data.fd); continue; } else { - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("error event %d"), epollEvent.events); goto cleanup; } @@ -451,7 +451,7 @@ static int lxcControllerMoveInterfaces(unsigned int nveths, unsigned int i; for (i = 0 ; i < nveths ; i++) if (moveInterfaceToNetNs(veths[i], container) < 0) { - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Failed to move interface %s to ns %d"), veths[i], container); return -1; @@ -476,7 +476,7 @@ static int lxcControllerCleanupInterfaces(unsigned int nveths, unsigned int i; for (i = 0 ; i < nveths ; i++) if (vethDelete(veths[i]) < 0) - lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Failed to delete veth: %s"), veths[i]); /* will continue to try to cleanup any other interfaces */ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 335a6db..d7b9631 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -127,7 +127,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn, /* If path isn't '/' then they typoed, tell them correct path */ if (STRNEQ(conn->uri->path, "/")) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Unexpected LXC URI path '%s', try lxc:///"), conn->uri->path); return VIR_DRV_OPEN_ERROR; @@ -135,7 +135,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn, /* URI was good, but driver isn't active */ if (lxc_driver == NULL) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, "%s", _("lxc state driver is not active")); return VIR_DRV_OPEN_ERROR; } @@ -198,7 +198,7 @@ static virDomainPtr lxcDomainLookupByID(virConnectPtr conn, lxcDriverUnlock(driver); if (!vm) { - lxcError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL); + lxcError(VIR_ERR_NO_DOMAIN, NULL); goto cleanup; } @@ -224,7 +224,7 @@ static virDomainPtr lxcDomainLookupByUUID(virConnectPtr conn, lxcDriverUnlock(driver); if (!vm) { - lxcError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL); + lxcError(VIR_ERR_NO_DOMAIN, NULL); goto cleanup; } @@ -249,7 +249,7 @@ static virDomainPtr lxcDomainLookupByName(virConnectPtr conn, vm = virDomainFindByName(&driver->domains, name); lxcDriverUnlock(driver); if (!vm) { - lxcError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL); + lxcError(VIR_ERR_NO_DOMAIN, NULL); goto cleanup; } @@ -274,7 +274,7 @@ static int lxcDomainIsActive(virDomainPtr dom) obj = virDomainFindByUUID(&driver->domains, dom->uuid); lxcDriverUnlock(driver); if (!obj) { - lxcError(dom->conn, NULL, VIR_ERR_NO_DOMAIN, NULL); + lxcError(VIR_ERR_NO_DOMAIN, NULL); goto cleanup; } ret = virDomainObjIsActive(obj); @@ -296,7 +296,7 @@ static int lxcDomainIsPersistent(virDomainPtr dom) obj = virDomainFindByUUID(&driver->domains, dom->uuid); lxcDriverUnlock(driver); if (!obj) { - lxcError(dom->conn, NULL, VIR_ERR_NO_DOMAIN, NULL); + lxcError(VIR_ERR_NO_DOMAIN, NULL); goto cleanup; } ret = obj->persistent; @@ -374,7 +374,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) goto cleanup; if ((def->nets != NULL) && !(driver->have_netns)) { - lxcError(conn, NULL, VIR_ERR_NO_SUPPORT, + lxcError(VIR_ERR_NO_SUPPORT, "%s", _("System lacks NETNS support")); goto cleanup; } @@ -423,19 +423,19 @@ static int lxcDomainUndefine(virDomainPtr dom) lxcDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, + lxcError(VIR_ERR_INVALID_DOMAIN, "%s", _("No domain with matching uuid")); goto cleanup; } if (virDomainObjIsActive(vm)) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, + lxcError(VIR_ERR_OPERATION_INVALID, "%s", _("Cannot delete active domain")); goto cleanup; } if (!vm->persistent) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, + lxcError(VIR_ERR_OPERATION_INVALID, "%s", _("Cannot undefine transient domain")); goto cleanup; } @@ -475,7 +475,7 @@ static int lxcDomainGetInfo(virDomainPtr dom, vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, + lxcError(VIR_ERR_INVALID_DOMAIN, "%s", _("No domain with matching uuid")); goto cleanup; } @@ -487,18 +487,18 @@ static int lxcDomainGetInfo(virDomainPtr dom, info->memory = vm->def->memory; } else { if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { - lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Unable to get cgroup for %s"), vm->def->name); goto cleanup; } if (virCgroupGetCpuacctUsage(cgroup, &(info->cpuTime)) < 0) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, + lxcError(VIR_ERR_OPERATION_FAILED, "%s", _("Cannot read cputime for domain")); goto cleanup; } if (virCgroupGetMemoryUsage(cgroup, &(info->memory)) < 0) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, + lxcError(VIR_ERR_OPERATION_FAILED, "%s", _("Cannot read memory usage for domain")); goto cleanup; } @@ -528,7 +528,7 @@ static char *lxcGetOSType(virDomainPtr dom) lxcDriverUnlock(driver); if (!vm) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, + lxcError(VIR_ERR_INVALID_DOMAIN, "%s", _("No domain with matching uuid")); goto cleanup; } @@ -557,7 +557,7 @@ static unsigned long lxcDomainGetMaxMemory(virDomainPtr dom) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -582,13 +582,13 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (newmax < vm->def->memory) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG, + lxcError(VIR_ERR_INVALID_ARG, "%s", _("Cannot set max memory lower than current memory")); goto cleanup; } @@ -614,26 +614,26 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (newmem > vm->def->maxmem) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG, + lxcError(VIR_ERR_INVALID_ARG, "%s", _("Cannot set memory higher than max memory")); goto cleanup; } if (virDomainObjIsActive(vm)) { if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { - lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Unable to get cgroup for %s\n"), vm->def->name); goto cleanup; } if (virCgroupSetMemory(cgroup, newmem) < 0) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, + lxcError(VIR_ERR_OPERATION_FAILED, "%s", _("Failed to set memory for domain")); goto cleanup; } @@ -662,7 +662,7 @@ static char *lxcDomainDumpXML(virDomainPtr dom, lxcDriverUnlock(driver); if (!vm) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, + lxcError(VIR_ERR_INVALID_DOMAIN, "%s", _("No domain with matching uuid")); goto cleanup; } @@ -691,8 +691,7 @@ cleanup: * * Returns 0 on success or -1 in case of error */ -static int lxcVmCleanup(virConnectPtr conn, - lxc_driver_t *driver, +static int lxcVmCleanup(lxc_driver_t *driver, virDomainObjPtr vm) { int rc = -1; @@ -723,7 +722,7 @@ static int lxcVmCleanup(virConnectPtr conn, close(priv->monitor); virFileDeletePid(driver->stateDir, vm->def->name); - virDomainDeleteConfig(conn, driver->stateDir, NULL, vm); + virDomainDeleteConfig(NULL, driver->stateDir, NULL, vm); vm->state = VIR_DOMAIN_SHUTOFF; vm->pid = -1; @@ -801,7 +800,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, DEBUG("bridge: %s", bridge); if (NULL == bridge) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to get bridge for interface")); goto error_exit; } @@ -812,7 +811,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, } DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth); if (0 != (rc = vethCreate(parentVeth, PATH_MAX, containerVeth, PATH_MAX))) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Failed to create veth device pair: %d"), rc); goto error_exit; } @@ -869,8 +868,7 @@ error_exit: } -static int lxcMonitorClient(virConnectPtr conn, - lxc_driver_t * driver, +static int lxcMonitorClient(lxc_driver_t * driver, virDomainObjPtr vm) { char *sockpath = NULL; @@ -892,7 +890,7 @@ static int lxcMonitorClient(virConnectPtr conn, memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; if (virStrcpyStatic(addr.sun_path, sockpath) == NULL) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Socket path %s too big for destination"), sockpath); goto error; } @@ -914,8 +912,7 @@ error: } -static int lxcVmTerminate(virConnectPtr conn, - lxc_driver_t *driver, +static int lxcVmTerminate(lxc_driver_t *driver, virDomainObjPtr vm, int signum) { @@ -923,7 +920,7 @@ static int lxcVmTerminate(virConnectPtr conn, signum = SIGINT; if (vm->pid <= 0) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Invalid PID %d for container"), vm->pid); return -1; } @@ -939,7 +936,7 @@ static int lxcVmTerminate(virConnectPtr conn, vm->state = VIR_DOMAIN_SHUTDOWN; - return lxcVmCleanup(conn, driver, vm); + return lxcVmCleanup(driver, vm); } static void lxcMonitorEvent(int watch, @@ -963,7 +960,7 @@ static void lxcMonitorEvent(int watch, goto cleanup; } - if (lxcVmTerminate(NULL, driver, vm, SIGINT) < 0) { + if (lxcVmTerminate(driver, vm, SIGINT) < 0) { virEventRemoveHandle(watch); } else { event = virDomainEventNewFromObj(vm, @@ -986,7 +983,7 @@ cleanup: } -static int lxcControllerStart(virConnectPtr conn, +static int lxcControllerStart(lxc_driver_t *driver, virDomainObjPtr vm, int nveths, char **veths, @@ -1008,7 +1005,6 @@ static int lxcControllerStart(virConnectPtr conn, fd_set keepfd; char appPtyStr[30]; const char *emulator; - lxc_driver_t *driver = conn->privateData; FD_ZERO(&keepfd); @@ -1138,7 +1134,7 @@ static int lxcControllerStart(virConnectPtr conn, } if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Container '%s' unexpectedly shutdown during startup"), largv[0]); goto cleanup; @@ -1235,7 +1231,7 @@ static int lxcVmStart(virConnectPtr conn, goto cleanup; } - if (lxcControllerStart(conn, + if (lxcControllerStart(driver, vm, nveths, veths, parentTty, logfd) < 0) @@ -1244,7 +1240,7 @@ static int lxcVmStart(virConnectPtr conn, /* Connect to the controller as a client *first* because * this will block until the child has written their * pid file out to disk */ - if ((priv->monitor = lxcMonitorClient(conn, driver, vm)) < 0) + if ((priv->monitor = lxcMonitorClient(driver, vm)) < 0) goto cleanup; /* And get its pid */ @@ -1263,7 +1259,7 @@ static int lxcVmStart(virConnectPtr conn, VIR_EVENT_HANDLE_ERROR | VIR_EVENT_HANDLE_HANGUP, lxcMonitorEvent, vm, NULL)) < 0) { - lxcVmTerminate(conn, driver, vm, 0); + lxcVmTerminate(driver, vm, 0); goto cleanup; } @@ -1305,13 +1301,13 @@ static int lxcDomainStart(virDomainPtr dom) lxcDriverLock(driver); vm = virDomainFindByName(&driver->domains, dom->name); if (!vm) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, + lxcError(VIR_ERR_INVALID_DOMAIN, _("No domain named %s"), dom->name); goto cleanup; } if ((vm->def->nets != NULL) && !(driver->have_netns)) { - lxcError(dom->conn, NULL, VIR_ERR_NO_SUPPORT, + lxcError(VIR_ERR_NO_SUPPORT, "%s", _("System lacks NETNS support")); goto cleanup; } @@ -1361,7 +1357,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, goto cleanup; if ((def->nets != NULL) && !(driver->have_netns)) { - lxcError(conn, NULL, VIR_ERR_NO_SUPPORT, + lxcError(VIR_ERR_NO_SUPPORT, "%s", _("System lacks NETNS support")); goto cleanup; } @@ -1414,12 +1410,12 @@ static int lxcDomainShutdown(virDomainPtr dom) lxcDriverLock(driver); vm = virDomainFindByID(&driver->domains, dom->id); if (!vm) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, + lxcError(VIR_ERR_INVALID_DOMAIN, _("No domain with id %d"), dom->id); goto cleanup; } - ret = lxcVmTerminate(dom->conn, driver, vm, 0); + ret = lxcVmTerminate(driver, vm, 0); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); @@ -1547,12 +1543,12 @@ static int lxcDomainDestroy(virDomainPtr dom) lxcDriverLock(driver); vm = virDomainFindByID(&driver->domains, dom->id); if (!vm) { - lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, + lxcError(VIR_ERR_INVALID_DOMAIN, _("No domain with id %d"), dom->id); goto cleanup; } - ret = lxcVmTerminate(dom->conn, driver, vm, SIGKILL); + ret = lxcVmTerminate(driver, vm, SIGKILL); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); @@ -1650,7 +1646,7 @@ lxcReconnectVM(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque) virDomainObjLock(vm); priv = vm->privateData; - if ((priv->monitor = lxcMonitorClient(NULL, driver, vm)) < 0) { + if ((priv->monitor = lxcMonitorClient(driver, vm)) < 0) { goto cleanup; } @@ -1683,7 +1679,7 @@ lxcReconnectVM(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque) VIR_EVENT_HANDLE_ERROR | VIR_EVENT_HANDLE_HANGUP, lxcMonitorEvent, vm, NULL)) < 0) { - lxcVmTerminate(NULL, driver, vm, 0); + lxcVmTerminate(driver, vm, 0); goto cleanup; } } else { @@ -1870,7 +1866,7 @@ lxcActive(void) { return active; } -static int lxcVersion(virConnectPtr conn, unsigned long *version) +static int lxcVersion(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned long *version) { struct utsname ver; int maj; @@ -1880,7 +1876,7 @@ static int lxcVersion(virConnectPtr conn, unsigned long *version) uname(&ver); if (sscanf(ver.release, "%i.%i.%i", &maj, &min, &rev) != 3) { - lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("Unknown release: %s"), ver.release); return -1; } @@ -1923,7 +1919,7 @@ static int lxcSetSchedulerParameters(virDomainPtr domain, vm = virDomainFindByUUID(&driver->domains, domain->uuid); if (vm == NULL) { - lxcError(NULL, domain, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("No such domain %s"), domain->uuid); goto cleanup; } @@ -1934,7 +1930,7 @@ static int lxcSetSchedulerParameters(virDomainPtr domain, for (i = 0; i < nparams; i++) { virSchedParameterPtr param = ¶ms[i]; if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) { - lxcError(NULL, domain, VIR_ERR_INVALID_ARG, "%s", + lxcError(VIR_ERR_INVALID_ARG, "%s", _("Invalid type for cpu_shares tunable, expected a 'ullong'")); goto cleanup; } @@ -1943,7 +1939,7 @@ static int lxcSetSchedulerParameters(virDomainPtr domain, if (virCgroupSetCpuShares(group, params[i].value.ul) != 0) goto cleanup; } else { - lxcError(NULL, domain, VIR_ERR_INVALID_ARG, + lxcError(VIR_ERR_INVALID_ARG, _("Invalid parameter `%s'"), param->field); goto cleanup; } @@ -1972,7 +1968,7 @@ static int lxcGetSchedulerParameters(virDomainPtr domain, return -1; if ((*nparams) != 1) { - lxcError(NULL, domain, VIR_ERR_INVALID_ARG, + lxcError(VIR_ERR_INVALID_ARG, "%s", _("Invalid parameter count")); return -1; } @@ -1981,7 +1977,7 @@ static int lxcGetSchedulerParameters(virDomainPtr domain, vm = virDomainFindByUUID(&driver->domains, domain->uuid); if (vm == NULL) { - lxcError(NULL, domain, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, _("No such domain %s"), domain->uuid); goto cleanup; } @@ -1993,7 +1989,7 @@ static int lxcGetSchedulerParameters(virDomainPtr domain, goto cleanup; params[0].value.ul = val; if (virStrcpyStatic(params[0].field, "cpu_shares") == NULL) { - lxcError(NULL, domain, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, "%s", _("Field cpu_shares too big for destination")); goto cleanup; } @@ -2027,13 +2023,13 @@ lxcDomainInterfaceStats(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, + lxcError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running")); goto cleanup; } @@ -2050,7 +2046,7 @@ lxcDomainInterfaceStats(virDomainPtr dom, if (ret == 0) ret = linuxDomainInterfaceStats(path, stats); else - lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG, + lxcError(VIR_ERR_INVALID_ARG, _("Invalid path, '%s' is not a known interface"), path); cleanup: @@ -2063,7 +2059,7 @@ static int lxcDomainInterfaceStats(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED, struct _virDomainInterfaceStats *stats ATTRIBUTE_UNUSED) - lxcError(dom->conn, dom, VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__); + lxcError(VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__); return -1; } #endif @@ -2081,7 +2077,7 @@ static int lxcDomainGetAutostart(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -2108,13 +2104,13 @@ static int lxcDomainSetAutostart(virDomainPtr dom, if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!vm->persistent) { - lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR, + lxcError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot set autostart for transient domain")); goto cleanup; } @@ -2277,20 +2273,20 @@ static int lxcDomainSuspend(virDomainPtr dom) if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, + lxcError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running")); goto cleanup; } if (vm->state != VIR_DOMAIN_PAUSED) { if (lxcFreezeContainer(driver, vm) < 0) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, + lxcError(VIR_ERR_OPERATION_FAILED, "%s", _("Suspend operation failed")); goto cleanup; } @@ -2342,20 +2338,20 @@ static int lxcDomainResume(virDomainPtr dom) if (!vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); - lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, + lxcError(VIR_ERR_NO_DOMAIN, _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, + lxcError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running")); goto cleanup; } if (vm->state == VIR_DOMAIN_PAUSED) { if (lxcUnfreezeContainer(driver, vm) < 0) { - lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, + lxcError(VIR_ERR_OPERATION_FAILED, "%s", _("Resume operation failed")); goto cleanup; } -- 1.6.6

On Tue, Feb 09, 2010 at 07:20:33PM +0000, Daniel P. Berrange wrote:
The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Remove the conn & dom parameters from lxcError since they're unused. Remove virConnectPtr from all other internal LXC driver APIs with exception of APIs which need it to resolve a virNetworkPtr into a bridge device name --- src/lxc/lxc_conf.h | 6 +- src/lxc/lxc_container.c | 6 +- src/lxc/lxc_controller.c | 10 ++-- src/lxc/lxc_driver.c | 142 ++++++++++++++++++++++----------------------- 4 files changed, 80 insertions(+), 84 deletions(-)
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index 499617f..d0c5bb1 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -63,8 +63,8 @@ struct __lxc_driver { int lxcLoadDriverConfig(lxc_driver_t *driver); virCapsPtr lxcCapsInit(void);
-#define lxcError(conn, dom, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_LXC, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define lxcError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_LXC, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt)
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Remove use of virConnectPtr from all APIs in domain_conf.{h,c} and update all callers to match --- src/conf/domain_conf.c | 763 +++++++++++++++++++------------------------ src/conf/domain_conf.h | 54 +-- src/esx/esx_driver.c | 8 +- src/lxc/lxc_controller.c | 5 +- src/lxc/lxc_driver.c | 40 +-- src/opennebula/one_driver.c | 8 +- src/openvz/openvz_driver.c | 10 +- src/phyp/phyp_driver.c | 4 +- src/qemu/qemu_driver.c | 76 ++--- src/test/test_driver.c | 30 +- src/uml/uml_driver.c | 28 +- src/vbox/vbox_tmpl.c | 8 +- src/xen/xen_driver.c | 7 +- src/xen/xend_internal.c | 19 +- src/xen/xm_internal.c | 17 +- tests/qemuargv2xmltest.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 4 +- tests/sexpr2xmltest.c | 2 +- tests/vmx2xmltest.c | 2 +- tests/xmconfigtest.c | 4 +- tests/xml2sexprtest.c | 2 +- tests/xml2vmxtest.c | 2 +- 23 files changed, 485 insertions(+), 612 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4ab6a5a..f9d7b13 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -222,9 +222,9 @@ VIR_ENUM_IMPL(virDomainSeclabel, VIR_DOMAIN_SECLABEL_LAST, "dynamic", "static") -#define virDomainReportError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_DOMAIN, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define virDomainReportError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_DOMAIN, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) #ifndef PROXY @@ -686,8 +686,7 @@ int virDomainObjUnref(virDomainObjPtr dom) return dom->refs; } -static virDomainObjPtr virDomainObjNew(virConnectPtr conn, - virCapsPtr caps) +static virDomainObjPtr virDomainObjNew(virCapsPtr caps) { virDomainObjPtr domain; @@ -705,7 +704,7 @@ static virDomainObjPtr virDomainObjNew(virConnectPtr conn, domain->privateDataFreeFunc = caps->privateDataFreeFunc; if (virMutexInit(&domain->lock) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize mutex")); if (domain->privateDataFreeFunc) (domain->privateDataFreeFunc)(domain->privateData); @@ -721,8 +720,7 @@ static virDomainObjPtr virDomainObjNew(virConnectPtr conn, return domain; } -virDomainObjPtr virDomainAssignDef(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainAssignDef(virCapsPtr caps, virDomainObjListPtr doms, const virDomainDefPtr def) { @@ -742,7 +740,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn, return domain; } - if (!(domain = virDomainObjNew(conn, caps))) + if (!(domain = virDomainObjNew(caps))) return NULL; domain->def = def; @@ -910,7 +908,7 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf, int flags) { if (!info) { - virDomainReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing device information")); return -1; } @@ -944,7 +942,7 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf, break; default: - virDomainReportError(NULL, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown address type '%d'"), info->type); return -1; } @@ -983,8 +981,7 @@ int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a, static int -virDomainDevicePCIAddressParseXML(virConnectPtr conn, - xmlNodePtr node, +virDomainDevicePCIAddressParseXML(xmlNodePtr node, virDomainDevicePCIAddressPtr addr) { char *domain, *slot, *bus, *function; @@ -999,34 +996,34 @@ virDomainDevicePCIAddressParseXML(virConnectPtr conn, if (domain && virStrToLong_ui(domain, NULL, 16, &addr->domain) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <address> 'domain' attribute")); goto cleanup; } if (bus && virStrToLong_ui(bus, NULL, 16, &addr->bus) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <address> 'bus' attribute")); goto cleanup; } if (slot && virStrToLong_ui(slot, NULL, 16, &addr->slot) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <address> 'slot' attribute")); goto cleanup; } if (function && virStrToLong_ui(function, NULL, 16, &addr->function) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <address> 'function' attribute")); goto cleanup; } if (!virDomainDevicePCIAddressIsValid(addr)) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Insufficient specification for PCI address")); goto cleanup; } @@ -1043,8 +1040,7 @@ cleanup: static int -virDomainDeviceDriveAddressParseXML(virConnectPtr conn, - xmlNodePtr node, +virDomainDeviceDriveAddressParseXML(xmlNodePtr node, virDomainDeviceDriveAddressPtr addr) { char *bus, *unit, *controller; @@ -1058,27 +1054,27 @@ virDomainDeviceDriveAddressParseXML(virConnectPtr conn, if (controller && virStrToLong_ui(controller, NULL, 10, &addr->controller) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <address> 'controller' attribute")); goto cleanup; } if (bus && virStrToLong_ui(bus, NULL, 10, &addr->bus) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <address> 'bus' attribute")); goto cleanup; } if (unit && virStrToLong_ui(unit, NULL, 10, &addr->unit) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <address> 'unit' attribute")); goto cleanup; } if (!virDomainDeviceDriveAddressIsValid(addr)) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Insufficient specification for drive address")); goto cleanup; } @@ -1096,8 +1092,7 @@ cleanup: * @param node XML nodeset to parse for device address definition */ static int -virDomainDeviceInfoParseXML(virConnectPtr conn, - xmlNodePtr node, +virDomainDeviceInfoParseXML(xmlNodePtr node, virDomainDeviceInfoPtr info, int flags) { @@ -1134,30 +1129,30 @@ virDomainDeviceInfoParseXML(virConnectPtr conn, if (type) { if ((info->type = virDomainDeviceAddressTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown address type '%s'"), type); goto cleanup; } } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No type specified for device address")); goto cleanup; } switch (info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - if (virDomainDevicePCIAddressParseXML(conn, address, &info->addr.pci) < 0) + if (virDomainDevicePCIAddressParseXML(address, &info->addr.pci) < 0) goto cleanup; break; case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: - if (virDomainDeviceDriveAddressParseXML(conn, address, &info->addr.drive) < 0) + if (virDomainDeviceDriveAddressParseXML(address, &info->addr.drive) < 0) goto cleanup; break; default: /* Should not happen */ - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unknown device address type")); goto cleanup; } @@ -1215,8 +1210,7 @@ virDomainDiskDefAssignAddress(virDomainDiskDefPtr def) * @param node XML nodeset to parse for disk definition */ static virDomainDiskDefPtr -virDomainDiskDefParseXML(virConnectPtr conn, - xmlNodePtr node, +virDomainDiskDefParseXML(xmlNodePtr node, int flags) { virDomainDiskDefPtr def; xmlNodePtr cur; @@ -1240,7 +1234,7 @@ virDomainDiskDefParseXML(virConnectPtr conn, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainDiskTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown disk type '%s'"), type); goto error; } @@ -1265,7 +1259,7 @@ virDomainDiskDefParseXML(virConnectPtr conn, source = virXMLPropString(cur, "dir"); break; default: - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %s"), virDomainDiskTypeToString(def->type)); goto error; @@ -1303,7 +1297,7 @@ virDomainDiskDefParseXML(virConnectPtr conn, devaddr = virXMLPropString(cur, "devaddr"); } else if (encryption == NULL && xmlStrEqual(cur->name, BAD_CAST "encryption")) { - encryption = virStorageEncryptionParseNode(conn, node->doc, + encryption = virStorageEncryptionParseNode(NULL, node->doc, cur); if (encryption == NULL) goto error; @@ -1318,7 +1312,7 @@ virDomainDiskDefParseXML(virConnectPtr conn, device = virXMLPropString(node, "device"); if (device) { if ((def->device = virDomainDiskDeviceTypeFromString(device)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown disk device '%s'"), device); goto error; } @@ -1331,20 +1325,20 @@ virDomainDiskDefParseXML(virConnectPtr conn, if (source == NULL && def->device != VIR_DOMAIN_DISK_DEVICE_CDROM && def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - virDomainReportError(conn, VIR_ERR_NO_SOURCE, + virDomainReportError(VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target); goto error; } if (target == NULL) { - virDomainReportError(conn, VIR_ERR_NO_TARGET, + virDomainReportError(VIR_ERR_NO_TARGET, source ? "%s" : NULL, source); goto error; } if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && !STRPREFIX(target, "fd")) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid floppy device name: %s"), target); goto error; } @@ -1359,14 +1353,14 @@ virDomainDiskDefParseXML(virConnectPtr conn, !STRPREFIX((const char *)target, "vd") && !STRPREFIX((const char *)target, "xvd") && !STRPREFIX((const char *)target, "ubd")) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid harddisk device name: %s"), target); goto error; } if (bus) { if ((def->bus = virDomainDiskBusTypeFromString(bus)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown disk bus type '%s'"), bus); goto error; } @@ -1391,20 +1385,20 @@ virDomainDiskDefParseXML(virConnectPtr conn, if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && def->bus != VIR_DOMAIN_DISK_BUS_FDC) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid bus type '%s' for floppy disk"), bus); goto error; } if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && def->bus == VIR_DOMAIN_DISK_BUS_FDC) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid bus type '%s' for disk"), bus); goto error; } if (cachetag && (def->cachemode = virDomainDiskCacheTypeFromString(cachetag)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown disk cache mode '%s'"), cachetag); goto error; } @@ -1414,14 +1408,14 @@ virDomainDiskDefParseXML(virConnectPtr conn, &def->info.addr.pci.domain, &def->info.addr.pci.bus, &def->info.addr.pci.slot) < 3) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse devaddr parameter '%s'"), devaddr); goto error; } def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else { - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; } @@ -1467,8 +1461,7 @@ cleanup: * @param node XML nodeset to parse for controller definition */ static virDomainControllerDefPtr -virDomainControllerDefParseXML(virConnectPtr conn, - xmlNodePtr node, +virDomainControllerDefParseXML(xmlNodePtr node, int flags) { virDomainControllerDefPtr def; @@ -1483,7 +1476,7 @@ virDomainControllerDefParseXML(virConnectPtr conn, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainDiskBusTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown disk controller type '%s'"), type); goto error; } @@ -1492,18 +1485,18 @@ virDomainControllerDefParseXML(virConnectPtr conn, idx = virXMLPropString(node, "index"); if (idx) { if (virStrToLong_i(idx, NULL, 10, &def->idx) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse disk controller index %s"), idx); goto error; } } - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Disk controllers must use the 'pci' address type")); goto error; } @@ -1524,8 +1517,7 @@ cleanup: * @param node XML nodeset to parse for disk definition */ static virDomainFSDefPtr -virDomainFSDefParseXML(virConnectPtr conn, - xmlNodePtr node, +virDomainFSDefParseXML(xmlNodePtr node, int flags) { virDomainFSDefPtr def; xmlNodePtr cur; @@ -1541,7 +1533,7 @@ virDomainFSDefParseXML(virConnectPtr conn, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainFSTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown filesystem type '%s'"), type); goto error; } @@ -1574,13 +1566,13 @@ virDomainFSDefParseXML(virConnectPtr conn, } if (source == NULL) { - virDomainReportError(conn, VIR_ERR_NO_SOURCE, + virDomainReportError(VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target); goto error; } if (target == NULL) { - virDomainReportError(conn, VIR_ERR_NO_TARGET, + virDomainReportError(VIR_ERR_NO_TARGET, source ? "%s" : NULL, source); goto error; } @@ -1590,7 +1582,7 @@ virDomainFSDefParseXML(virConnectPtr conn, def->dst = target; target = NULL; - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; cleanup: @@ -1613,8 +1605,7 @@ cleanup: * @return 0 on success, -1 on failure */ static virDomainNetDefPtr -virDomainNetDefParseXML(virConnectPtr conn, - virCapsPtr caps, +virDomainNetDefParseXML(virCapsPtr caps, xmlNodePtr node, int flags ATTRIBUTE_UNUSED) { virDomainNetDefPtr def; @@ -1640,7 +1631,7 @@ virDomainNetDefParseXML(virConnectPtr conn, type = virXMLPropString(node, "type"); if (type != NULL) { if ((def->type = virDomainNetTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown interface type '%s'"), type); goto error; } @@ -1708,7 +1699,7 @@ virDomainNetDefParseXML(virConnectPtr conn, if (macaddr) { if (virParseMacAddr((const char *)macaddr, def->mac) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unable to parse mac address '%s'"), (const char *)macaddr); goto error; @@ -1722,14 +1713,14 @@ virDomainNetDefParseXML(virConnectPtr conn, &def->info.addr.pci.domain, &def->info.addr.pci.bus, &def->info.addr.pci.slot) < 3) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse devaddr parameter '%s'"), devaddr); goto error; } def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else { - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; } @@ -1737,7 +1728,7 @@ virDomainNetDefParseXML(virConnectPtr conn, * them we should make sure address type is correct */ if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Network interfaces must use 'pci' address type")); goto error; } @@ -1745,7 +1736,7 @@ virDomainNetDefParseXML(virConnectPtr conn, switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: if (network == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No <source> 'network' attribute specified with <interface type='network'/>")); goto error; } @@ -1771,7 +1762,7 @@ virDomainNetDefParseXML(virConnectPtr conn, case VIR_DOMAIN_NET_TYPE_BRIDGE: if (bridge == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No <source> 'bridge' attribute specified with <interface type='bridge'/>")); goto error; } @@ -1791,12 +1782,12 @@ virDomainNetDefParseXML(virConnectPtr conn, case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_MCAST: if (port == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No <source> 'port' attribute specified with socket interface")); goto error; } if (virStrToLong_i(port, NULL, 10, &def->data.socket.port) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse <source> 'port' attribute with socket interface")); goto error; } @@ -1804,7 +1795,7 @@ virDomainNetDefParseXML(virConnectPtr conn, if (address == NULL) { if (def->type == VIR_DOMAIN_NET_TYPE_CLIENT || def->type == VIR_DOMAIN_NET_TYPE_MCAST) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No <source> 'address' attribute specified with socket interface")); goto error; } @@ -1816,7 +1807,7 @@ virDomainNetDefParseXML(virConnectPtr conn, case VIR_DOMAIN_NET_TYPE_INTERNAL: if (internal == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No <source> 'name' attribute specified with <interface type='internal'/>")); goto error; } @@ -1840,8 +1831,8 @@ virDomainNetDefParseXML(virConnectPtr conn, for (i = 0 ; i < strlen(model) ; i++) { int char_ok = c_isalnum(model[i]) || model[i] == '_'; if (!char_ok) { - virDomainReportError (conn, VIR_ERR_INVALID_ARG, "%s", - _("Model name contains invalid characters")); + virDomainReportError(VIR_ERR_INVALID_ARG, "%s", + _("Model name contains invalid characters")); goto error; } } @@ -1911,8 +1902,7 @@ error: * */ static virDomainChrDefPtr -virDomainChrDefParseXML(virConnectPtr conn, - xmlNodePtr node, +virDomainChrDefParseXML(xmlNodePtr node, int flags) { xmlNodePtr cur; char *type = NULL; @@ -1944,7 +1934,7 @@ virDomainChrDefParseXML(virConnectPtr conn, if ((def->targetType = virDomainChrTargetTypeFromString(nodeName)) < 0) { /* channel is handled below */ if (STRNEQ(nodeName, "channel")) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, _("unknown target type for character device: %s"), nodeName); VIR_FREE(def); @@ -1986,7 +1976,7 @@ virDomainChrDefParseXML(virConnectPtr conn, if (bindService == NULL) bindService = virXMLPropString(cur, "service"); } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown source mode '%s'"), mode); goto error; @@ -2003,7 +1993,7 @@ virDomainChrDefParseXML(virConnectPtr conn, if (def->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_NULL) { targetType = virXMLPropString(cur, "type"); if (targetType == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, "%s", + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("character device target does " "not define a type")); goto error; @@ -2011,7 +2001,7 @@ virDomainChrDefParseXML(virConnectPtr conn, if ((def->targetType = virDomainChrTargetTypeFromString(targetType)) < 0) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, _("unknown target type for " "character device: %s"), targetType); @@ -2032,7 +2022,7 @@ virDomainChrDefParseXML(virConnectPtr conn, } if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, _("Invalid port number: %s"), portStr); goto error; @@ -2044,7 +2034,7 @@ virDomainChrDefParseXML(virConnectPtr conn, portStr = virXMLPropString(cur, "port"); if (addrStr == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, "%s", + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("guestfwd channel does not " "define a target address")); goto error; @@ -2055,27 +2045,27 @@ virDomainChrDefParseXML(virConnectPtr conn, } if (virSocketParseAddr(addrStr, def->target.addr, 0) < 0) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, _("%s is not a valid address"), addrStr); goto error; } if (def->target.addr->stor.ss_family != AF_INET) { - virDomainReportError(conn, VIR_ERR_CONFIG_UNSUPPORTED, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("guestfwd channel only supports " "IPv4 addresses")); goto error; } if (portStr == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, "%s", + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("guestfwd channel does " "not define a target port")); goto error; } if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, _("Invalid port number: %s"), portStr); goto error; @@ -2084,7 +2074,7 @@ virDomainChrDefParseXML(virConnectPtr conn, break; default: - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, _("unexpected target type type %u"), def->targetType); } @@ -2108,7 +2098,7 @@ virDomainChrDefParseXML(virConnectPtr conn, case VIR_DOMAIN_CHR_TYPE_PIPE: if (path == NULL && def->type != VIR_DOMAIN_CHR_TYPE_PTY) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source path attribute for char device")); goto error; } @@ -2125,12 +2115,12 @@ virDomainChrDefParseXML(virConnectPtr conn, if (mode == NULL || STREQ(mode, "connect")) { if (connectHost == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source host attribute for char device")); goto error; } if (connectService == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source service attribute for char device")); goto error; } @@ -2142,12 +2132,12 @@ virDomainChrDefParseXML(virConnectPtr conn, def->data.tcp.listen = 0; } else { if (bindHost == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source host attribute for char device")); goto error; } if (bindService == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source service attribute for char device")); goto error; } @@ -2165,7 +2155,7 @@ virDomainChrDefParseXML(virConnectPtr conn, else if (STREQ(protocol, "telnet")) def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown protocol '%s'"), protocol); goto error; } @@ -2174,7 +2164,7 @@ virDomainChrDefParseXML(virConnectPtr conn, case VIR_DOMAIN_CHR_TYPE_UDP: if (connectService == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source service attribute for char device")); goto error; } @@ -2192,7 +2182,7 @@ virDomainChrDefParseXML(virConnectPtr conn, case VIR_DOMAIN_CHR_TYPE_UNIX: if (path == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source path attribute for char device")); goto error; } @@ -2208,7 +2198,7 @@ virDomainChrDefParseXML(virConnectPtr conn, break; } - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; cleanup: @@ -2234,8 +2224,7 @@ error: /* Parse the XML definition for a network interface */ static virDomainInputDefPtr -virDomainInputDefParseXML(virConnectPtr conn, - const char *ostype, +virDomainInputDefParseXML(const char *ostype, xmlNodePtr node, int flags) { virDomainInputDefPtr def; @@ -2251,20 +2240,20 @@ virDomainInputDefParseXML(virConnectPtr conn, bus = virXMLPropString(node, "bus"); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing input device type")); goto error; } if ((def->type = virDomainInputTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown input device type '%s'"), type); goto error; } if (bus) { if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown input bus type '%s'"), bus); goto error; } @@ -2272,25 +2261,25 @@ virDomainInputDefParseXML(virConnectPtr conn, if (STREQ(ostype, "hvm")) { if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */ def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("ps2 bus does not support %s input device"), type); goto error; } if (def->bus == VIR_DOMAIN_INPUT_BUS_XEN) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported input bus %s"), bus); goto error; } } else { if (def->bus != VIR_DOMAIN_INPUT_BUS_XEN) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported input bus %s"), bus); } if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("xen bus does not support %s input device"), type); goto error; @@ -2307,7 +2296,7 @@ virDomainInputDefParseXML(virConnectPtr conn, } } - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; cleanup: @@ -2325,8 +2314,7 @@ error: /* Parse the XML definition for a graphics device */ static virDomainGraphicsDefPtr -virDomainGraphicsDefParseXML(virConnectPtr conn, - xmlNodePtr node, int flags) { +virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) { virDomainGraphicsDefPtr def; char *type = NULL; @@ -2338,13 +2326,13 @@ virDomainGraphicsDefParseXML(virConnectPtr conn, type = virXMLPropString(node, "type"); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing graphics device type")); goto error; } if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown graphics device type '%s'"), type); goto error; } @@ -2355,7 +2343,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn, if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vnc port %s"), port); VIR_FREE(port); goto error; @@ -2393,7 +2381,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn, } else if (STREQ(fullscreen, "no")) { def->data.sdl.fullscreen = 0; } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown fullscreen value '%s'"), fullscreen); VIR_FREE(fullscreen); goto error; @@ -2411,7 +2399,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn, if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse rdp port %s"), port); VIR_FREE(port); goto error; @@ -2455,7 +2443,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn, } else if (STREQ(fullscreen, "no")) { def->data.desktop.fullscreen = 0; } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown fullscreen value '%s'"), fullscreen); VIR_FREE(fullscreen); goto error; @@ -2480,8 +2468,7 @@ error: static virDomainSoundDefPtr -virDomainSoundDefParseXML(virConnectPtr conn, - const xmlNodePtr node, +virDomainSoundDefParseXML(const xmlNodePtr node, int flags) { char *model; @@ -2494,12 +2481,12 @@ virDomainSoundDefParseXML(virConnectPtr conn, model = virXMLPropString(node, "model"); if ((def->model = virDomainSoundModelTypeFromString(model)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown sound model '%s'"), model); goto error; } - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; cleanup: @@ -2515,8 +2502,7 @@ error: static virDomainWatchdogDefPtr -virDomainWatchdogDefParseXML(virConnectPtr conn, - const xmlNodePtr node, +virDomainWatchdogDefParseXML(const xmlNodePtr node, int flags) { @@ -2531,14 +2517,14 @@ virDomainWatchdogDefParseXML(virConnectPtr conn, model = virXMLPropString (node, "model"); if (model == NULL) { - virDomainReportError (conn, VIR_ERR_INTERNAL_ERROR, "%s", - _("watchdog must contain model name")); + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("watchdog must contain model name")); goto error; } def->model = virDomainWatchdogModelTypeFromString (model); if (def->model < 0) { - virDomainReportError (conn, VIR_ERR_INTERNAL_ERROR, - _("unknown watchdog model '%s'"), model); + virDomainReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown watchdog model '%s'"), model); goto error; } @@ -2548,13 +2534,13 @@ virDomainWatchdogDefParseXML(virConnectPtr conn, else { def->action = virDomainWatchdogActionTypeFromString (action); if (def->action < 0) { - virDomainReportError (conn, VIR_ERR_INTERNAL_ERROR, - _("unknown watchdog action '%s'"), action); + virDomainReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown watchdog action '%s'"), action); goto error; } } - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; cleanup: @@ -2671,8 +2657,7 @@ virDomainVideoAccelDefParseXML(const xmlNodePtr node) { } static virDomainVideoDefPtr -virDomainVideoDefParseXML(virConnectPtr conn, - const xmlNodePtr node, +virDomainVideoDefParseXML(const xmlNodePtr node, virDomainDefPtr dom, int flags) { virDomainVideoDefPtr def; @@ -2702,13 +2687,13 @@ virDomainVideoDefParseXML(virConnectPtr conn, if (type) { if ((def->type = virDomainVideoTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown video model '%s'"), type); goto error; } } else { if ((def->type = virDomainVideoDefaultType(dom)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing video model and cannot determine default")); goto error; } @@ -2716,7 +2701,7 @@ virDomainVideoDefParseXML(virConnectPtr conn, if (vram) { if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse video ram '%s'"), vram); goto error; } @@ -2726,7 +2711,7 @@ virDomainVideoDefParseXML(virConnectPtr conn, if (heads) { if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse video heads '%s'"), heads); goto error; } @@ -2734,7 +2719,7 @@ virDomainVideoDefParseXML(virConnectPtr conn, def->heads = 1; } - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; VIR_FREE(type); @@ -2752,8 +2737,7 @@ error: } static int -virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, - const xmlNodePtr node, +virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node, virDomainHostdevDefPtr def, int flags ATTRIBUTE_UNUSED) { @@ -2776,14 +2760,14 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, got_vendor = 1; if (virStrToLong_ui(vendor, NULL, 0, &def->source.subsys.u.usb.vendor) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vendor id %s"), vendor); VIR_FREE(vendor); goto out; } VIR_FREE(vendor); } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb vendor needs id")); goto out; } @@ -2794,7 +2778,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, got_product = 1; if (virStrToLong_ui(product, NULL, 0, &def->source.subsys.u.usb.product) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse product %s"), product); VIR_FREE(product); @@ -2802,7 +2786,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, } VIR_FREE(product); } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb product needs id")); goto out; } @@ -2813,14 +2797,14 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, if (bus) { if (virStrToLong_ui(bus, NULL, 0, &def->source.subsys.u.usb.bus) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse bus %s"), bus); VIR_FREE(bus); goto out; } VIR_FREE(bus); } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb address needs bus id")); goto out; } @@ -2829,7 +2813,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, if (device) { if (virStrToLong_ui(device, NULL, 0, &def->source.subsys.u.usb.device) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse device %s"), device); VIR_FREE(device); @@ -2837,12 +2821,12 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, } VIR_FREE(device); } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("usb address needs device id")); goto out; } } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown usb source type '%s'"), cur->name); goto out; @@ -2852,18 +2836,18 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, } if (got_vendor && def->source.subsys.u.usb.vendor == 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("vendor cannot be 0.")); goto out; } if (!got_vendor && got_product) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing vendor")); goto out; } if (got_vendor && !got_product) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing product")); goto out; } @@ -2875,8 +2859,7 @@ out: static int -virDomainHostdevSubsysPciDefParseXML(virConnectPtr conn, - const xmlNodePtr node, +virDomainHostdevSubsysPciDefParseXML(const xmlNodePtr node, virDomainHostdevDefPtr def, int flags) { @@ -2890,7 +2873,7 @@ virDomainHostdevSubsysPciDefParseXML(virConnectPtr conn, virDomainDevicePCIAddressPtr addr = &def->source.subsys.u.pci; - if (virDomainDevicePCIAddressParseXML(conn, cur, addr) < 0) + if (virDomainDevicePCIAddressParseXML(cur, addr) < 0) goto out; } else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) && xmlStrEqual(cur->name, BAD_CAST "state")) { @@ -2901,7 +2884,7 @@ virDomainHostdevSubsysPciDefParseXML(virConnectPtr conn, &def->info.addr.pci.domain, &def->info.addr.pci.bus, &def->info.addr.pci.slot) < 3) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse devaddr parameter '%s'"), devaddr); VIR_FREE(devaddr); @@ -2909,7 +2892,7 @@ virDomainHostdevSubsysPciDefParseXML(virConnectPtr conn, } def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pci source type '%s'"), cur->name); goto out; @@ -2925,8 +2908,7 @@ out: static virDomainHostdevDefPtr -virDomainHostdevDefParseXML(virConnectPtr conn, - const xmlNodePtr node, +virDomainHostdevDefParseXML(const xmlNodePtr node, int flags) { xmlNodePtr cur; @@ -2942,7 +2924,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn, mode = virXMLPropString(node, "mode"); if (mode) { if ((def->mode=virDomainHostdevModeTypeFromString(mode)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown hostdev mode '%s'"), mode); goto error; } @@ -2953,12 +2935,12 @@ virDomainHostdevDefParseXML(virConnectPtr conn, type = virXMLPropString(node, "type"); if (type) { if ((def->source.subsys.type = virDomainHostdevSubsysTypeFromString(type)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown host device type '%s'"), type); goto error; } } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing type in hostdev")); goto error; } @@ -2976,18 +2958,17 @@ virDomainHostdevDefParseXML(virConnectPtr conn, if (xmlStrEqual(cur->name, BAD_CAST "source")) { if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { - if (virDomainHostdevSubsysUsbDefParseXML(conn, cur, - def, flags) < 0) + if (virDomainHostdevSubsysUsbDefParseXML(cur, def, flags) < 0) goto error; } if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { - if (virDomainHostdevSubsysPciDefParseXML(conn, cur, def, flags) < 0) + if (virDomainHostdevSubsysPciDefParseXML(cur, def, flags) < 0) goto error; } } else if (xmlStrEqual(cur->name, BAD_CAST "address")) { } else { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown node %s"), cur->name); } } @@ -2995,7 +2976,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn, } if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; } @@ -3004,7 +2985,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn, case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PCI host devices must use 'pci' address type")); goto error; } @@ -3024,8 +3005,7 @@ error: } -static int virDomainLifecycleParseXML(virConnectPtr conn, - xmlXPathContextPtr ctxt, +static int virDomainLifecycleParseXML(xmlXPathContextPtr ctxt, const char *xpath, int *val, int defaultVal) @@ -3036,7 +3016,7 @@ static int virDomainLifecycleParseXML(virConnectPtr conn, } else { *val = virDomainLifecycleTypeFromString(tmp); if (*val < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown lifecycle action %s"), tmp); VIR_FREE(tmp); return -1; @@ -3047,8 +3027,7 @@ static int virDomainLifecycleParseXML(virConnectPtr conn, } static int -virSecurityLabelDefParseXML(virConnectPtr conn, - const virDomainDefPtr def, +virSecurityLabelDefParseXML(const virDomainDefPtr def, xmlXPathContextPtr ctxt, int flags) { @@ -3060,14 +3039,14 @@ virSecurityLabelDefParseXML(virConnectPtr conn, p = virXPathStringLimit("string(./seclabel/@type)", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("missing security type")); goto error; } def->seclabel.type = virDomainSeclabelTypeFromString(p); VIR_FREE(p); if (def->seclabel.type < 0) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("invalid security type")); goto error; } @@ -3080,7 +3059,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, p = virXPathStringLimit("string(./seclabel/@model)", VIR_SECURITY_MODEL_BUFLEN-1, ctxt); if (p == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("missing security model")); goto error; } @@ -3089,7 +3068,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, p = virXPathStringLimit("string(./seclabel/label[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("security label is missing")); goto error; } @@ -3103,7 +3082,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, p = virXPathStringLimit("string(./seclabel/imagelabel[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("security imagelabel is missing")); goto error; } @@ -3117,8 +3096,7 @@ error: return -1; } -virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, - virCapsPtr caps, +virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, const virDomainDefPtr def, const char *xmlStr, int flags) @@ -3130,13 +3108,13 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, if (!(xml = xmlReadDoc(BAD_CAST xmlStr, "device.xml", NULL, XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, NULL); + virDomainReportError(VIR_ERR_XML_ERROR, NULL); goto error; } node = xmlDocGetRootElement(xml); if (node == NULL) { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("missing root element")); goto error; } @@ -3148,43 +3126,43 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, if (xmlStrEqual(node->name, BAD_CAST "disk")) { dev->type = VIR_DOMAIN_DEVICE_DISK; - if (!(dev->data.disk = virDomainDiskDefParseXML(conn, node, flags))) + if (!(dev->data.disk = virDomainDiskDefParseXML(node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "filesystem")) { dev->type = VIR_DOMAIN_DEVICE_FS; - if (!(dev->data.fs = virDomainFSDefParseXML(conn, node, flags))) + if (!(dev->data.fs = virDomainFSDefParseXML(node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "interface")) { dev->type = VIR_DOMAIN_DEVICE_NET; - if (!(dev->data.net = virDomainNetDefParseXML(conn, caps, node, flags))) + if (!(dev->data.net = virDomainNetDefParseXML(caps, node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "input")) { dev->type = VIR_DOMAIN_DEVICE_INPUT; - if (!(dev->data.input = virDomainInputDefParseXML(conn, def->os.type, + if (!(dev->data.input = virDomainInputDefParseXML(def->os.type, node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "sound")) { dev->type = VIR_DOMAIN_DEVICE_SOUND; - if (!(dev->data.sound = virDomainSoundDefParseXML(conn, node, flags))) + if (!(dev->data.sound = virDomainSoundDefParseXML(node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "watchdog")) { dev->type = VIR_DOMAIN_DEVICE_WATCHDOG; - if (!(dev->data.watchdog = virDomainWatchdogDefParseXML(conn, node, flags))) + if (!(dev->data.watchdog = virDomainWatchdogDefParseXML(node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "video")) { dev->type = VIR_DOMAIN_DEVICE_VIDEO; - if (!(dev->data.video = virDomainVideoDefParseXML(conn, node, def, flags))) + if (!(dev->data.video = virDomainVideoDefParseXML(node, def, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "hostdev")) { dev->type = VIR_DOMAIN_DEVICE_HOSTDEV; - if (!(dev->data.hostdev = virDomainHostdevDefParseXML(conn, node, flags))) + if (!(dev->data.hostdev = virDomainHostdevDefParseXML(node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "controller")) { dev->type = VIR_DOMAIN_DEVICE_CONTROLLER; - if (!(dev->data.controller = virDomainControllerDefParseXML(conn, node, flags))) + if (!(dev->data.controller = virDomainControllerDefParseXML(node, flags))) goto error; } else { - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("unknown device type")); goto error; } @@ -3309,8 +3287,7 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def, #ifndef PROXY -static char *virDomainDefDefaultEmulator(virConnectPtr conn, - virDomainDefPtr def, +static char *virDomainDefDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) { const char *type; const char *emulator; @@ -3318,7 +3295,7 @@ static char *virDomainDefDefaultEmulator(virConnectPtr conn, type = virDomainVirtTypeToString(def->virtType); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown virt type")); return NULL; } @@ -3329,7 +3306,7 @@ static char *virDomainDefDefaultEmulator(virConnectPtr conn, type); if (!emulator) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("no emulator for domain %s os type %s on architecture %s"), type, def->os.type, def->os.arch); return NULL; @@ -3342,8 +3319,7 @@ static char *virDomainDefDefaultEmulator(virConnectPtr conn, return retemu; } -static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, - virCapsPtr caps, +static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, xmlXPathContextPtr ctxt, int flags) { xmlNodePtr *nodes = NULL, node = NULL; @@ -3364,13 +3340,13 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* Find out what type of virtualization to use */ if (!(tmp = virXPathString("string(./@type)", ctxt))) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain type attribute")); goto error; } if ((def->virtType = virDomainVirtTypeFromString(tmp)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("invalid domain type %s"), tmp); goto error; } @@ -3378,7 +3354,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* Extract domain name */ if (!(def->name = virXPathString("string(./name[1])", ctxt))) { - virDomainReportError(conn, VIR_ERR_NO_NAME, NULL); + virDomainReportError(VIR_ERR_NO_NAME, NULL); goto error; } @@ -3386,13 +3362,13 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, tmp = virXPathString("string(./uuid[1])", ctxt); if (!tmp) { if (virUUIDGenerate(def->uuid)) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate UUID")); goto error; } } else { if (virUUIDParse(tmp, def->uuid) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed uuid element")); goto error; } @@ -3404,7 +3380,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* Extract domain memory */ if (virXPathULong("string(./memory[1])", ctxt, &def->maxmem) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing memory element")); goto error; } @@ -3427,7 +3403,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, virReportOOMError(); goto error; } - if (virDomainCpuSetParse(conn, (const char **)&set, + if (virDomainCpuSetParse((const char **)&set, 0, def->cpumask, def->cpumasklen) < 0) goto error; @@ -3441,7 +3417,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, for (i = 0 ; i < n ; i++) { int val = virDomainFeatureTypeFromString((const char *)nodes[i]->name); if (val < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected feature %s"), nodes[i]->name); goto error; @@ -3451,15 +3427,15 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); } - if (virDomainLifecycleParseXML(conn, ctxt, "string(./on_reboot[1])", + if (virDomainLifecycleParseXML(ctxt, "string(./on_reboot[1])", &def->onReboot, VIR_DOMAIN_LIFECYCLE_RESTART) < 0) goto error; - if (virDomainLifecycleParseXML(conn, ctxt, "string(./on_poweroff[1])", + if (virDomainLifecycleParseXML(ctxt, "string(./on_poweroff[1])", &def->onPoweroff, VIR_DOMAIN_LIFECYCLE_DESTROY) < 0) goto error; - if (virDomainLifecycleParseXML(conn, ctxt, "string(./on_crash[1])", + if (virDomainLifecycleParseXML(ctxt, "string(./on_crash[1])", &def->onCrash, VIR_DOMAIN_LIFECYCLE_DESTROY) < 0) goto error; @@ -3481,7 +3457,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; } } else { - virDomainReportError(conn, VIR_ERR_OS_TYPE, + virDomainReportError(VIR_ERR_OS_TYPE, "%s", _("no OS type")); goto error; } @@ -3501,7 +3477,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { - virDomainReportError(conn, VIR_ERR_OS_TYPE, + virDomainReportError(VIR_ERR_OS_TYPE, "%s", def->os.type); goto error; } @@ -3509,7 +3485,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, def->os.arch = virXPathString("string(./os/type[1]/@arch)", ctxt); if (def->os.arch) { if (!virCapabilitiesSupportsGuestArch(caps, def->os.type, def->os.arch)) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("os type '%s' & arch '%s' combination is not supported"), def->os.type, def->os.arch); goto error; @@ -3517,7 +3493,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } else { const char *defaultArch = virCapabilitiesDefaultGuestArch(caps, def->os.type, virDomainVirtTypeToString(def->virtType)); if (defaultArch == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"), def->os.type); goto error; @@ -3568,7 +3544,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (STREQ(def->os.type, "hvm")) { /* analysis of the boot devices */ if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract boot device")); goto error; } @@ -3576,12 +3552,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, int val; char *dev = virXMLPropString(nodes[i], "dev"); if (!dev) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing boot device")); goto error; } if ((val = virDomainBootTypeFromString(dev)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unknown boot device '%s'"), dev); VIR_FREE(dev); @@ -3599,22 +3575,21 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); if (!def->emulator && virCapabilitiesIsEmulatorRequired(caps)) { - def->emulator = virDomainDefDefaultEmulator(conn, def, caps); + def->emulator = virDomainDefDefaultEmulator(def, caps); if (!def->emulator) goto error; } /* analysis of the disk devices */ if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract disk devices")); goto error; } if (n && VIR_ALLOC_N(def->disks, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainDiskDefPtr disk = virDomainDiskDefParseXML(conn, - nodes[i], + virDomainDiskDefPtr disk = virDomainDiskDefParseXML(nodes[i], flags); if (!disk) goto error; @@ -3625,15 +3600,14 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the controller devices */ if ((n = virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract controller devices")); goto error; } if (n && VIR_ALLOC_N(def->controllers, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainControllerDefPtr controller = virDomainControllerDefParseXML(conn, - nodes[i], + virDomainControllerDefPtr controller = virDomainControllerDefParseXML(nodes[i], flags); if (!controller) goto error; @@ -3650,15 +3624,14 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the filesystems */ if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract filesystem devices")); goto error; } if (n && VIR_ALLOC_N(def->fss, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainFSDefPtr fs = virDomainFSDefParseXML(conn, - nodes[i], + virDomainFSDefPtr fs = virDomainFSDefParseXML(nodes[i], flags); if (!fs) goto error; @@ -3669,15 +3642,14 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the network devices */ if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract network devices")); goto error; } if (n && VIR_ALLOC_N(def->nets, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainNetDefPtr net = virDomainNetDefParseXML(conn, - caps, + virDomainNetDefPtr net = virDomainNetDefParseXML(caps, nodes[i], flags); if (!net) @@ -3690,7 +3662,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the character devices */ if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract parallel devices")); goto error; } @@ -3698,8 +3670,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, - nodes[i], + virDomainChrDefPtr chr = virDomainChrDefParseXML(nodes[i], flags); if (!chr) goto error; @@ -3710,7 +3681,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); if ((n = virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract serial devices")); goto error; } @@ -3718,8 +3689,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, - nodes[i], + virDomainChrDefPtr chr = virDomainChrDefParseXML(nodes[i], flags); if (!chr) goto error; @@ -3730,8 +3700,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); if ((node = virXPathNode("./devices/console[1]", ctxt)) != NULL) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, - node, + virDomainChrDefPtr chr = virDomainChrDefParseXML(node, flags); if (!chr) goto error; @@ -3759,7 +3728,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract channel devices")); goto error; } @@ -3767,8 +3736,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, - nodes[i], + virDomainChrDefPtr chr = virDomainChrDefParseXML(nodes[i], flags); if (!chr) goto error; @@ -3780,7 +3748,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the input devices */ if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract input devices")); goto error; } @@ -3788,8 +3756,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainInputDefPtr input = virDomainInputDefParseXML(conn, - def->os.type, + virDomainInputDefPtr input = virDomainInputDefParseXML(def->os.type, nodes[i], flags); if (!input) @@ -3815,15 +3782,14 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the graphics devices */ if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract graphics devices")); goto error; } if (n && VIR_ALLOC_N(def->graphics, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainGraphicsDefPtr graphics = virDomainGraphicsDefParseXML(conn, - nodes[i], + virDomainGraphicsDefPtr graphics = virDomainGraphicsDefParseXML(nodes[i], flags); if (!graphics) goto error; @@ -3859,15 +3825,14 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract sound devices")); goto error; } if (n && VIR_ALLOC_N(def->sounds, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainSoundDefPtr sound = virDomainSoundDefParseXML(conn, - nodes[i], + virDomainSoundDefPtr sound = virDomainSoundDefParseXML(nodes[i], flags); if (!sound) goto error; @@ -3878,15 +3843,14 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the video devices */ if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract video devices")); goto error; } if (n && VIR_ALLOC_N(def->videos, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainVideoDefPtr video = virDomainVideoDefParseXML(conn, - nodes[i], + virDomainVideoDefPtr video = virDomainVideoDefParseXML(nodes[i], def, flags); if (!video) @@ -3903,7 +3867,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto no_memory; video->type = virDomainVideoDefaultType(def); if (video->type < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot determine default video type")); VIR_FREE(video); goto error; @@ -3919,15 +3883,14 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the host devices */ if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract host devices")); goto error; } if (n && VIR_ALLOC_N(def->hostdevs, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainHostdevDefPtr hostdev = virDomainHostdevDefParseXML(conn, - nodes[i], + virDomainHostdevDefPtr hostdev = virDomainHostdevDefParseXML(nodes[i], flags); if (!hostdev) goto error; @@ -3939,18 +3902,18 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the watchdog devices */ def->watchdog = NULL; if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract watchdog devices")); goto error; } if (n > 1) { - virDomainReportError (conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError (VIR_ERR_INTERNAL_ERROR, "%s", _("only a single watchdog device is supported")); goto error; } if (n > 0) { virDomainWatchdogDefPtr watchdog = - virDomainWatchdogDefParseXML(conn, nodes[0], flags); + virDomainWatchdogDefParseXML(nodes[0], flags); if (!watchdog) goto error; @@ -3959,13 +3922,13 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } /* analysis of security label */ - if (virSecurityLabelDefParseXML(conn, def, ctxt, flags) == -1) + if (virSecurityLabelDefParseXML(def, ctxt, flags) == -1) goto error; if ((node = virXPathNode("./cpu[1]", ctxt)) != NULL) { xmlNodePtr oldnode = ctxt->node; ctxt->node = node; - def->cpu = virCPUDefParseXML(conn, node, ctxt, VIR_CPU_TYPE_GUEST); + def->cpu = virCPUDefParseXML(NULL, node, ctxt, VIR_CPU_TYPE_GUEST); ctxt->node = oldnode; if (def->cpu == NULL) @@ -3986,8 +3949,7 @@ no_memory: } -static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, - virCapsPtr caps, +static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, xmlXPathContextPtr ctxt) { char *tmp = NULL; @@ -3996,30 +3958,30 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, xmlNodePtr oldnode; virDomainObjPtr obj; - if (!(obj = virDomainObjNew(conn, caps))) + if (!(obj = virDomainObjNew(caps))) return NULL; if (!(config = virXPathNode("./domain", ctxt))) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no domain config")); goto error; } oldnode = ctxt->node; ctxt->node = config; - obj->def = virDomainDefParseXML(conn, caps, ctxt, + obj->def = virDomainDefParseXML(caps, ctxt, VIR_DOMAIN_XML_INTERNAL_STATUS); ctxt->node = oldnode; if (!obj->def) goto error; if (!(tmp = virXPathString("string(./@state)", ctxt))) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain state")); goto error; } if ((obj->state = virDomainStateTypeFromString(tmp)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("invalid domain state '%s'"), tmp); VIR_FREE(tmp); goto error; @@ -4027,7 +3989,7 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, VIR_FREE(tmp); if ((virXPathLong("string(./@pid)", ctxt, &val)) < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid pid")); goto error; } @@ -4052,21 +4014,18 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; if (ctxt) { - virConnectPtr conn = ctxt->_private; - if (virGetLastError() == NULL && ctxt->lastError.level == XML_ERR_FATAL && ctxt->lastError.message != NULL) { - virDomainReportError (conn, VIR_ERR_XML_DETAIL, - _("at line %d: %s"), - ctxt->lastError.line, - ctxt->lastError.message); + virDomainReportError(VIR_ERR_XML_DETAIL, + _("at line %d: %s"), + ctxt->lastError.line, + ctxt->lastError.message); } } } -virDomainDefPtr virDomainDefParseString(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr virDomainDefParseString(virCapsPtr caps, const char *xmlStr, int flags) { @@ -4080,26 +4039,24 @@ virDomainDefPtr virDomainDefParseString(virConnectPtr conn, if (!pctxt || !pctxt->sax) goto cleanup; pctxt->sax->error = catchXMLError; - pctxt->_private = conn; - if (conn) virResetError (&conn->err); xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr, "domain.xml", NULL, XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOWARNING); if (!xml) { if (virGetLastError() == NULL) - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("failed to parse xml document")); goto cleanup; } if ((root = xmlDocGetRootElement(xml)) == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing root element")); goto cleanup; } - def = virDomainDefParseNode(conn, caps, xml, root, flags); + def = virDomainDefParseNode(caps, xml, root, flags); cleanup: xmlFreeParserCtxt (pctxt); @@ -4107,8 +4064,7 @@ cleanup: return def; } -virDomainDefPtr virDomainDefParseFile(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, const char *filename, int flags) { xmlParserCtxtPtr pctxt; @@ -4121,26 +4077,24 @@ virDomainDefPtr virDomainDefParseFile(virConnectPtr conn, if (!pctxt || !pctxt->sax) goto cleanup; pctxt->sax->error = catchXMLError; - pctxt->_private = conn; - if (conn) virResetError (&conn->err); xml = xmlCtxtReadFile (pctxt, filename, NULL, XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOWARNING); if (!xml) { if (virGetLastError() == NULL) - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("failed to parse xml document")); goto cleanup; } if ((root = xmlDocGetRootElement(xml)) == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing root element")); goto cleanup; } - def = virDomainDefParseNode(conn, caps, xml, root, flags); + def = virDomainDefParseNode(caps, xml, root, flags); cleanup: xmlFreeParserCtxt (pctxt); @@ -4149,8 +4103,7 @@ cleanup: } -virDomainDefPtr virDomainDefParseNode(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, xmlDocPtr xml, xmlNodePtr root, int flags) @@ -4159,7 +4112,7 @@ virDomainDefPtr virDomainDefParseNode(virConnectPtr conn, virDomainDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domain")) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("incorrect root element")); goto cleanup; } @@ -4171,7 +4124,7 @@ virDomainDefPtr virDomainDefParseNode(virConnectPtr conn, } ctxt->node = root; - def = virDomainDefParseXML(conn, caps, ctxt, flags); + def = virDomainDefParseXML(caps, ctxt, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -4179,8 +4132,7 @@ cleanup: } -virDomainObjPtr virDomainObjParseFile(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainObjParseFile(virCapsPtr caps, const char *filename) { xmlParserCtxtPtr pctxt; @@ -4193,26 +4145,24 @@ virDomainObjPtr virDomainObjParseFile(virConnectPtr conn, if (!pctxt || !pctxt->sax) goto cleanup; pctxt->sax->error = catchXMLError; - pctxt->_private = conn; - if (conn) virResetError (&conn->err); xml = xmlCtxtReadFile (pctxt, filename, NULL, XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOWARNING); if (!xml) { if (virGetLastError() == NULL) - virDomainReportError(conn, VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("failed to parse xml document")); goto cleanup; } if ((root = xmlDocGetRootElement(xml)) == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing root element")); goto cleanup; } - obj = virDomainObjParseNode(conn, caps, xml, root); + obj = virDomainObjParseNode(caps, xml, root); cleanup: xmlFreeParserCtxt (pctxt); @@ -4221,8 +4171,7 @@ cleanup: } -virDomainObjPtr virDomainObjParseNode(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainObjParseNode(virCapsPtr caps, xmlDocPtr xml, xmlNodePtr root) { @@ -4230,7 +4179,7 @@ virDomainObjPtr virDomainObjParseNode(virConnectPtr conn, virDomainObjPtr obj = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domstatus")) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("incorrect root element")); goto cleanup; } @@ -4242,7 +4191,7 @@ virDomainObjPtr virDomainObjParseNode(virConnectPtr conn, } ctxt->node = root; - obj = virDomainObjParseXML(conn, caps, ctxt); + obj = virDomainObjParseXML(caps, ctxt); cleanup: xmlXPathFreeContext(ctxt); @@ -4387,7 +4336,7 @@ virDomainCpuNumberParse(const char **str, int maxcpu) * freed by the caller. */ char * -virDomainCpuSetFormat(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, char *cpuset, int maxcpu) +virDomainCpuSetFormat(char *cpuset, int maxcpu) { virBuffer buf = VIR_BUFFER_INITIALIZER; int start, cur; @@ -4450,7 +4399,7 @@ virDomainCpuSetFormat(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, char *c * @str is updated to the end of the part parsed */ int -virDomainCpuSetParse(virConnectPtr conn, const char **str, char sep, +virDomainCpuSetParse(const char **str, char sep, char *cpuset, int maxcpu) { const char *cur; @@ -4531,21 +4480,20 @@ virDomainCpuSetParse(virConnectPtr conn, const char **str, char sep, return (ret); parse_error: - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("topology cpuset syntax error")); return (-1); } static int -virDomainLifecycleDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainLifecycleDefFormat(virBufferPtr buf, int type, const char *name) { const char *typeStr = virDomainLifecycleTypeToString(type); if (!typeStr) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle type %d"), type); return -1; } @@ -4557,8 +4505,7 @@ virDomainLifecycleDefFormat(virConnectPtr conn, static int -virDomainDiskDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainDiskDefFormat(virBufferPtr buf, virDomainDiskDefPtr def, int flags) { @@ -4568,22 +4515,22 @@ virDomainDiskDefFormat(virConnectPtr conn, const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %d"), def->type); return -1; } if (!device) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk device %d"), def->device); return -1; } if (!bus) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk bus %d"), def->bus); return -1; } if (!cachemode) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk cache mode %d"), def->cachemode); return -1; } @@ -4616,7 +4563,7 @@ virDomainDiskDefFormat(virConnectPtr conn, def->src); break; default: - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %s"), virDomainDiskTypeToString(def->type)); return -1; @@ -4634,7 +4581,7 @@ virDomainDiskDefFormat(virConnectPtr conn, virBufferEscapeString(buf, " <serial>%s</serial>\n", def->serial); if (def->encryption != NULL && - virStorageEncryptionFormat(conn, buf, def->encryption) < 0) + virStorageEncryptionFormat(NULL, buf, def->encryption) < 0) return -1; if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) @@ -4646,15 +4593,14 @@ virDomainDiskDefFormat(virConnectPtr conn, } static int -virDomainControllerDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainControllerDefFormat(virBufferPtr buf, virDomainControllerDefPtr def, int flags) { const char *type = virDomainControllerTypeToString(def->type); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected controller type %d"), def->type); return -1; } @@ -4676,15 +4622,14 @@ virDomainControllerDefFormat(virConnectPtr conn, } static int -virDomainFSDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainFSDefFormat(virBufferPtr buf, virDomainFSDefPtr def, int flags) { const char *type = virDomainFSTypeToString(def->type); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected filesystem type %d"), def->type); return -1; } @@ -4731,15 +4676,14 @@ virDomainFSDefFormat(virConnectPtr conn, } static int -virDomainNetDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefPtr def, int flags) { const char *type = virDomainNetTypeToString(def->type); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected net type %d"), def->type); return -1; } @@ -4815,8 +4759,7 @@ virDomainNetDefFormat(virConnectPtr conn, static int -virDomainChrDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainChrDefFormat(virBufferPtr buf, virDomainChrDefPtr def, int flags) { @@ -4837,7 +4780,7 @@ virDomainChrDefFormat(virConnectPtr conn, } if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected char type %d"), def->type); return -1; } @@ -4925,13 +4868,13 @@ virDomainChrDefFormat(virConnectPtr conn, { int port = virSocketGetPort(def->target.addr); if (port < 0) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to format guestfwd port")); return -1; } const char *addr = virSocketFormatAddr(def->target.addr); if (addr == NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to format guestfwd address")); return -1; } @@ -4950,7 +4893,7 @@ virDomainChrDefFormat(virConnectPtr conn, break; default: - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected character destination type %d"), def->targetType); return -1; @@ -4966,15 +4909,14 @@ virDomainChrDefFormat(virConnectPtr conn, } static int -virDomainSoundDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainSoundDefFormat(virBufferPtr buf, virDomainSoundDefPtr def, int flags) { const char *model = virDomainSoundModelTypeToString(def->model); if (!model) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected sound model %d"), def->model); return -1; } @@ -4996,8 +4938,7 @@ virDomainSoundDefFormat(virConnectPtr conn, static int -virDomainWatchdogDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainWatchdogDefFormat(virBufferPtr buf, virDomainWatchdogDefPtr def, int flags) { @@ -5005,13 +4946,13 @@ virDomainWatchdogDefFormat(virConnectPtr conn, const char *action = virDomainWatchdogActionTypeToString (def->action); if (!model) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected watchdog model %d"), def->model); return -1; } if (!action) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected watchdog action %d"), def->action); return -1; } @@ -5045,15 +4986,14 @@ virDomainVideoAccelDefFormat(virBufferPtr buf, static int -virDomainVideoDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainVideoDefFormat(virBufferPtr buf, virDomainVideoDefPtr def, int flags) { const char *model = virDomainVideoTypeToString(def->type); if (!model) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected video model %d"), def->type); return -1; } @@ -5082,8 +5022,7 @@ virDomainVideoDefFormat(virConnectPtr conn, } static int -virDomainInputDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainInputDefFormat(virBufferPtr buf, virDomainInputDefPtr def, int flags) { @@ -5091,12 +5030,12 @@ virDomainInputDefFormat(virConnectPtr conn, const char *bus = virDomainInputBusTypeToString(def->bus); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected input type %d"), def->type); return -1; } if (!bus) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected input bus type %d"), def->bus); return -1; } @@ -5118,15 +5057,14 @@ virDomainInputDefFormat(virConnectPtr conn, static int -virDomainGraphicsDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainGraphicsDefFormat(virBufferPtr buf, virDomainGraphicsDefPtr def, int flags) { const char *type = virDomainGraphicsTypeToString(def->type); if (!type) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected net type %d"), def->type); return -1; } @@ -5213,8 +5151,7 @@ virDomainGraphicsDefFormat(virConnectPtr conn, static int -virDomainHostdevDefFormat(virConnectPtr conn, - virBufferPtr buf, +virDomainHostdevDefFormat(virBufferPtr buf, virDomainHostdevDefPtr def, int flags) { @@ -5222,14 +5159,14 @@ virDomainHostdevDefFormat(virConnectPtr conn, const char *type; if (!mode || def->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected hostdev mode %d"), def->mode); return -1; } type = virDomainHostdevSubsysTypeToString(def->source.subsys.type); if (!type || (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB && def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) ) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected hostdev type %d"), def->source.subsys.type); return -1; @@ -5270,8 +5207,7 @@ virDomainHostdevDefFormat(virConnectPtr conn, } -char *virDomainDefFormat(virConnectPtr conn, - virDomainDefPtr def, +char *virDomainDefFormat(virDomainDefPtr def, int flags) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -5281,7 +5217,7 @@ char *virDomainDefFormat(virConnectPtr conn, int n, allones = 1; if (!(type = virDomainVirtTypeToString(def->virtType))) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected domain type %d"), def->virtType); goto cleanup; } @@ -5321,7 +5257,7 @@ char *virDomainDefFormat(virConnectPtr conn, } else { char *cpumask = NULL; if ((cpumask = - virDomainCpuSetFormat(conn, def->cpumask, def->cpumasklen)) == NULL) + virDomainCpuSetFormat(def->cpumask, def->cpumasklen)) == NULL) goto cleanup; virBufferVSprintf(&buf, " <vcpu cpuset='%s'>%lu</vcpu>\n", cpumask, def->vcpus); @@ -5377,7 +5313,7 @@ char *virDomainDefFormat(virConnectPtr conn, const char *boottype = virDomainBootTypeToString(def->os.bootDevs[n]); if (!boottype) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected boot device type %d"), def->os.bootDevs[n]); goto cleanup; @@ -5395,7 +5331,7 @@ char *virDomainDefFormat(virConnectPtr conn, if (def->features & (1 << i)) { const char *name = virDomainFeatureTypeToString(i); if (!name) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected feature %d"), i); goto cleanup; } @@ -5405,19 +5341,19 @@ char *virDomainDefFormat(virConnectPtr conn, virBufferAddLit(&buf, " </features>\n"); } - if (virCPUDefFormatBuf(conn, &buf, def->cpu, " ", 0) < 0) + if (virCPUDefFormatBuf(NULL, &buf, def->cpu, " ", 0) < 0) goto cleanup; virBufferVSprintf(&buf, " <clock offset='%s'/>\n", def->localtime ? "localtime" : "utc"); - if (virDomainLifecycleDefFormat(conn, &buf, def->onPoweroff, + if (virDomainLifecycleDefFormat(&buf, def->onPoweroff, "on_poweroff") < 0) goto cleanup; - if (virDomainLifecycleDefFormat(conn, &buf, def->onReboot, + if (virDomainLifecycleDefFormat(&buf, def->onReboot, "on_reboot") < 0) goto cleanup; - if (virDomainLifecycleDefFormat(conn, &buf, def->onCrash, + if (virDomainLifecycleDefFormat(&buf, def->onCrash, "on_crash") < 0) goto cleanup; @@ -5428,33 +5364,33 @@ char *virDomainDefFormat(virConnectPtr conn, def->emulator); for (n = 0 ; n < def->ndisks ; n++) - if (virDomainDiskDefFormat(conn, &buf, def->disks[n], flags) < 0) + if (virDomainDiskDefFormat(&buf, def->disks[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->ncontrollers ; n++) - if (virDomainControllerDefFormat(conn, &buf, def->controllers[n], flags) < 0) + if (virDomainControllerDefFormat(&buf, def->controllers[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->nfss ; n++) - if (virDomainFSDefFormat(conn, &buf, def->fss[n], flags) < 0) + if (virDomainFSDefFormat(&buf, def->fss[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->nnets ; n++) - if (virDomainNetDefFormat(conn, &buf, def->nets[n], flags) < 0) + if (virDomainNetDefFormat(&buf, def->nets[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->nserials ; n++) - if (virDomainChrDefFormat(conn, &buf, def->serials[n], flags) < 0) + if (virDomainChrDefFormat(&buf, def->serials[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->nparallels ; n++) - if (virDomainChrDefFormat(conn, &buf, def->parallels[n], flags) < 0) + if (virDomainChrDefFormat(&buf, def->parallels[n], flags) < 0) goto cleanup; /* If there's a PV console that's preferred.. */ if (def->console) { - if (virDomainChrDefFormat(conn, &buf, def->console, flags) < 0) + if (virDomainChrDefFormat(&buf, def->console, flags) < 0) goto cleanup; } else if (def->nserials != 0) { /* ..else for legacy compat duplicate the first serial device as a @@ -5462,17 +5398,17 @@ char *virDomainDefFormat(virConnectPtr conn, virDomainChrDef console; memcpy(&console, def->serials[0], sizeof(console)); console.targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE; - if (virDomainChrDefFormat(conn, &buf, &console, flags) < 0) + if (virDomainChrDefFormat(&buf, &console, flags) < 0) goto cleanup; } for (n = 0 ; n < def->nchannels ; n++) - if (virDomainChrDefFormat(conn, &buf, def->channels[n], flags) < 0) + if (virDomainChrDefFormat(&buf, def->channels[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->ninputs ; n++) if (def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_USB && - virDomainInputDefFormat(conn, &buf, def->inputs[n], flags) < 0) + virDomainInputDefFormat(&buf, def->inputs[n], flags) < 0) goto cleanup; if (def->ngraphics > 0) { @@ -5484,28 +5420,28 @@ char *virDomainDefFormat(virConnectPtr conn, { .alias = NULL }, }; - if (virDomainInputDefFormat(conn, &buf, &autoInput, flags) < 0) + if (virDomainInputDefFormat(&buf, &autoInput, flags) < 0) goto cleanup; for (n = 0 ; n < def->ngraphics ; n++) - if (virDomainGraphicsDefFormat(conn, &buf, def->graphics[n], flags) < 0) + if (virDomainGraphicsDefFormat(&buf, def->graphics[n], flags) < 0) goto cleanup; } for (n = 0 ; n < def->nsounds ; n++) - if (virDomainSoundDefFormat(conn, &buf, def->sounds[n], flags) < 0) + if (virDomainSoundDefFormat(&buf, def->sounds[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->nvideos ; n++) - if (virDomainVideoDefFormat(conn, &buf, def->videos[n], flags) < 0) + if (virDomainVideoDefFormat(&buf, def->videos[n], flags) < 0) goto cleanup; for (n = 0 ; n < def->nhostdevs ; n++) - if (virDomainHostdevDefFormat(conn, &buf, def->hostdevs[n], flags) < 0) + if (virDomainHostdevDefFormat(&buf, def->hostdevs[n], flags) < 0) goto cleanup; if (def->watchdog) - virDomainWatchdogDefFormat (conn, &buf, def->watchdog, flags); + virDomainWatchdogDefFormat (&buf, def->watchdog, flags); virBufferAddLit(&buf, " </devices>\n"); @@ -5545,8 +5481,7 @@ char *virDomainDefFormat(virConnectPtr conn, return NULL; } -char *virDomainObjFormat(virConnectPtr conn, - virCapsPtr caps, +char *virDomainObjFormat(virCapsPtr caps, virDomainObjPtr obj, int flags) { @@ -5561,8 +5496,7 @@ char *virDomainObjFormat(virConnectPtr conn, ((caps->privateDataXMLFormat)(&buf, obj->privateData)) < 0) goto error; - if (!(config_xml = virDomainDefFormat(conn, - obj->def, + if (!(config_xml = virDomainDefFormat(obj->def, flags))) goto error; @@ -5585,8 +5519,7 @@ error: #ifndef PROXY -int virDomainSaveXML(virConnectPtr conn, - const char *configDir, +int virDomainSaveXML(const char *configDir, virDomainDefPtr def, const char *xml) { @@ -5594,7 +5527,7 @@ int virDomainSaveXML(virConnectPtr conn, int fd = -1, ret = -1; size_t towrite; - if ((configFile = virDomainConfigFile(conn, configDir, def->name)) == NULL) + if ((configFile = virDomainConfigFile(configDir, def->name)) == NULL) goto cleanup; if (virFileMakePath(configDir)) { @@ -5636,19 +5569,17 @@ int virDomainSaveXML(virConnectPtr conn, return ret; } -int virDomainSaveConfig(virConnectPtr conn, - const char *configDir, +int virDomainSaveConfig(const char *configDir, virDomainDefPtr def) { int ret = -1; char *xml; - if (!(xml = virDomainDefFormat(conn, - def, + if (!(xml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE))) goto cleanup; - if (virDomainSaveXML(conn, configDir, def, xml)) + if (virDomainSaveXML(configDir, def, xml)) goto cleanup; ret = 0; @@ -5657,8 +5588,7 @@ cleanup: return ret; } -int virDomainSaveStatus(virConnectPtr conn, - virCapsPtr caps, +int virDomainSaveStatus(virCapsPtr caps, const char *statusDir, virDomainObjPtr obj) { @@ -5666,10 +5596,10 @@ int virDomainSaveStatus(virConnectPtr conn, int ret = -1; char *xml; - if (!(xml = virDomainObjFormat(conn, caps, obj, flags))) + if (!(xml = virDomainObjFormat(caps, obj, flags))) goto cleanup; - if (virDomainSaveXML(conn, statusDir, obj->def, xml)) + if (virDomainSaveXML(statusDir, obj->def, xml)) goto cleanup; ret = 0; @@ -5679,8 +5609,7 @@ cleanup: } -virDomainObjPtr virDomainLoadConfig(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainLoadConfig(virCapsPtr caps, virDomainObjListPtr doms, const char *configDir, const char *autostartDir, @@ -5694,15 +5623,15 @@ virDomainObjPtr virDomainLoadConfig(virConnectPtr conn, int autostart; int newVM = 1; - if ((configFile = virDomainConfigFile(conn, configDir, name)) == NULL) + if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; - if ((autostartLink = virDomainConfigFile(conn, autostartDir, name)) == NULL) + if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) goto error; if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; - if (!(def = virDomainDefParseFile(conn, caps, configFile, + if (!(def = virDomainDefParseFile(caps, configFile, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -5712,7 +5641,7 @@ virDomainObjPtr virDomainLoadConfig(virConnectPtr conn, newVM = 0; } - if (!(dom = virDomainAssignDef(conn, caps, doms, def))) + if (!(dom = virDomainAssignDef(caps, doms, def))) goto error; dom->autostart = autostart; @@ -5731,8 +5660,7 @@ error: return NULL; } -static virDomainObjPtr virDomainLoadStatus(virConnectPtr conn, - virCapsPtr caps, +static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps, virDomainObjListPtr doms, const char *statusDir, const char *name, @@ -5743,16 +5671,16 @@ static virDomainObjPtr virDomainLoadStatus(virConnectPtr conn, virDomainObjPtr obj = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; - if ((statusFile = virDomainConfigFile(conn, statusDir, name)) == NULL) + if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) goto error; - if (!(obj = virDomainObjParseFile(conn, caps, statusFile))) + if (!(obj = virDomainObjParseFile(caps, statusFile))) goto error; virUUIDFormat(obj->def->uuid, uuidstr); if (virHashLookup(doms->objs, uuidstr) != NULL) { - virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected domain %s already exists"), obj->def->name); goto error; @@ -5776,8 +5704,7 @@ error: return NULL; } -int virDomainLoadAllConfigs(virConnectPtr conn, - virCapsPtr caps, +int virDomainLoadAllConfigs(virCapsPtr caps, virDomainObjListPtr doms, const char *configDir, const char *autostartDir, @@ -5812,16 +5739,14 @@ int virDomainLoadAllConfigs(virConnectPtr conn, kill the whole process */ VIR_INFO("Loading config file '%s.xml'", entry->d_name); if (liveStatus) - dom = virDomainLoadStatus(conn, - caps, + dom = virDomainLoadStatus(caps, doms, configDir, entry->d_name, notify, opaque); else - dom = virDomainLoadConfig(conn, - caps, + dom = virDomainLoadConfig(caps, doms, configDir, autostartDir, @@ -5840,17 +5765,16 @@ int virDomainLoadAllConfigs(virConnectPtr conn, return 0; } -int virDomainDeleteConfig(virConnectPtr conn, - const char *configDir, +int virDomainDeleteConfig(const char *configDir, const char *autostartDir, virDomainObjPtr dom) { char *configFile = NULL, *autostartLink = NULL; int ret = -1; - if ((configFile = virDomainConfigFile(conn, configDir, dom->def->name)) == NULL) + if ((configFile = virDomainConfigFile(configDir, dom->def->name)) == NULL) goto cleanup; - if ((autostartLink = virDomainConfigFile(conn, autostartDir, dom->def->name)) == NULL) + if ((autostartLink = virDomainConfigFile(autostartDir, dom->def->name)) == NULL) goto cleanup; /* Not fatal if this doesn't work */ @@ -5872,8 +5796,7 @@ cleanup: return ret; } -char *virDomainConfigFile(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - const char *dir, +char *virDomainConfigFile(const char *dir, const char *name) { char *ret = NULL; @@ -5965,16 +5888,16 @@ virDomainObjIsDuplicate(virDomainObjListPtr doms, if (STRNEQ(vm->def->name, def->name)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); - virDomainReportError(NULL, VIR_ERR_OPERATION_FAILED, - _("domain '%s' is already defined with uuid %s"), - vm->def->name, uuidstr); + virDomainReportError(VIR_ERR_OPERATION_FAILED, + _("domain '%s' is already defined with uuid %s"), + vm->def->name, uuidstr); goto cleanup; } if (check_active) { /* UUID & name match, but if VM is already active, refuse it */ if (virDomainObjIsActive(vm)) { - virDomainReportError(NULL, VIR_ERR_OPERATION_INVALID, + virDomainReportError(VIR_ERR_OPERATION_INVALID, _("domain is already active as '%s'"), vm->def->name); goto cleanup; @@ -5988,7 +5911,7 @@ virDomainObjIsDuplicate(virDomainObjListPtr doms, if (vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); - virDomainReportError(NULL, VIR_ERR_OPERATION_FAILED, + virDomainReportError(VIR_ERR_OPERATION_FAILED, _("domain '%s' already exists with uuid %s"), def->name, uuidstr); goto cleanup; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0b79e88..07c9866 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -751,59 +751,48 @@ void virDomainObjRef(virDomainObjPtr vm); /* Returns 1 if the object was freed, 0 if more refs exist */ int virDomainObjUnref(virDomainObjPtr vm); -virDomainObjPtr virDomainAssignDef(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainAssignDef(virCapsPtr caps, virDomainObjListPtr doms, const virDomainDefPtr def); void virDomainRemoveInactive(virDomainObjListPtr doms, virDomainObjPtr dom); #ifndef PROXY -virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, - virCapsPtr caps, +virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, const virDomainDefPtr def, const char *xmlStr, int flags); -virDomainDefPtr virDomainDefParseString(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr virDomainDefParseString(virCapsPtr caps, const char *xmlStr, int flags); -virDomainDefPtr virDomainDefParseFile(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, const char *filename, int flags); -virDomainDefPtr virDomainDefParseNode(virConnectPtr conn, - virCapsPtr caps, +virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, xmlDocPtr doc, xmlNodePtr root, int flags); -virDomainObjPtr virDomainObjParseFile(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainObjParseFile(virCapsPtr caps, const char *filename); -virDomainObjPtr virDomainObjParseNode(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainObjParseNode(virCapsPtr caps, xmlDocPtr xml, xmlNodePtr root); int virDomainDefAddDiskControllers(virDomainDefPtr def); #endif -char *virDomainDefFormat(virConnectPtr conn, - virDomainDefPtr def, +char *virDomainDefFormat(virDomainDefPtr def, int flags); -char *virDomainObjFormat(virConnectPtr conn, - virCapsPtr caps, +char *virDomainObjFormat(virCapsPtr caps, virDomainObjPtr obj, int flags); -int virDomainCpuSetParse(virConnectPtr conn, - const char **str, +int virDomainCpuSetParse(const char **str, char sep, char *cpuset, int maxcpu); -char *virDomainCpuSetFormat(virConnectPtr conn, - char *cpuset, +char *virDomainCpuSetFormat(char *cpuset, int maxcpu); int virDomainDiskInsert(virDomainDefPtr def, @@ -817,16 +806,13 @@ int virDomainControllerInsert(virDomainDefPtr def, void virDomainControllerInsertPreAlloced(virDomainDefPtr def, virDomainControllerDefPtr controller); -int virDomainSaveXML(virConnectPtr conn, - const char *configDir, +int virDomainSaveXML(const char *configDir, virDomainDefPtr def, const char *xml); -int virDomainSaveConfig(virConnectPtr conn, - const char *configDir, +int virDomainSaveConfig(const char *configDir, virDomainDefPtr def); -int virDomainSaveStatus(virConnectPtr conn, - virCapsPtr caps, +int virDomainSaveStatus(virCapsPtr caps, const char *statusDir, virDomainObjPtr obj); @@ -834,8 +820,7 @@ typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom, int newDomain, void *opaque); -virDomainObjPtr virDomainLoadConfig(virConnectPtr conn, - virCapsPtr caps, +virDomainObjPtr virDomainLoadConfig(virCapsPtr caps, virDomainObjListPtr doms, const char *configDir, const char *autostartDir, @@ -843,8 +828,7 @@ virDomainObjPtr virDomainLoadConfig(virConnectPtr conn, virDomainLoadConfigNotify notify, void *opaque); -int virDomainLoadAllConfigs(virConnectPtr conn, - virCapsPtr caps, +int virDomainLoadAllConfigs(virCapsPtr caps, virDomainObjListPtr doms, const char *configDir, const char *autostartDir, @@ -852,13 +836,11 @@ int virDomainLoadAllConfigs(virConnectPtr conn, virDomainLoadConfigNotify notify, void *opaque); -int virDomainDeleteConfig(virConnectPtr conn, - const char *configDir, +int virDomainDeleteConfig(const char *configDir, const char *autostartDir, virDomainObjPtr dom); -char *virDomainConfigFile(virConnectPtr conn, - const char *dir, +char *virDomainConfigFile(const char *dir, const char *name); int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 352495a..535ec43 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2182,7 +2182,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags) priv->host->apiVersion); if (def != NULL) { - xml = virDomainDefFormat(domain->conn, def, flags); + xml = virDomainDefFormat(def, flags); } cleanup: @@ -2225,7 +2225,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat, priv->host->apiVersion); if (def != NULL) { - xml = virDomainDefFormat(conn, def, VIR_DOMAIN_XML_INACTIVE); + xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); } virDomainDefFree(def); @@ -2250,7 +2250,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, return NULL; } - def = virDomainDefParseString(conn, priv->caps, domainXml, 0); + def = virDomainDefParseString(priv->caps, domainXml, 0); if (def == NULL) { return NULL; @@ -2454,7 +2454,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED) } /* Parse domain XML */ - def = virDomainDefParseString(conn, priv->caps, xml, + def = virDomainDefParseString(priv->caps, xml, VIR_DOMAIN_XML_INACTIVE); if (def == NULL) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 3d45ad2..95970cc 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -742,12 +742,11 @@ int main(int argc, char *argv[]) if ((caps = lxcCapsInit()) == NULL) goto cleanup; - if ((configFile = virDomainConfigFile(NULL, - LXC_STATE_DIR, + if ((configFile = virDomainConfigFile(LXC_STATE_DIR, name)) == NULL) goto cleanup; - if ((def = virDomainDefParseFile(NULL, caps, configFile, + if ((def = virDomainDefParseFile(caps, configFile, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index d7b9631..1a73ca6 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -366,7 +366,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) int dupVM; lxcDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -379,14 +379,13 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) goto cleanup; } - if (!(vm = virDomainAssignDef(conn, driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) goto cleanup; def = NULL; vm->persistent = 1; - if (virDomainSaveConfig(conn, - driver->configDir, + if (virDomainSaveConfig(driver->configDir, vm->newDef ? vm->newDef : vm->def) < 0) { virDomainRemoveInactive(&driver->domains, vm); vm = NULL; @@ -440,8 +439,7 @@ static int lxcDomainUndefine(virDomainPtr dom) goto cleanup; } - if (virDomainDeleteConfig(dom->conn, - driver->configDir, + if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0) goto cleanup; @@ -667,8 +665,7 @@ static char *lxcDomainDumpXML(virDomainPtr dom, goto cleanup; } - ret = virDomainDefFormat(dom->conn, - (flags & VIR_DOMAIN_XML_INACTIVE) && + ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? vm->newDef : vm->def, flags); @@ -722,7 +719,7 @@ static int lxcVmCleanup(lxc_driver_t *driver, close(priv->monitor); virFileDeletePid(driver->stateDir, vm->def->name); - virDomainDeleteConfig(NULL, driver->stateDir, NULL, vm); + virDomainDeleteConfig(driver->stateDir, NULL, vm); vm->state = VIR_DOMAIN_SHUTOFF; vm->pid = -1; @@ -1220,7 +1217,7 @@ static int lxcVmStart(virConnectPtr conn, goto cleanup; /* Persist the live configuration now we have veth & tty info */ - if (virDomainSaveConfig(conn, driver->stateDir, vm->def) < 0) + if (virDomainSaveConfig(driver->stateDir, vm->def) < 0) goto cleanup; if ((logfd = open(logfile, O_WRONLY | O_APPEND | O_CREAT, @@ -1349,7 +1346,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, virDomainEventPtr event = NULL; lxcDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1363,7 +1360,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, } - if (!(vm = virDomainAssignDef(conn, driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) goto cleanup; def = NULL; @@ -1657,13 +1654,12 @@ lxcReconnectVM(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque) goto cleanup; } - if ((config = virDomainConfigFile(NULL, - driver->stateDir, + if ((config = virDomainConfigFile(driver->stateDir, vm->def->name)) == NULL) goto cleanup; /* Try and load the live config */ - tmp = virDomainDefParseFile(NULL, driver->caps, config, 0); + tmp = virDomainDefParseFile(driver->caps, config, 0); VIR_FREE(config); if (tmp) { vm->newDef = vm->def; @@ -1761,8 +1757,7 @@ static int lxcStartup(int privileged) lxc_driver->caps->privateDataAllocFunc = lxcDomainObjPrivateAlloc; lxc_driver->caps->privateDataFreeFunc = lxcDomainObjPrivateFree; - if (virDomainLoadAllConfigs(NULL, - lxc_driver->caps, + if (virDomainLoadAllConfigs(lxc_driver->caps, &lxc_driver->domains, lxc_driver->configDir, lxc_driver->autostartDir, @@ -1806,8 +1801,7 @@ lxcReload(void) { return 0; lxcDriverLock(lxc_driver); - virDomainLoadAllConfigs(NULL, - lxc_driver->caps, + virDomainLoadAllConfigs(lxc_driver->caps, &lxc_driver->domains, lxc_driver->configDir, lxc_driver->autostartDir, @@ -2122,11 +2116,11 @@ static int lxcDomainSetAutostart(virDomainPtr dom, goto cleanup; } - configFile = virDomainConfigFile(dom->conn, driver->configDir, + configFile = virDomainConfigFile(driver->configDir, vm->def->name); if (configFile == NULL) goto cleanup; - autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, + autostartLink = virDomainConfigFile(driver->autostartDir, vm->def->name); if (autostartLink == NULL) goto cleanup; @@ -2297,7 +2291,7 @@ static int lxcDomainSuspend(virDomainPtr dom) VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); } - if (virDomainSaveStatus(dom->conn, driver->caps, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) goto cleanup; ret = 0; @@ -2362,7 +2356,7 @@ static int lxcDomainResume(virDomainPtr dom) VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); } - if (virDomainSaveStatus(dom->conn, driver->caps, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) goto cleanup; ret = 0; diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index 657fa36..b41c418 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -246,11 +246,11 @@ static virDomainPtr oneDomainDefine(virConnectPtr conn, const char *xml) virDomainPtr dom=NULL; oneDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto return_point; - if (!(vm = virDomainAssignDef(conn, driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) { virDomainDefFree(def); goto return_point; @@ -443,7 +443,7 @@ oneDomainCreateAndStart(virConnectPtr conn, int oneid; oneDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto return_point; @@ -455,7 +455,7 @@ oneDomainCreateAndStart(virConnectPtr conn, goto return_point; } - if (!(vm = virDomainAssignDef(conn, driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) { virDomainDefFree(def); goto return_point; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index a3f0a5b..5c07857 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -479,7 +479,7 @@ static char *openvzDomainDumpXML(virDomainPtr dom, int flags) { goto cleanup; } - ret = virDomainDefFormat(dom->conn, vm->def, flags); + ret = virDomainDefFormat(vm->def, flags); cleanup: if (vm) @@ -806,7 +806,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) virDomainPtr dom = NULL; openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(conn, driver->caps, xml, + if ((vmdef = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -824,7 +824,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) vmdef->name); goto cleanup; } - if (!(vm = virDomainAssignDef(conn, driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, vmdef))) goto cleanup; vmdef = NULL; @@ -886,7 +886,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, const char *progstart[] = {VZCTL, "--quiet", "start", PROGRAM_SENTINAL, NULL}; openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(conn, driver->caps, xml, + if ((vmdef = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -904,7 +904,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, vmdef->name); goto cleanup; } - if (!(vm = virDomainAssignDef(conn, driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, vmdef))) goto cleanup; vmdef = NULL; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 11b6227..eef1cc7 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1270,7 +1270,7 @@ phypDomainDumpXML(virDomainPtr dom, int flags) goto err; } - return virDomainDefFormat(dom->conn, &def, flags); + return virDomainDefFormat(&def, flags); err: return NULL; @@ -1420,7 +1420,7 @@ phypDomainCreateAndStart(virConnectPtr conn, unsigned int i = 0; char *managed_system = phyp_driver->managed_system; - if (!(def = virDomainDefParseString(conn, phyp_driver->caps, xml, + if (!(def = virDomainDefParseString(phyp_driver->caps, xml, VIR_DOMAIN_XML_SECURE))) goto err; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index da13473..7c5dfe4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1158,8 +1158,7 @@ qemudStartup(int privileged) { } /* Get all the running persistent or transient configs first */ - if (virDomainLoadAllConfigs(NULL, - qemu_driver->caps, + if (virDomainLoadAllConfigs(qemu_driver->caps, &qemu_driver->domains, qemu_driver->stateDir, NULL, @@ -1169,8 +1168,7 @@ qemudStartup(int privileged) { qemuReconnectDomains(qemu_driver); /* Then inactive persistent configs */ - if (virDomainLoadAllConfigs(NULL, - qemu_driver->caps, + if (virDomainLoadAllConfigs(qemu_driver->caps, &qemu_driver->domains, qemu_driver->configDir, qemu_driver->autostartDir, @@ -1219,8 +1217,7 @@ qemudReload(void) { return 0; qemuDriverLock(qemu_driver); - virDomainLoadAllConfigs(NULL, - qemu_driver->caps, + virDomainLoadAllConfigs(qemu_driver->caps, &qemu_driver->domains, qemu_driver->configDir, qemu_driver->autostartDir, @@ -2757,7 +2754,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, qemuDomainObjExitMonitorWithDriver(driver, vm); - if (virDomainSaveStatus(conn, driver->caps, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) goto abort; return 0; @@ -3305,7 +3302,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml, virDomainEventPtr event = NULL; qemuDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -3315,8 +3312,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml, if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) goto cleanup; - if (!(vm = virDomainAssignDef(conn, - driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) goto cleanup; @@ -3394,7 +3390,7 @@ static int qemudDomainSuspend(virDomainPtr dom) { VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); } - if (virDomainSaveStatus(dom->conn, driver->caps, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) goto endjob; ret = 0; @@ -3454,7 +3450,7 @@ static int qemudDomainResume(virDomainPtr dom) { VIR_DOMAIN_EVENT_RESUMED, VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); } - if (virDomainSaveStatus(dom->conn, driver->caps, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) goto endjob; ret = 0; @@ -3878,7 +3874,7 @@ static int qemudDomainSave(virDomainPtr dom, } /* Get XML for the domain */ - xml = virDomainDefFormat(dom->conn, vm->def, VIR_DOMAIN_XML_SECURE); + xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE); if (!xml) { qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to get domain xml")); @@ -4501,7 +4497,7 @@ static int qemudDomainRestore(virConnectPtr conn, } /* Create a domain from this XML */ - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) { qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to parse XML")); @@ -4511,8 +4507,7 @@ static int qemudDomainRestore(virConnectPtr conn, if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) goto cleanup; - if (!(vm = virDomainAssignDef(conn, - driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) { qemuReportError(VIR_ERR_OPERATION_FAILED, @@ -4585,7 +4580,7 @@ static int qemudDomainRestore(virConnectPtr conn, } qemuDomainObjExitMonitorWithDriver(driver, vm); vm->state = VIR_DOMAIN_RUNNING; - virDomainSaveStatus(conn, driver->caps, driver->stateDir, vm); + virDomainSaveStatus(driver->caps, driver->stateDir, vm); } ret = 0; @@ -4652,8 +4647,7 @@ static char *qemudDomainDumpXML(virDomainPtr dom, } } - ret = virDomainDefFormat(dom->conn, - (flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? + ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? vm->newDef : vm->def, flags); @@ -4684,7 +4678,7 @@ static char *qemuDomainXMLFromNative(virConnectPtr conn, if (!def) goto cleanup; - xml = virDomainDefFormat(conn, def, VIR_DOMAIN_XML_INACTIVE); + xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); cleanup: virDomainDefFree(def); @@ -4716,7 +4710,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, goto cleanup; } - def = virDomainDefParseString(conn, driver->caps, xmlData, 0); + def = virDomainDefParseString(driver->caps, xmlData, 0); if (!def) goto cleanup; @@ -5002,7 +4996,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) { int dupVM; qemuDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -5015,8 +5009,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) { if (qemudCanonicalizeMachine(driver, def) < 0) goto cleanup; - if (!(vm = virDomainAssignDef(conn, - driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) { goto cleanup; @@ -5024,8 +5017,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) { def = NULL; vm->persistent = 1; - if (virDomainSaveConfig(conn, - driver->configDir, + if (virDomainSaveConfig(driver->configDir, vm->newDef ? vm->newDef : vm->def) < 0) { virDomainRemoveInactive(&driver->domains, vm); @@ -5081,7 +5073,7 @@ static int qemudDomainUndefine(virDomainPtr dom) { goto cleanup; } - if (virDomainDeleteConfig(dom->conn, driver->configDir, driver->autostartDir, vm) < 0) + if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0) goto cleanup; event = virDomainEventNewFromObj(vm, @@ -5912,7 +5904,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom, goto endjob; } - dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml, + dev = virDomainDeviceDefParse(driver->caps, vm->def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto endjob; @@ -6010,7 +6002,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom, goto endjob; } - if (!ret && virDomainSaveStatus(dom->conn, driver->caps, driver->stateDir, vm) < 0) + if (!ret && virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) ret = -1; endjob: @@ -6397,7 +6389,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom, goto endjob; } - dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml, + dev = virDomainDeviceDefParse(driver->caps, vm->def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto endjob; @@ -6425,7 +6417,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom, "%s", _("This type of device cannot be hot unplugged")); } - if (!ret && virDomainSaveStatus(dom->conn, driver->caps, driver->stateDir, vm) < 0) + if (!ret && virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) ret = -1; endjob: @@ -6506,9 +6498,9 @@ static int qemudDomainSetAutostart(virDomainPtr dom, autostart = (autostart != 0); if (vm->autostart != autostart) { - if ((configFile = virDomainConfigFile(dom->conn, driver->configDir, vm->def->name)) == NULL) + if ((configFile = virDomainConfigFile(driver->configDir, vm->def->name)) == NULL) goto cleanup; - if ((autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, vm->def->name)) == NULL) + if ((autostartLink = virDomainConfigFile(driver->autostartDir, vm->def->name)) == NULL) goto cleanup; if (autostart) { @@ -7441,7 +7433,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, } /* Parse the domain XML. */ - if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml, + if (!(def = virDomainDefParseString(driver->caps, dom_xml, VIR_DOMAIN_XML_INACTIVE))) { qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to parse XML")); @@ -7454,8 +7446,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) goto cleanup; - if (!(vm = virDomainAssignDef(dconn, - driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) { qemuReportError(VIR_ERR_OPERATION_FAILED, @@ -7668,7 +7659,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, VIR_DEBUG("Generated uri_out=%s", *uri_out); /* Parse the domain XML. */ - if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml, + if (!(def = virDomainDefParseString(driver->caps, dom_xml, VIR_DOMAIN_XML_INACTIVE))) { qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to parse XML")); @@ -7681,8 +7672,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) goto cleanup; - if (!(vm = virDomainAssignDef(dconn, - driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) { qemuReportError(VIR_ERR_OPERATION_FAILED, @@ -8117,7 +8107,7 @@ static int doPeer2PeerMigrate(virDomainPtr dom, goto cleanup; } - dom_xml = virDomainDefFormat(dom->conn, vm->def, VIR_DOMAIN_XML_SECURE); + dom_xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE); if (!dom_xml) { qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to get domain xml")); @@ -8210,7 +8200,7 @@ qemudDomainMigratePerform (virDomainPtr dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_MIGRATED); if (!vm->persistent || (flags & VIR_MIGRATE_UNDEFINE_SOURCE)) { - virDomainDeleteConfig(dom->conn, driver->configDir, driver->autostartDir, vm); + virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm); if (qemuDomainObjEndJob(vm) > 0) virDomainRemoveInactive(&driver->domains, vm); vm = NULL; @@ -8290,7 +8280,7 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn, newVM = 0; vm->persistent = 1; - if (virDomainSaveConfig(dconn, driver->configDir, vm->def) < 0) { + if (virDomainSaveConfig(driver->configDir, vm->def) < 0) { /* Hmpf. Migration was successful, but making it persistent * was not. If we report successful, then when this domain * shuts down, management tools are in for a surprise. On the @@ -8344,7 +8334,7 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); } - virDomainSaveStatus(dconn, driver->caps, driver->stateDir, vm); + virDomainSaveStatus(driver->caps, driver->stateDir, vm); } else { qemudShutdownVMDaemon (dconn, driver, vm); event = virDomainEventNewFromObj(vm, diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 411c5cd..c141ae4 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -539,13 +539,13 @@ static int testOpenDefault(virConnectPtr conn) { privconn->nextDomID = 1; - if (!(domdef = virDomainDefParseString(conn, privconn->caps, + if (!(domdef = virDomainDefParseString(privconn->caps, defaultDomainXML, VIR_DOMAIN_XML_INACTIVE))) goto error; if (testDomainGenerateIfnames(conn, domdef) < 0) goto error; - if (!(domobj = virDomainAssignDef(conn, privconn->caps, + if (!(domobj = virDomainAssignDef(privconn->caps, &privconn->domains, domdef))) goto error; domdef = NULL; @@ -890,19 +890,19 @@ static int testOpenFromFile(virConnectPtr conn, testError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("resolving domain filename")); goto error; } - def = virDomainDefParseFile(conn, privconn->caps, absFile, + def = virDomainDefParseFile(privconn->caps, absFile, VIR_DOMAIN_XML_INACTIVE); VIR_FREE(absFile); if (!def) goto error; } else { - if ((def = virDomainDefParseNode(conn, privconn->caps, xml, domains[i], - VIR_DOMAIN_XML_INACTIVE)) == NULL) + if ((def = virDomainDefParseNode(privconn->caps, xml, domains[i], + VIR_DOMAIN_XML_INACTIVE)) == NULL) goto error; } if (testDomainGenerateIfnames(conn, def) < 0 || - !(dom = virDomainAssignDef(conn, privconn->caps, + !(dom = virDomainAssignDef(privconn->caps, &privconn->domains, def))) { virDomainDefFree(def); goto error; @@ -1291,7 +1291,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, virDomainEventPtr event = NULL; testDriverLock(privconn); - if ((def = virDomainDefParseString(conn, privconn->caps, xml, + if ((def = virDomainDefParseString(privconn->caps, xml, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -1300,7 +1300,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, if (testDomainGenerateIfnames(conn, def) < 0) goto cleanup; - if (!(dom = virDomainAssignDef(conn, privconn->caps, + if (!(dom = virDomainAssignDef(privconn->caps, &privconn->domains, def))) goto cleanup; def = NULL; @@ -1707,8 +1707,7 @@ static int testDomainSave(virDomainPtr domain, goto cleanup; } - xml = virDomainDefFormat(domain->conn, - privdom->def, + xml = virDomainDefFormat(privdom->def, VIR_DOMAIN_XML_SECURE); if (xml == NULL) { @@ -1836,7 +1835,7 @@ static int testDomainRestore(virConnectPtr conn, xml[len] = '\0'; testDriverLock(privconn); - def = virDomainDefParseString(conn, privconn->caps, xml, + def = virDomainDefParseString(privconn->caps, xml, VIR_DOMAIN_XML_INACTIVE); if (!def) goto cleanup; @@ -1846,7 +1845,7 @@ static int testDomainRestore(virConnectPtr conn, if (testDomainGenerateIfnames(conn, def) < 0) goto cleanup; - if (!(dom = virDomainAssignDef(conn, privconn->caps, + if (!(dom = virDomainAssignDef(privconn->caps, &privconn->domains, def))) goto cleanup; def = NULL; @@ -2241,8 +2240,7 @@ static char *testDomainDumpXML(virDomainPtr domain, int flags) def = (flags & VIR_DOMAIN_XML_INACTIVE) && privdom->newDef ? privdom->newDef : privdom->def; - ret = virDomainDefFormat(domain->conn, - def, + ret = virDomainDefFormat(def, flags); cleanup: @@ -2287,7 +2285,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, int dupVM; testDriverLock(privconn); - if ((def = virDomainDefParseString(conn, privconn->caps, xml, + if ((def = virDomainDefParseString(privconn->caps, xml, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -2296,7 +2294,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, if (testDomainGenerateIfnames(conn, def) < 0) goto cleanup; - if (!(dom = virDomainAssignDef(conn, privconn->caps, + if (!(dom = virDomainAssignDef(privconn->caps, &privconn->domains, def))) goto cleanup; def = NULL; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index cb6bf3a..541ff9a 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -435,8 +435,7 @@ umlStartup(int privileged) { umlInotifyEvent, uml_driver, NULL)) < 0) goto error; - if (virDomainLoadAllConfigs(NULL, - uml_driver->caps, + if (virDomainLoadAllConfigs(uml_driver->caps, ¨_driver->domains, uml_driver->configDir, uml_driver->autostartDir, @@ -473,8 +472,7 @@ umlReload(void) { return 0; umlDriverLock(uml_driver); - virDomainLoadAllConfigs(NULL, - uml_driver->caps, + virDomainLoadAllConfigs(uml_driver->caps, ¨_driver->domains, uml_driver->configDir, uml_driver->autostartDir, @@ -1263,15 +1261,14 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml, virDomainPtr dom = NULL; umlDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) goto cleanup; - if (!(vm = virDomainAssignDef(conn, - driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) goto cleanup; @@ -1534,8 +1531,7 @@ static char *umlDomainDumpXML(virDomainPtr dom, goto cleanup; } - ret = virDomainDefFormat(dom->conn, - (flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? + ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? vm->newDef : vm->def, flags); @@ -1601,23 +1597,21 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) { virDomainPtr dom = NULL; umlDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml, + if (!(def = virDomainDefParseString(driver->caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (virDomainObjIsDuplicate(&driver->domains, def, 0) < 0) goto cleanup; - if (!(vm = virDomainAssignDef(conn, - driver->caps, + if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def))) goto cleanup; def = NULL; vm->persistent = 1; - if (virDomainSaveConfig(conn, - driver->configDir, + if (virDomainSaveConfig(driver->configDir, vm->newDef ? vm->newDef : vm->def) < 0) { virDomainRemoveInactive(&driver->domains, vm); @@ -1661,7 +1655,7 @@ static int umlDomainUndefine(virDomainPtr dom) { goto cleanup; } - if (virDomainDeleteConfig(dom->conn, driver->configDir, driver->autostartDir, vm) < 0) + if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0) goto cleanup; virDomainRemoveInactive(&driver->domains, @@ -1728,9 +1722,9 @@ static int umlDomainSetAutostart(virDomainPtr dom, autostart = (autostart != 0); if (vm->autostart != autostart) { - if ((configFile = virDomainConfigFile(dom->conn, driver->configDir, vm->def->name)) == NULL) + if ((configFile = virDomainConfigFile(driver->configDir, vm->def->name)) == NULL) goto cleanup; - if ((autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, vm->def->name)) == NULL) + if ((autostartLink = virDomainConfigFile(driver->autostartDir, vm->def->name)) == NULL) goto cleanup; if (autostart) { diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index c316566..c175e0d 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -3019,7 +3019,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { } if (gotAllABoutDef == 0) - ret = virDomainDefFormat(dom->conn, def, flags); + ret = virDomainDefFormat(def, flags); cleanup: vboxIIDFree(iid); @@ -3355,7 +3355,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { PRUnichar *machineNameUtf16 = NULL; nsresult rc; - if (!(def = virDomainDefParseString(conn, data->caps, xml, + if (!(def = virDomainDefParseString(data->caps, xml, VIR_DOMAIN_XML_INACTIVE))) { goto cleanup; } @@ -4658,7 +4658,7 @@ static int vboxDomainAttachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(dom->conn, data->caps, def, xml, + dev = virDomainDeviceDefParse(data->caps, def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) { virReportOOMError(); @@ -4867,7 +4867,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(dom->conn, data->caps, def, xml, + dev = virDomainDeviceDefParse(data->caps, def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) { virReportOOMError(); diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index cfef055..6f21c6a 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -169,7 +169,7 @@ xenDomainUsedCpus(virDomainPtr dom) } } } - res = virDomainCpuSetFormat(dom->conn, cpulist, priv->nbNodeCpus); + res = virDomainCpuSetFormat(cpulist, priv->nbNodeCpus); } done: @@ -1195,7 +1195,7 @@ xenUnifiedDomainXMLFromNative(virConnectPtr conn, if (!def) goto cleanup; - ret = virDomainDefFormat(conn, def, 0); + ret = virDomainDefFormat(def, 0); cleanup: virDomainDefFree(def); @@ -1224,8 +1224,7 @@ xenUnifiedDomainXMLToNative(virConnectPtr conn, goto cleanup; } - if (!(def = virDomainDefParseString(conn, - priv->caps, + if (!(def = virDomainDefParseString(priv->caps, xmlData, 0))) goto cleanup; diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index b724267..88923c8 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2410,7 +2410,7 @@ xenDaemonParseSxpr(virConnectPtr conn, goto error; } - if (virDomainCpuSetParse(conn, &cpus, + if (virDomainCpuSetParse(&cpus, 0, def->cpumask, def->cpumasklen) < 0) { virXendError(conn, VIR_ERR_INTERNAL_ERROR, @@ -2810,7 +2810,7 @@ sexpr_to_xend_topology(virConnectPtr conn, for (cpu = 0; cpu < numCpus; cpu++) cpuset[cpu] = 0; } else { - nb_cpus = virDomainCpuSetParse(conn, &cur, 'n', cpuset, numCpus); + nb_cpus = virDomainCpuSetParse(&cur, 'n', cpuset, numCpus); if (nb_cpus < 0) goto error; } @@ -3468,7 +3468,7 @@ xenDaemonDomainDumpXML(virDomainPtr domain, int flags, const char *cpus) cpus))) return(NULL); - xml = virDomainDefFormat(domain->conn, def, flags); + xml = virDomainDefFormat(def, flags); virDomainDefFree(def); @@ -4053,8 +4053,7 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc, priv = (xenUnifiedPrivatePtr) conn->privateData; - if (!(def = virDomainDefParseString(conn, - priv->caps, + if (!(def = virDomainDefParseString(priv->caps, xmlDesc, VIR_DOMAIN_XML_INACTIVE))) return (NULL); @@ -4167,8 +4166,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(domain->conn, - priv->caps, + if (!(dev = virDomainDeviceDefParse(priv->caps, def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -4304,8 +4302,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(domain->conn, - priv->caps, + if (!(dev = virDomainDeviceDefParse(priv->caps, def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -4652,7 +4649,7 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) { if (priv->xendConfigVersion < 3) return(NULL); - if (!(def = virDomainDefParseString(conn, priv->caps, xmlDesc, + if (!(def = virDomainDefParseString(priv->caps, xmlDesc, VIR_DOMAIN_XML_INACTIVE))) { virXendError(conn, VIR_ERR_XML_ERROR, "%s", _("failed to parse domain description")); @@ -5804,7 +5801,7 @@ xenDaemonFormatSxpr(virConnectPtr conn, virBufferVSprintf(&buf, "(vcpus %lu)", def->vcpus); if (def->cpumask) { - char *ranges = virDomainCpuSetFormat(conn, def->cpumask, def->cpumasklen); + char *ranges = virDomainCpuSetFormat(def->cpumask, def->cpumasklen); if (ranges == NULL) goto error; virBufferVSprintf(&buf, "(cpus '%s')", ranges); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 256dd23..8d48eda 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -784,7 +784,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) goto no_memory; - if (virDomainCpuSetParse(conn, &str, 0, + if (virDomainCpuSetParse(&str, 0, def->cpumask, def->cpumasklen) < 0) goto cleanup; } @@ -1504,7 +1504,7 @@ char *xenXMDomainDumpXML(virDomainPtr domain, int flags) { if (!(entry = virHashLookup(priv->configCache, filename))) goto cleanup; - ret = virDomainDefFormat(domain->conn, entry->def, flags); + ret = virDomainDefFormat(entry->def, flags); cleanup: xenUnifiedUnlock(priv); @@ -1758,8 +1758,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain, virReportOOMError(); goto cleanup; } - if (virDomainCpuSetParse(domain->conn, - (const char **)&mapstr, 0, + if (virDomainCpuSetParse((const char **)&mapstr, 0, cpuset, maxcpu) < 0) goto cleanup; @@ -2261,7 +2260,7 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn, goto no_memory; if ((def->cpumask != NULL) && - ((cpus = virDomainCpuSetFormat(conn, def->cpumask, + ((cpus = virDomainCpuSetFormat(def->cpumask, def->cpumasklen)) == NULL)) goto cleanup; @@ -2651,7 +2650,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) { return (NULL); } - if (!(def = virDomainDefParseString(conn, priv->caps, xml, + if (!(def = virDomainDefParseString(priv->caps, xml, VIR_DOMAIN_XML_INACTIVE))) { xenUnifiedUnlock(priv); return (NULL); @@ -2957,8 +2956,7 @@ xenXMDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, goto cleanup; def = entry->def; - if (!(dev = virDomainDeviceDefParse(domain->conn, - priv->caps, + if (!(dev = virDomainDeviceDefParse(priv->caps, entry->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -3050,8 +3048,7 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, goto cleanup; def = entry->def; - if (!(dev = virDomainDeviceDefParse(domain->conn, - priv->caps, + if (!(dev = virDomainDeviceDefParse(priv->caps, entry->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 694c552..50c4453 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -52,7 +52,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (!(vmdef = qemuParseCommandLineString(driver.caps, cmd))) goto fail; - if (!(actualxml = virDomainDefFormat(NULL, vmdef, 0))) + if (!(actualxml = virDomainDefFormat(vmdef, 0))) goto fail; if (blankProblemElements(expectxml) < 0 || diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f4908b8..8bdab49 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -40,7 +40,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0) goto fail; - if (!(vmdef = virDomainDefParseFile(NULL, driver.caps, xml, + if (!(vmdef = virDomainDefParseFile(driver.caps, xml, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5b706bb..e807d7b 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -32,11 +32,11 @@ static int testCompareXMLToXMLFiles(const char *xml) { if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0) goto fail; - if (!(vmdef = virDomainDefParseString(NULL, driver.caps, xmlData, + if (!(vmdef = virDomainDefParseString(driver.caps, xmlData, VIR_DOMAIN_XML_INACTIVE))) goto fail; - if (!(actual = virDomainDefFormat(NULL, vmdef, 0))) + if (!(actual = virDomainDefFormat(vmdef, 0))) goto fail; if (STRNEQ(xmlData, actual)) { diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 381af66..297c30e 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -51,7 +51,7 @@ static int testCompareFiles(const char *xml, const char *sexpr, if (!(def = xenDaemonParseSxprString(conn, sexprData, xendConfigVersion))) goto fail; - if (!(gotxml = virDomainDefFormat(NULL, def, 0))) + if (!(gotxml = virDomainDefFormat(def, 0))) goto fail; if (STRNEQ(xmlData, gotxml)) { diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 8ea0b12..3980993 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -42,7 +42,7 @@ testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion) goto failure; } - formatted = virDomainDefFormat(NULL, def, VIR_DOMAIN_XML_SECURE); + formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE); if (formatted == NULL) { goto failure; diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index a80f1e5..acb6d18 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -70,7 +70,7 @@ static int testCompareParseXML(const char *xmcfg, const char *xml, priv.caps = caps; conn->privateData = &priv; - if (!(def = virDomainDefParseString(NULL, caps, xmlPtr, + if (!(def = virDomainDefParseString(caps, xmlPtr, VIR_DOMAIN_XML_INACTIVE))) goto fail; @@ -130,7 +130,7 @@ static int testCompareFormatXML(const char *xmcfg, const char *xml, if (!(def = xenXMDomainConfigParse(conn, conf))) goto fail; - if (!(gotxml = virDomainDefFormat(conn, def, VIR_DOMAIN_XML_SECURE))) + if (!(gotxml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE))) goto fail; if (STRNEQ(xmlData, gotxml)) { diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index df9e607..0455dc4 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -35,7 +35,7 @@ static int testCompareFiles(const char *xml, const char *sexpr, if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0) goto fail; - if (!(def = virDomainDefParseString(NULL, caps, xmlData, + if (!(def = virDomainDefParseString(caps, xmlData, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 530dd2a..8e0acbd 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -83,7 +83,7 @@ testCompareFiles(const char *xml, const char *vmx, esxVI_APIVersion apiVersion) goto failure; } - def = virDomainDefParseString(NULL, caps, xmlData, VIR_DOMAIN_XML_INACTIVE); + def = virDomainDefParseString(caps, xmlData, VIR_DOMAIN_XML_INACTIVE); if (def == NULL) { goto failure; -- 1.6.6

On Tue, Feb 09, 2010 at 07:20:34PM +0000, Daniel P. Berrange wrote:
The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Remove use of virConnectPtr from all APIs in domain_conf.{h,c} and update all callers to match --- src/conf/domain_conf.c | 763 +++++++++++++++++++------------------------ src/conf/domain_conf.h | 54 +-- src/esx/esx_driver.c | 8 +- src/lxc/lxc_controller.c | 5 +- src/lxc/lxc_driver.c | 40 +-- src/opennebula/one_driver.c | 8 +- src/openvz/openvz_driver.c | 10 +- src/phyp/phyp_driver.c | 4 +- src/qemu/qemu_driver.c | 76 ++--- src/test/test_driver.c | 30 +- src/uml/uml_driver.c | 28 +- src/vbox/vbox_tmpl.c | 8 +- src/xen/xen_driver.c | 7 +- src/xen/xend_internal.c | 19 +- src/xen/xm_internal.c | 17 +- tests/qemuargv2xmltest.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 4 +- tests/sexpr2xmltest.c | 2 +- tests/vmx2xmltest.c | 2 +- tests/xmconfigtest.c | 4 +- tests/xml2sexprtest.c | 2 +- tests/xml2vmxtest.c | 2 +- 23 files changed, 485 insertions(+), 612 deletions(-)
ACk, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Remove use of virConnectPtr from all APIs in security_driver.{h,c} and update all callers to match --- src/qemu/qemu_driver.c | 90 ++++++++++++++++------------------ src/qemu/qemu_security_dac.c | 43 +++++++---------- src/qemu/qemu_security_stacked.c | 99 ++++++++++++++++---------------------- src/security/security_apparmor.c | 69 ++++++++++++-------------- src/security/security_driver.c | 17 +++---- src/security/security_driver.h | 54 +++++++------------- src/security/security_selinux.c | 73 +++++++++++---------------- 7 files changed, 189 insertions(+), 256 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7c5dfe4..4cc66be 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -118,8 +118,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, const char *migrateFrom, int stdin_fd); -static void qemudShutdownVMDaemon(virConnectPtr conn, - struct qemud_driver *driver, +static void qemudShutdownVMDaemon(struct qemud_driver *driver, virDomainObjPtr vm); static int qemudDomainGetMaxVcpus(virDomainPtr dom); @@ -681,7 +680,7 @@ qemuHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_DOMAIN_EVENT_STOPPED_FAILED : VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); - qemudShutdownVMDaemon(NULL, driver, vm); + qemudShutdownVMDaemon(driver, vm); if (!vm->persistent) virDomainRemoveInactive(&driver->domains, vm); else @@ -865,7 +864,7 @@ qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq if (driver->securityDriver && driver->securityDriver->domainReserveSecurityLabel && - driver->securityDriver->domainReserveSecurityLabel(NULL, obj) < 0) + driver->securityDriver->domainReserveSecurityLabel(obj) < 0) goto error; if (obj->def->id >= driver->nextvmid) @@ -878,7 +877,7 @@ error: /* We can't get the monitor back, so must kill the VM * to remove danger of it ending up running twice if * user tries to start it again later */ - qemudShutdownVMDaemon(NULL, driver, obj); + qemudShutdownVMDaemon(driver, obj); if (!obj->persistent) virDomainRemoveInactive(&driver->domains, obj); else @@ -2468,7 +2467,7 @@ static int qemudSecurityHook(void *data) { if (h->driver->securityDriver && h->driver->securityDriver->domainSetSecurityProcessLabel && - h->driver->securityDriver->domainSetSecurityProcessLabel(h->conn, h->driver->securityDriver, h->vm) < 0) + h->driver->securityDriver->domainSetSecurityProcessLabel(h->driver->securityDriver, h->vm) < 0) return -1; return 0; @@ -2536,12 +2535,12 @@ static int qemudStartVMDaemon(virConnectPtr conn, then generate a security label for isolation */ if (driver->securityDriver && driver->securityDriver->domainGenSecurityLabel && - driver->securityDriver->domainGenSecurityLabel(conn, vm) < 0) + driver->securityDriver->domainGenSecurityLabel(vm) < 0) return -1; if (driver->securityDriver && driver->securityDriver->domainSetSecurityAllLabel && - driver->securityDriver->domainSetSecurityAllLabel(conn, vm) < 0) + driver->securityDriver->domainSetSecurityAllLabel(vm) < 0) goto cleanup; /* Ensure no historical cgroup for this VM is lieing around bogus settings */ @@ -2767,10 +2766,10 @@ cleanup: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityAllLabel) - driver->securityDriver->domainRestoreSecurityAllLabel(conn, vm); + driver->securityDriver->domainRestoreSecurityAllLabel(vm); if (driver->securityDriver && driver->securityDriver->domainReleaseSecurityLabel) - driver->securityDriver->domainReleaseSecurityLabel(conn, vm); + driver->securityDriver->domainReleaseSecurityLabel(vm); qemuRemoveCgroup(driver, vm, 0); if ((vm->def->ngraphics == 1) && vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && @@ -2784,7 +2783,7 @@ cleanup: abort: /* We jump here if we failed to initialize the now running VM * killing it off and pretend we never started it */ - qemudShutdownVMDaemon(conn, driver, vm); + qemudShutdownVMDaemon(driver, vm); if (logfile != -1) close(logfile); @@ -2793,8 +2792,7 @@ abort: } -static void qemudShutdownVMDaemon(virConnectPtr conn, - struct qemud_driver *driver, +static void qemudShutdownVMDaemon(struct qemud_driver *driver, virDomainObjPtr vm) { int ret; int retries = 0; @@ -2851,10 +2849,10 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, /* Reset Security Labels */ if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityAllLabel) - driver->securityDriver->domainRestoreSecurityAllLabel(conn, vm); + driver->securityDriver->domainRestoreSecurityAllLabel(vm); if (driver->securityDriver && driver->securityDriver->domainReleaseSecurityLabel) - driver->securityDriver->domainReleaseSecurityLabel(conn, vm); + driver->securityDriver->domainReleaseSecurityLabel(vm); /* Clear out dynamically assigned labels */ if (vm->def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC) { @@ -3306,7 +3304,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (virSecurityDriverVerify(conn, def) < 0) + if (virSecurityDriverVerify(def) < 0) goto cleanup; if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) @@ -3535,7 +3533,7 @@ static int qemudDomainDestroy(virDomainPtr dom) { goto endjob; } - qemudShutdownVMDaemon(dom->conn, driver, vm); + qemudShutdownVMDaemon(driver, vm); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); @@ -3911,7 +3909,7 @@ static int qemudDomainSave(virDomainPtr dom, if (driver->securityDriver && driver->securityDriver->domainSetSavedStateLabel && - driver->securityDriver->domainSetSavedStateLabel(dom->conn, vm, path) == -1) + driver->securityDriver->domainSetSavedStateLabel(vm, path) == -1) goto endjob; if (header.compressed == QEMUD_SAVE_FORMAT_RAW) { @@ -3938,13 +3936,13 @@ static int qemudDomainSave(virDomainPtr dom, if (driver->securityDriver && driver->securityDriver->domainRestoreSavedStateLabel && - driver->securityDriver->domainRestoreSavedStateLabel(dom->conn, vm, path) == -1) + driver->securityDriver->domainRestoreSavedStateLabel(vm, path) == -1) goto endjob; ret = 0; /* Shut it down */ - qemudShutdownVMDaemon(dom->conn, driver, vm); + qemudShutdownVMDaemon(driver, vm); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SAVED); @@ -4025,7 +4023,7 @@ static int qemudDomainCoreDump(virDomainPtr dom, if (driver->securityDriver && driver->securityDriver->domainSetSavedStateLabel && - driver->securityDriver->domainSetSavedStateLabel(dom->conn, vm, path) == -1) + driver->securityDriver->domainSetSavedStateLabel(vm, path) == -1) goto endjob; /* Migrate will always stop the VM, so the resume condition is @@ -4052,12 +4050,12 @@ static int qemudDomainCoreDump(virDomainPtr dom, if (driver->securityDriver && driver->securityDriver->domainRestoreSavedStateLabel && - driver->securityDriver->domainRestoreSavedStateLabel(dom->conn, vm, path) == -1) + driver->securityDriver->domainRestoreSavedStateLabel(vm, path) == -1) goto endjob; endjob: if ((ret == 0) && (flags & VIR_DUMP_CRASH)) { - qemudShutdownVMDaemon(dom->conn, driver, vm); + qemudShutdownVMDaemon(driver, vm); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_CRASHED); @@ -4388,7 +4386,7 @@ static int qemudDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr sec */ if (virDomainObjIsActive(vm)) { if (driver->securityDriver && driver->securityDriver->domainGetSecurityProcessLabel) { - if (driver->securityDriver->domainGetSecurityProcessLabel(dom->conn, vm, seclabel) == -1) { + if (driver->securityDriver->domainGetSecurityProcessLabel(vm, seclabel) == -1) { qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to get security label")); goto cleanup; @@ -5000,7 +4998,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) { VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (virSecurityDriverVerify(conn, def) < 0) + if (virSecurityDriverVerify(def) < 0) goto cleanup; if ((dupVM = virDomainObjIsDuplicate(&driver->domains, def, 0)) < 0) @@ -5095,8 +5093,7 @@ cleanup: } -static int qemudDomainChangeEjectableMedia(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainChangeEjectableMedia(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk) { @@ -5137,7 +5134,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn, if (driver->securityDriver && driver->securityDriver->domainSetSecurityImageLabel && - driver->securityDriver->domainSetSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainSetSecurityImageLabel(vm, disk) < 0) return -1; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -5163,7 +5160,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn, if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(conn, vm, origdisk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(vm, origdisk) < 0) VIR_WARN("Unable to restore security label on ejected image %s", origdisk->src); VIR_FREE(origdisk->src); @@ -5178,7 +5175,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn, error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(conn, vm, disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(vm, disk) < 0) VIR_WARN("Unable to restore security label on new media %s", disk->src); return -1; } @@ -5205,7 +5202,7 @@ static int qemudDomainAttachPciDiskDevice(struct qemud_driver *driver, if (driver->securityDriver && driver->securityDriver->domainSetSecurityImageLabel && - driver->securityDriver->domainSetSecurityImageLabel(NULL, vm, disk) < 0) + driver->securityDriver->domainSetSecurityImageLabel(vm, disk) < 0) return -1; if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { @@ -5266,7 +5263,7 @@ error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(vm, disk) < 0) VIR_WARN("Unable to restore security label on %s", disk->src); return -1; @@ -5398,7 +5395,7 @@ static int qemudDomainAttachSCSIDisk(struct qemud_driver *driver, if (driver->securityDriver && driver->securityDriver->domainSetSecurityImageLabel && - driver->securityDriver->domainSetSecurityImageLabel(NULL, vm, disk) < 0) + driver->securityDriver->domainSetSecurityImageLabel(vm, disk) < 0) return -1; /* We should have an address already, so make sure */ @@ -5475,7 +5472,7 @@ error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(vm, disk) < 0) VIR_WARN("Unable to restore security label on %s", disk->src); return -1; @@ -5502,7 +5499,7 @@ static int qemudDomainAttachUsbMassstorageDevice(struct qemud_driver *driver, if (driver->securityDriver && driver->securityDriver->domainSetSecurityImageLabel && - driver->securityDriver->domainSetSecurityImageLabel(NULL, vm, disk) < 0) + driver->securityDriver->domainSetSecurityImageLabel(vm, disk) < 0) return -1; if (!disk->src) { @@ -5554,7 +5551,7 @@ error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(vm, disk) < 0) VIR_WARN("Unable to restore security label on %s", disk->src); return -1; @@ -5825,8 +5822,7 @@ error: } -static int qemudDomainAttachHostDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainAttachHostDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, int qemuCmdFlags) @@ -5840,7 +5836,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn, if (driver->securityDriver && driver->securityDriver->domainSetSecurityHostdevLabel && - driver->securityDriver->domainSetSecurityHostdevLabel(conn, vm, hostdev) < 0) + driver->securityDriver->domainSetSecurityHostdevLabel(vm, hostdev) < 0) return -1; switch (hostdev->source.subsys.type) { @@ -5868,7 +5864,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn, error: if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityHostdevLabel && - driver->securityDriver->domainRestoreSecurityHostdevLabel(conn, vm, hostdev) < 0) + driver->securityDriver->domainRestoreSecurityHostdevLabel(vm, hostdev) < 0) VIR_WARN0("Unable to restore host device labelling on hotplug fail"); return -1; @@ -5936,7 +5932,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom, switch (dev->data.disk->device) { case VIR_DOMAIN_DISK_DEVICE_CDROM: case VIR_DOMAIN_DISK_DEVICE_FLOPPY: - ret = qemudDomainChangeEjectableMedia(dom->conn, driver, vm, dev->data.disk); + ret = qemudDomainChangeEjectableMedia(driver, vm, dev->data.disk); if (ret == 0) dev->data.disk = NULL; break; @@ -5991,7 +5987,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom, if (ret == 0) dev->data.net = NULL; } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { - ret = qemudDomainAttachHostDevice(dom->conn, driver, vm, + ret = qemudDomainAttachHostDevice(driver, vm, dev->data.hostdev, qemuCmdFlags); if (ret == 0) dev->data.hostdev = NULL; @@ -6085,7 +6081,7 @@ static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver, if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityImageLabel && - driver->securityDriver->domainRestoreSecurityImageLabel(NULL, vm, dev->data.disk) < 0) + driver->securityDriver->domainRestoreSecurityImageLabel(vm, dev->data.disk) < 0) VIR_WARN("Unable to restore security label on %s", dev->data.disk->src); ret = 0; @@ -6357,7 +6353,7 @@ static int qemudDomainDetachHostDevice(struct qemud_driver *driver, if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityHostdevLabel && - driver->securityDriver->domainRestoreSecurityHostdevLabel(NULL, vm, dev->data.hostdev) < 0) + driver->securityDriver->domainRestoreSecurityHostdevLabel(vm, dev->data.hostdev) < 0) VIR_WARN0("Failed to restore host device labelling"); return ret; @@ -7506,7 +7502,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, qemust = qemuStreamMigOpen(st, unixfile); if (qemust == NULL) { - qemudShutdownVMDaemon(NULL, driver, vm); + qemudShutdownVMDaemon(driver, vm); if (!vm->persistent) { if (qemuDomainObjEndJob(vm) > 0) virDomainRemoveInactive(&driver->domains, vm); @@ -8193,7 +8189,7 @@ qemudDomainMigratePerform (virDomainPtr dom, } /* Clean up the source domain. */ - qemudShutdownVMDaemon (dom->conn, driver, vm); + qemudShutdownVMDaemon(driver, vm); paused = 0; event = virDomainEventNewFromObj(vm, @@ -8336,7 +8332,7 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn, } virDomainSaveStatus(driver->caps, driver->stateDir, vm); } else { - qemudShutdownVMDaemon (dconn, driver, vm); + qemudShutdownVMDaemon(driver, vm); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_FAILED); diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c index e753490..11f41b3 100644 --- a/src/qemu/qemu_security_dac.c +++ b/src/qemu/qemu_security_dac.c @@ -105,8 +105,7 @@ err: static int -qemuSecurityDACSetSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm ATTRIBUTE_UNUSED, +qemuSecurityDACSetSecurityImageLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED, virDomainDiskDefPtr disk) { @@ -149,8 +148,7 @@ qemuSecurityDACSetSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -qemuSecurityDACRestoreSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm ATTRIBUTE_UNUSED, +qemuSecurityDACRestoreSecurityImageLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED, virDomainDiskDefPtr disk) { if (!driver->privileged || !driver->dynamicOwnership) @@ -195,8 +193,7 @@ qemuSecurityDACSetSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityDACSetSecurityHostdevLabel(virDomainObjPtr vm, virDomainHostdevDefPtr dev) { @@ -218,7 +215,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn, if (!usb) goto done; - ret = usbDeviceFileIterate(conn, usb, qemuSecurityDACSetSecurityUSBLabel, vm); + ret = usbDeviceFileIterate(NULL, usb, qemuSecurityDACSetSecurityUSBLabel, vm); usbFreeDevice(usb); break; } @@ -232,7 +229,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn, if (!pci) goto done; - ret = pciDeviceFileIterate(conn, pci, qemuSecurityDACSetSecurityPCILabel, vm); + ret = pciDeviceFileIterate(NULL, pci, qemuSecurityDACSetSecurityPCILabel, vm); pciFreeDevice(pci); break; @@ -269,8 +266,7 @@ qemuSecurityDACRestoreSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn, - virDomainObjPtr vm ATTRIBUTE_UNUSED, +qemuSecurityDACRestoreSecurityHostdevLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED, virDomainHostdevDefPtr dev) { @@ -292,7 +288,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn, if (!usb) goto done; - ret = usbDeviceFileIterate(conn, usb, qemuSecurityDACRestoreSecurityUSBLabel, NULL); + ret = usbDeviceFileIterate(NULL, usb, qemuSecurityDACRestoreSecurityUSBLabel, NULL); usbFreeDevice(usb); break; @@ -307,7 +303,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn, if (!pci) goto done; - ret = pciDeviceFileIterate(conn, pci, qemuSecurityDACRestoreSecurityPCILabel, NULL); + ret = pciDeviceFileIterate(NULL, pci, qemuSecurityDACRestoreSecurityPCILabel, NULL); pciFreeDevice(pci); break; @@ -324,8 +320,7 @@ done: static int -qemuSecurityDACRestoreSecurityAllLabel(virConnectPtr conn, - virDomainObjPtr vm) +qemuSecurityDACRestoreSecurityAllLabel(virDomainObjPtr vm) { int i; int rc = 0; @@ -336,12 +331,12 @@ qemuSecurityDACRestoreSecurityAllLabel(virConnectPtr conn, VIR_DEBUG("Restoring security label on %s", vm->def->name); for (i = 0 ; i < vm->def->nhostdevs ; i++) { - if (qemuSecurityDACRestoreSecurityHostdevLabel(conn, vm, + if (qemuSecurityDACRestoreSecurityHostdevLabel(vm, vm->def->hostdevs[i]) < 0) rc = -1; } for (i = 0 ; i < vm->def->ndisks ; i++) { - if (qemuSecurityDACRestoreSecurityImageLabel(conn, vm, + if (qemuSecurityDACRestoreSecurityImageLabel(vm, vm->def->disks[i]) < 0) rc = -1; } @@ -350,8 +345,7 @@ qemuSecurityDACRestoreSecurityAllLabel(virConnectPtr conn, static int -qemuSecurityDACSetSecurityAllLabel(virConnectPtr conn, - virDomainObjPtr vm) +qemuSecurityDACSetSecurityAllLabel(virDomainObjPtr vm) { int i; @@ -362,11 +356,11 @@ qemuSecurityDACSetSecurityAllLabel(virConnectPtr conn, /* XXX fixme - we need to recursively label the entriy tree :-( */ if (vm->def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_DIR) continue; - if (qemuSecurityDACSetSecurityImageLabel(conn, vm, vm->def->disks[i]) < 0) + if (qemuSecurityDACSetSecurityImageLabel(vm, vm->def->disks[i]) < 0) return -1; } for (i = 0 ; i < vm->def->nhostdevs ; i++) { - if (qemuSecurityDACSetSecurityHostdevLabel(conn, vm, vm->def->hostdevs[i]) < 0) + if (qemuSecurityDACSetSecurityHostdevLabel(vm, vm->def->hostdevs[i]) < 0) return -1; } @@ -375,8 +369,7 @@ qemuSecurityDACSetSecurityAllLabel(virConnectPtr conn, static int -qemuSecurityDACSetSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm ATTRIBUTE_UNUSED, +qemuSecurityDACSetSavedStateLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED, const char *savefile) { if (!driver->privileged || !driver->dynamicOwnership) @@ -387,8 +380,7 @@ qemuSecurityDACSetSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -qemuSecurityDACRestoreSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm ATTRIBUTE_UNUSED, +qemuSecurityDACRestoreSavedStateLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED, const char *savefile) { if (!driver->privileged || !driver->dynamicOwnership) @@ -399,8 +391,7 @@ qemuSecurityDACRestoreSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -qemuSecurityDACSetProcessLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virSecurityDriverPtr drv ATTRIBUTE_UNUSED, +qemuSecurityDACSetProcessLabel(virSecurityDriverPtr drv ATTRIBUTE_UNUSED, virDomainObjPtr vm ATTRIBUTE_UNUSED) { DEBUG("Dropping privileges of VM to %d:%d", driver->user, driver->group); diff --git a/src/qemu/qemu_security_stacked.c b/src/qemu/qemu_security_stacked.c index deabe0a..c0258ce 100644 --- a/src/qemu/qemu_security_stacked.c +++ b/src/qemu/qemu_security_stacked.c @@ -38,19 +38,18 @@ void qemuSecurityStackedSetDriver(struct qemud_driver *newdriver) static int -qemuSecurityStackedVerify(virConnectPtr conn, - virDomainDefPtr def) +qemuSecurityStackedVerify(virDomainDefPtr def) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainSecurityVerify && - driver->securitySecondaryDriver->domainSecurityVerify(conn, def) < 0) + driver->securitySecondaryDriver->domainSecurityVerify(def) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainSecurityVerify && - driver->securityPrimaryDriver->domainSecurityVerify(conn, def) < 0) + driver->securityPrimaryDriver->domainSecurityVerify(def) < 0) rc = -1; return rc; @@ -58,19 +57,18 @@ qemuSecurityStackedVerify(virConnectPtr conn, static int -qemuSecurityStackedGenLabel(virConnectPtr conn, - virDomainObjPtr vm) +qemuSecurityStackedGenLabel(virDomainObjPtr vm) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainGenSecurityLabel && - driver->securitySecondaryDriver->domainGenSecurityLabel(conn, vm) < 0) + driver->securitySecondaryDriver->domainGenSecurityLabel(vm) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainGenSecurityLabel && - driver->securityPrimaryDriver->domainGenSecurityLabel(conn, vm) < 0) + driver->securityPrimaryDriver->domainGenSecurityLabel(vm) < 0) rc = -1; return rc; @@ -78,19 +76,18 @@ qemuSecurityStackedGenLabel(virConnectPtr conn, static int -qemuSecurityStackedReleaseLabel(virConnectPtr conn, - virDomainObjPtr vm) +qemuSecurityStackedReleaseLabel(virDomainObjPtr vm) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainReleaseSecurityLabel && - driver->securitySecondaryDriver->domainReleaseSecurityLabel(conn, vm) < 0) + driver->securitySecondaryDriver->domainReleaseSecurityLabel(vm) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainReleaseSecurityLabel && - driver->securityPrimaryDriver->domainReleaseSecurityLabel(conn, vm) < 0) + driver->securityPrimaryDriver->domainReleaseSecurityLabel(vm) < 0) rc = -1; return rc; @@ -98,19 +95,18 @@ qemuSecurityStackedReleaseLabel(virConnectPtr conn, static int -qemuSecurityStackedReserveLabel(virConnectPtr conn, - virDomainObjPtr vm) +qemuSecurityStackedReserveLabel(virDomainObjPtr vm) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainReserveSecurityLabel && - driver->securitySecondaryDriver->domainReserveSecurityLabel(conn, vm) < 0) + driver->securitySecondaryDriver->domainReserveSecurityLabel(vm) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainReserveSecurityLabel && - driver->securityPrimaryDriver->domainReserveSecurityLabel(conn, vm) < 0) + driver->securityPrimaryDriver->domainReserveSecurityLabel(vm) < 0) rc = -1; return rc; @@ -118,20 +114,19 @@ qemuSecurityStackedReserveLabel(virConnectPtr conn, static int -qemuSecurityStackedSetSecurityImageLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityStackedSetSecurityImageLabel(virDomainObjPtr vm, virDomainDiskDefPtr disk) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainSetSecurityImageLabel && - driver->securitySecondaryDriver->domainSetSecurityImageLabel(conn, vm, disk) < 0) + driver->securitySecondaryDriver->domainSetSecurityImageLabel(vm, disk) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainSetSecurityImageLabel && - driver->securityPrimaryDriver->domainSetSecurityImageLabel(conn, vm, disk) < 0) + driver->securityPrimaryDriver->domainSetSecurityImageLabel(vm, disk) < 0) rc = -1; return rc; @@ -139,20 +134,19 @@ qemuSecurityStackedSetSecurityImageLabel(virConnectPtr conn, static int -qemuSecurityStackedRestoreSecurityImageLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityStackedRestoreSecurityImageLabel(virDomainObjPtr vm, virDomainDiskDefPtr disk) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainRestoreSecurityImageLabel && - driver->securitySecondaryDriver->domainRestoreSecurityImageLabel(conn, vm, disk) < 0) + driver->securitySecondaryDriver->domainRestoreSecurityImageLabel(vm, disk) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainRestoreSecurityImageLabel && - driver->securityPrimaryDriver->domainRestoreSecurityImageLabel(conn, vm, disk) < 0) + driver->securityPrimaryDriver->domainRestoreSecurityImageLabel(vm, disk) < 0) rc = -1; return rc; @@ -160,8 +154,7 @@ qemuSecurityStackedRestoreSecurityImageLabel(virConnectPtr conn, static int -qemuSecurityStackedSetSecurityHostdevLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityStackedSetSecurityHostdevLabel(virDomainObjPtr vm, virDomainHostdevDefPtr dev) { @@ -169,12 +162,12 @@ qemuSecurityStackedSetSecurityHostdevLabel(virConnectPtr conn, if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainSetSecurityHostdevLabel && - driver->securitySecondaryDriver->domainSetSecurityHostdevLabel(conn, vm, dev) < 0) + driver->securitySecondaryDriver->domainSetSecurityHostdevLabel(vm, dev) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainSetSecurityHostdevLabel && - driver->securityPrimaryDriver->domainSetSecurityHostdevLabel(conn, vm, dev) < 0) + driver->securityPrimaryDriver->domainSetSecurityHostdevLabel(vm, dev) < 0) rc = -1; return rc; @@ -182,8 +175,7 @@ qemuSecurityStackedSetSecurityHostdevLabel(virConnectPtr conn, static int -qemuSecurityStackedRestoreSecurityHostdevLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityStackedRestoreSecurityHostdevLabel(virDomainObjPtr vm, virDomainHostdevDefPtr dev) { @@ -191,12 +183,12 @@ qemuSecurityStackedRestoreSecurityHostdevLabel(virConnectPtr conn, if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainRestoreSecurityHostdevLabel && - driver->securitySecondaryDriver->domainRestoreSecurityHostdevLabel(conn, vm, dev) < 0) + driver->securitySecondaryDriver->domainRestoreSecurityHostdevLabel(vm, dev) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainRestoreSecurityHostdevLabel && - driver->securityPrimaryDriver->domainRestoreSecurityHostdevLabel(conn, vm, dev) < 0) + driver->securityPrimaryDriver->domainRestoreSecurityHostdevLabel(vm, dev) < 0) rc = -1; return rc; @@ -204,19 +196,18 @@ qemuSecurityStackedRestoreSecurityHostdevLabel(virConnectPtr conn, static int -qemuSecurityStackedSetSecurityAllLabel(virConnectPtr conn, - virDomainObjPtr vm) +qemuSecurityStackedSetSecurityAllLabel(virDomainObjPtr vm) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainSetSecurityAllLabel && - driver->securitySecondaryDriver->domainSetSecurityAllLabel(conn, vm) < 0) + driver->securitySecondaryDriver->domainSetSecurityAllLabel(vm) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainSetSecurityAllLabel && - driver->securityPrimaryDriver->domainSetSecurityAllLabel(conn, vm) < 0) + driver->securityPrimaryDriver->domainSetSecurityAllLabel(vm) < 0) rc = -1; return rc; @@ -224,19 +215,18 @@ qemuSecurityStackedSetSecurityAllLabel(virConnectPtr conn, static int -qemuSecurityStackedRestoreSecurityAllLabel(virConnectPtr conn, - virDomainObjPtr vm) +qemuSecurityStackedRestoreSecurityAllLabel(virDomainObjPtr vm) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainRestoreSecurityAllLabel && - driver->securitySecondaryDriver->domainRestoreSecurityAllLabel(conn, vm) < 0) + driver->securitySecondaryDriver->domainRestoreSecurityAllLabel(vm) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainRestoreSecurityAllLabel && - driver->securityPrimaryDriver->domainRestoreSecurityAllLabel(conn, vm) < 0) + driver->securityPrimaryDriver->domainRestoreSecurityAllLabel(vm) < 0) rc = -1; return rc; @@ -244,20 +234,19 @@ qemuSecurityStackedRestoreSecurityAllLabel(virConnectPtr conn, static int -qemuSecurityStackedSetSavedStateLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityStackedSetSavedStateLabel(virDomainObjPtr vm, const char *savefile) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainSetSavedStateLabel && - driver->securitySecondaryDriver->domainSetSavedStateLabel(conn, vm, savefile) < 0) + driver->securitySecondaryDriver->domainSetSavedStateLabel(vm, savefile) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainSetSavedStateLabel && - driver->securityPrimaryDriver->domainSetSavedStateLabel(conn, vm, savefile) < 0) + driver->securityPrimaryDriver->domainSetSavedStateLabel(vm, savefile) < 0) rc = -1; return rc; @@ -265,20 +254,19 @@ qemuSecurityStackedSetSavedStateLabel(virConnectPtr conn, static int -qemuSecurityStackedRestoreSavedStateLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityStackedRestoreSavedStateLabel(virDomainObjPtr vm, const char *savefile) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainRestoreSavedStateLabel && - driver->securitySecondaryDriver->domainRestoreSavedStateLabel(conn, vm, savefile) < 0) + driver->securitySecondaryDriver->domainRestoreSavedStateLabel(vm, savefile) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainRestoreSavedStateLabel && - driver->securityPrimaryDriver->domainRestoreSavedStateLabel(conn, vm, savefile) < 0) + driver->securityPrimaryDriver->domainRestoreSavedStateLabel(vm, savefile) < 0) rc = -1; return rc; @@ -286,23 +274,20 @@ qemuSecurityStackedRestoreSavedStateLabel(virConnectPtr conn, static int -qemuSecurityStackedSetProcessLabel(virConnectPtr conn, - virSecurityDriverPtr drv ATTRIBUTE_UNUSED, +qemuSecurityStackedSetProcessLabel(virSecurityDriverPtr drv ATTRIBUTE_UNUSED, virDomainObjPtr vm) { int rc = 0; if (driver->securitySecondaryDriver && driver->securitySecondaryDriver->domainSetSecurityProcessLabel && - driver->securitySecondaryDriver->domainSetSecurityProcessLabel(conn, - driver->securitySecondaryDriver, + driver->securitySecondaryDriver->domainSetSecurityProcessLabel(driver->securitySecondaryDriver, vm) < 0) rc = -1; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainSetSecurityProcessLabel && - driver->securityPrimaryDriver->domainSetSecurityProcessLabel(conn, - driver->securityPrimaryDriver, + driver->securityPrimaryDriver->domainSetSecurityProcessLabel(driver->securityPrimaryDriver, vm) < 0) rc = -1; @@ -310,16 +295,14 @@ qemuSecurityStackedSetProcessLabel(virConnectPtr conn, } static int -qemuSecurityStackedGetProcessLabel(virConnectPtr conn, - virDomainObjPtr vm, +qemuSecurityStackedGetProcessLabel(virDomainObjPtr vm, virSecurityLabelPtr seclabel) { int rc = 0; if (driver->securityPrimaryDriver && driver->securityPrimaryDriver->domainGetSecurityProcessLabel && - driver->securityPrimaryDriver->domainGetSecurityProcessLabel(conn, - vm, + driver->securityPrimaryDriver->domainGetSecurityProcessLabel(vm, seclabel) < 0) rc = -1; diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index 2d5f944..23f40f8 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -148,7 +148,7 @@ profile_status_file(const char *str) * load (add) a profile. Will create one if necessary */ static int -load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, +load_profile(const char *profile, virDomainObjPtr vm, virDomainDiskDefPtr disk) { int rc = -1, status, ret; @@ -162,7 +162,7 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, return rc; } - xml = virDomainDefFormat(conn, vm->def, VIR_DOMAIN_XML_SECURE); + xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE); if (!xml) goto clean; @@ -204,7 +204,7 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, if (errno == EINTR) goto rewait; - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected exit status from virt-aa-helper " "%d pid %lu"), WEXITSTATUS(status), (unsigned long)child); @@ -311,9 +311,9 @@ AppArmorSecurityDriverProbe(void) * currently not used. */ static int -AppArmorSecurityDriverOpen(virConnectPtr conn, virSecurityDriverPtr drv) +AppArmorSecurityDriverOpen(virSecurityDriverPtr drv) { - virSecurityDriverSetDOI(conn, drv, SECURITY_APPARMOR_VOID_DOI); + virSecurityDriverSetDOI(drv, SECURITY_APPARMOR_VOID_DOI); return 0; } @@ -323,7 +323,7 @@ AppArmorSecurityDriverOpen(virConnectPtr conn, virSecurityDriverPtr drv) * called on shutdown. */ static int -AppArmorGenSecurityLabel(virConnectPtr conn, virDomainObjPtr vm) +AppArmorGenSecurityLabel(virDomainObjPtr vm) { int rc = -1; char *profile_name = NULL; @@ -333,7 +333,7 @@ AppArmorGenSecurityLabel(virConnectPtr conn, virDomainObjPtr vm) if ((vm->def->seclabel.label) || (vm->def->seclabel.model) || (vm->def->seclabel.imagelabel)) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("security label already defined for VM")); return rc; @@ -377,15 +377,15 @@ AppArmorGenSecurityLabel(virConnectPtr conn, virDomainObjPtr vm) } static int -AppArmorSetSecurityAllLabel(virConnectPtr conn, virDomainObjPtr vm) +AppArmorSetSecurityAllLabel(virDomainObjPtr vm) { if (vm->def->seclabel.type == VIR_DOMAIN_SECLABEL_STATIC) return 0; /* if the profile is not already loaded, then load one */ if (profile_loaded(vm->def->seclabel.label) < 0) { - if (load_profile(conn, vm->def->seclabel.label, vm, NULL) < 0) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + if (load_profile(vm->def->seclabel.label, vm, NULL) < 0) { + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("cannot generate AppArmor profile " "\'%s\'"), vm->def->seclabel.label); return -1; @@ -399,8 +399,7 @@ AppArmorSetSecurityAllLabel(virConnectPtr conn, virDomainObjPtr vm) * running. */ static int -AppArmorGetSecurityProcessLabel(virConnectPtr conn, - virDomainObjPtr vm, virSecurityLabelPtr sec) +AppArmorGetSecurityProcessLabel(virDomainObjPtr vm, virSecurityLabelPtr sec) { int rc = -1; char *profile_name = NULL; @@ -410,13 +409,13 @@ AppArmorGetSecurityProcessLabel(virConnectPtr conn, if (virStrcpy(sec->label, profile_name, VIR_SECURITY_LABEL_BUFLEN) == NULL) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("error copying profile name")); goto clean; } if ((sec->enforcing = profile_status(profile_name, 1)) < 0) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("error calling profile_status()")); goto clean; } @@ -432,7 +431,7 @@ AppArmorGetSecurityProcessLabel(virConnectPtr conn, * more details. Currently called via qemudShutdownVMDaemon. */ static int -AppArmorReleaseSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm) +AppArmorReleaseSecurityLabel(virDomainObjPtr vm) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; @@ -445,14 +444,14 @@ AppArmorReleaseSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPt static int -AppArmorRestoreSecurityAllLabel(virConnectPtr conn, virDomainObjPtr vm) +AppArmorRestoreSecurityAllLabel(virDomainObjPtr vm) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; int rc = 0; if (secdef->type == VIR_DOMAIN_SECLABEL_DYNAMIC) { if ((rc = remove_profile(secdef->label)) != 0) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("could not remove profile for \'%s\'"), secdef->label); } @@ -464,8 +463,7 @@ AppArmorRestoreSecurityAllLabel(virConnectPtr conn, virDomainObjPtr vm) * LOCAL_STATE_DIR/log/libvirt/qemu/<vm name>.log */ static int -AppArmorSetSecurityProcessLabel(virConnectPtr conn, - virSecurityDriverPtr drv, virDomainObjPtr vm) +AppArmorSetSecurityProcessLabel(virSecurityDriverPtr drv, virDomainObjPtr vm) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; int rc = -1; @@ -475,7 +473,7 @@ AppArmorSetSecurityProcessLabel(virConnectPtr conn, return rc; if (STRNEQ(drv->name, secdef->model)) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("security label driver mismatch: " "\'%s\' model configured for domain, but " "hypervisor driver is \'%s\'."), @@ -485,7 +483,7 @@ AppArmorSetSecurityProcessLabel(virConnectPtr conn, } if (aa_change_profile(profile_name) < 0) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("error calling aa_change_profile()")); goto clean; } @@ -500,8 +498,7 @@ AppArmorSetSecurityProcessLabel(virConnectPtr conn, /* Called when hotplugging */ static int -AppArmorRestoreSecurityImageLabel(virConnectPtr conn, - virDomainObjPtr vm, +AppArmorRestoreSecurityImageLabel(virDomainObjPtr vm, virDomainDiskDefPtr disk ATTRIBUTE_UNUSED) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; @@ -516,8 +513,8 @@ AppArmorRestoreSecurityImageLabel(virConnectPtr conn, /* Update the profile only if it is loaded */ if (profile_loaded(secdef->imagelabel) >= 0) { - if (load_profile(conn, secdef->imagelabel, vm, NULL) < 0) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + if (load_profile(secdef->imagelabel, vm, NULL) < 0) { + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("cannot update AppArmor profile " "\'%s\'"), secdef->imagelabel); @@ -534,8 +531,7 @@ AppArmorRestoreSecurityImageLabel(virConnectPtr conn, /* Called when hotplugging */ static int -AppArmorSetSecurityImageLabel(virConnectPtr conn, - virDomainObjPtr vm, virDomainDiskDefPtr disk) +AppArmorSetSecurityImageLabel(virDomainObjPtr vm, virDomainDiskDefPtr disk) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; int rc = -1; @@ -550,7 +546,7 @@ AppArmorSetSecurityImageLabel(virConnectPtr conn, if (secdef->imagelabel) { /* if the device doesn't exist, error out */ if (!virFileExists(disk->src)) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("\'%s\' does not exist"), disk->src); return rc; } @@ -560,8 +556,8 @@ AppArmorSetSecurityImageLabel(virConnectPtr conn, /* update the profile only if it is loaded */ if (profile_loaded(secdef->imagelabel) >= 0) { - if (load_profile(conn, secdef->imagelabel, vm, disk) < 0) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + if (load_profile(secdef->imagelabel, vm, disk) < 0) { + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("cannot update AppArmor profile " "\'%s\'"), secdef->imagelabel); @@ -578,13 +574,13 @@ AppArmorSetSecurityImageLabel(virConnectPtr conn, } static int -AppArmorSecurityVerify(virConnectPtr conn, virDomainDefPtr def) +AppArmorSecurityVerify(virDomainDefPtr def) { const virSecurityLabelDefPtr secdef = &def->seclabel; if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC) { if (use_apparmor() < 0 || profile_status(secdef->label, 0) < 0) { - virSecurityReportError(conn, VIR_ERR_XML_ERROR, + virSecurityReportError(VIR_ERR_XML_ERROR, _("Invalid security label \'%s\'"), secdef->label); return -1; @@ -594,16 +590,14 @@ AppArmorSecurityVerify(virConnectPtr conn, virDomainDefPtr def) } static int -AppArmorReserveSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm ATTRIBUTE_UNUSED) +AppArmorReserveSecurityLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED) { /* NOOP. Nothing to reserve with AppArmor */ return 0; } static int -AppArmorSetSecurityHostdevLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm, +AppArmorSetSecurityHostdevLabel(virDomainObjPtr vm, virDomainHostdevDefPtr dev ATTRIBUTE_UNUSED) { @@ -617,8 +611,7 @@ AppArmorSetSecurityHostdevLabel(virConnectPtr conn ATTRIBUTE_UNUSED, } static int -AppArmorRestoreSecurityHostdevLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm, +AppArmorRestoreSecurityHostdevLabel(virDomainObjPtr vm, virDomainHostdevDefPtr dev ATTRIBUTE_UNUSED) { diff --git a/src/security/security_driver.c b/src/security/security_driver.c index 4e6172d..27945a6 100644 --- a/src/security/security_driver.c +++ b/src/security/security_driver.c @@ -35,7 +35,7 @@ static virSecurityDriverPtr security_drivers[] = { }; int -virSecurityDriverVerify(virConnectPtr conn, virDomainDefPtr def) +virSecurityDriverVerify(virDomainDefPtr def) { unsigned int i; const virSecurityLabelDefPtr secdef = &def->seclabel; @@ -46,10 +46,10 @@ virSecurityDriverVerify(virConnectPtr conn, virDomainDefPtr def) for (i = 0; security_drivers[i] != NULL ; i++) { if (STREQ(security_drivers[i]->name, secdef->model)) { - return security_drivers[i]->domainSecurityVerify(conn, def); + return security_drivers[i]->domainSecurityVerify(def); } } - virSecurityReportError(conn, VIR_ERR_XML_ERROR, + virSecurityReportError(VIR_ERR_XML_ERROR, _("invalid security model '%s'"), secdef->model); return -1; } @@ -72,7 +72,7 @@ virSecurityDriverStartup(virSecurityDriverPtr *drv, switch (tmp->probe()) { case SECURITY_DRIVER_ENABLE: virSecurityDriverInit(tmp); - if (tmp->open(NULL, tmp) == -1) { + if (tmp->open(tmp) == -1) { return -1; } else { *drv = tmp; @@ -91,7 +91,7 @@ virSecurityDriverStartup(virSecurityDriverPtr *drv, } void -virSecurityReportError(virConnectPtr conn, int code, const char *fmt, ...) +virSecurityReportError(int code, const char *fmt, ...) { va_list args; char errorMessage[1024]; @@ -103,7 +103,7 @@ virSecurityReportError(virConnectPtr conn, int code, const char *fmt, ...) } else errorMessage[0] = '\0'; - virRaiseError(conn, NULL, NULL, VIR_FROM_SECURITY, code, + virRaiseError(NULL, NULL, NULL, VIR_FROM_SECURITY, code, VIR_ERR_ERROR, NULL, NULL, NULL, -1, -1, "%s", errorMessage); } @@ -118,12 +118,11 @@ virSecurityDriverInit(virSecurityDriverPtr drv) } int -virSecurityDriverSetDOI(virConnectPtr conn, - virSecurityDriverPtr drv, +virSecurityDriverSetDOI(virSecurityDriverPtr drv, const char *doi) { if (strlen(doi) >= VIR_SECURITY_DOI_BUFLEN) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("%s: DOI \'%s\' is " "longer than the maximum allowed length of %d"), __func__, doi, VIR_SECURITY_DOI_BUFLEN - 1); diff --git a/src/security/security_driver.h b/src/security/security_driver.h index 5d2446d..8860d81 100644 --- a/src/security/security_driver.h +++ b/src/security/security_driver.h @@ -29,44 +29,29 @@ typedef enum { typedef struct _virSecurityDriver virSecurityDriver; typedef virSecurityDriver *virSecurityDriverPtr; typedef virSecurityDriverStatus (*virSecurityDriverProbe) (void); -typedef int (*virSecurityDriverOpen) (virConnectPtr conn, - virSecurityDriverPtr drv); -typedef int (*virSecurityDomainRestoreImageLabel) (virConnectPtr conn, - virDomainObjPtr vm, +typedef int (*virSecurityDriverOpen) (virSecurityDriverPtr drv); +typedef int (*virSecurityDomainRestoreImageLabel) (virDomainObjPtr vm, virDomainDiskDefPtr disk); -typedef int (*virSecurityDomainSetImageLabel) (virConnectPtr conn, - virDomainObjPtr vm, +typedef int (*virSecurityDomainSetImageLabel) (virDomainObjPtr vm, virDomainDiskDefPtr disk); -typedef int (*virSecurityDomainRestoreHostdevLabel) (virConnectPtr conn, - virDomainObjPtr vm, +typedef int (*virSecurityDomainRestoreHostdevLabel) (virDomainObjPtr vm, virDomainHostdevDefPtr dev); -typedef int (*virSecurityDomainSetHostdevLabel) (virConnectPtr conn, - virDomainObjPtr vm, +typedef int (*virSecurityDomainSetHostdevLabel) (virDomainObjPtr vm, virDomainHostdevDefPtr dev); -typedef int (*virSecurityDomainSetSavedStateLabel) (virConnectPtr conn, - virDomainObjPtr vm, +typedef int (*virSecurityDomainSetSavedStateLabel) (virDomainObjPtr vm, const char *savefile); -typedef int (*virSecurityDomainRestoreSavedStateLabel) (virConnectPtr conn, - virDomainObjPtr vm, +typedef int (*virSecurityDomainRestoreSavedStateLabel) (virDomainObjPtr vm, const char *savefile); -typedef int (*virSecurityDomainGenLabel) (virConnectPtr conn, - virDomainObjPtr sec); -typedef int (*virSecurityDomainReserveLabel) (virConnectPtr conn, - virDomainObjPtr sec); -typedef int (*virSecurityDomainReleaseLabel) (virConnectPtr conn, - virDomainObjPtr sec); -typedef int (*virSecurityDomainSetAllLabel) (virConnectPtr conn, - virDomainObjPtr sec); -typedef int (*virSecurityDomainRestoreAllLabel) (virConnectPtr conn, - virDomainObjPtr vm); -typedef int (*virSecurityDomainGetProcessLabel) (virConnectPtr conn, - virDomainObjPtr vm, +typedef int (*virSecurityDomainGenLabel) (virDomainObjPtr sec); +typedef int (*virSecurityDomainReserveLabel) (virDomainObjPtr sec); +typedef int (*virSecurityDomainReleaseLabel) (virDomainObjPtr sec); +typedef int (*virSecurityDomainSetAllLabel) (virDomainObjPtr sec); +typedef int (*virSecurityDomainRestoreAllLabel) (virDomainObjPtr vm); +typedef int (*virSecurityDomainGetProcessLabel) (virDomainObjPtr vm, virSecurityLabelPtr sec); -typedef int (*virSecurityDomainSetProcessLabel) (virConnectPtr conn, - virSecurityDriverPtr drv, +typedef int (*virSecurityDomainSetProcessLabel) (virSecurityDriverPtr drv, virDomainObjPtr vm); -typedef int (*virSecurityDomainSecurityVerify) (virConnectPtr conn, - virDomainDefPtr def); +typedef int (*virSecurityDomainSecurityVerify) (virDomainDefPtr def); struct _virSecurityDriver { const char *name; @@ -101,16 +86,15 @@ int virSecurityDriverStartup(virSecurityDriverPtr *drv, const char *name); int -virSecurityDriverVerify(virConnectPtr conn, virDomainDefPtr def); +virSecurityDriverVerify(virDomainDefPtr def); void -virSecurityReportError(virConnectPtr conn, int code, const char *fmt, ...) - ATTRIBUTE_FMT_PRINTF(3, 4); +virSecurityReportError(int code, const char *fmt, ...) + ATTRIBUTE_FMT_PRINTF(2, 3); /* Helpers */ void virSecurityDriverInit(virSecurityDriverPtr drv); -int virSecurityDriverSetDOI(virConnectPtr conn, - virSecurityDriverPtr drv, +int virSecurityDriverSetDOI(virSecurityDriverPtr drv, const char *doi); const char *virSecurityDriverGetDOI(virSecurityDriverPtr drv); const char *virSecurityDriverGetModel(virSecurityDriverPtr drv); diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index a97d3de..7507549 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -156,8 +156,7 @@ SELinuxInitialize(void) } static int -SELinuxGenSecurityLabel(virConnectPtr conn, - virDomainObjPtr vm) +SELinuxGenSecurityLabel(virDomainObjPtr vm) { int rc = -1; char mcs[1024]; @@ -171,7 +170,7 @@ SELinuxGenSecurityLabel(virConnectPtr conn, if (vm->def->seclabel.label || vm->def->seclabel.model || vm->def->seclabel.imagelabel) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("security label already defined for VM")); return rc; } @@ -192,13 +191,13 @@ SELinuxGenSecurityLabel(virConnectPtr conn, vm->def->seclabel.label = SELinuxGenNewContext(default_domain_context, mcs); if (! vm->def->seclabel.label) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("cannot generate selinux context for %s"), mcs); goto err; } vm->def->seclabel.imagelabel = SELinuxGenNewContext(default_image_context, mcs); if (! vm->def->seclabel.imagelabel) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("cannot generate selinux context for %s"), mcs); goto err; } @@ -221,8 +220,7 @@ done: } static int -SELinuxReserveSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm) +SELinuxReserveSecurityLabel(virDomainObjPtr vm) { security_context_t pctx; context_t ctx = NULL; @@ -266,19 +264,18 @@ SELinuxSecurityDriverProbe(void) } static int -SELinuxSecurityDriverOpen(virConnectPtr conn, virSecurityDriverPtr drv) +SELinuxSecurityDriverOpen(virSecurityDriverPtr drv) { /* * Where will the DOI come from? SELinux configuration, or qemu * configuration? For the moment, we'll just set it to "0". */ - virSecurityDriverSetDOI(conn, drv, SECURITY_SELINUX_VOID_DOI); + virSecurityDriverSetDOI(drv, SECURITY_SELINUX_VOID_DOI); return SELinuxInitialize(); } static int -SELinuxGetSecurityProcessLabel(virConnectPtr conn, - virDomainObjPtr vm, +SELinuxGetSecurityProcessLabel(virDomainObjPtr vm, virSecurityLabelPtr sec) { security_context_t ctx; @@ -291,7 +288,7 @@ SELinuxGetSecurityProcessLabel(virConnectPtr conn, } if (strlen((char *) ctx) >= VIR_SECURITY_LABEL_BUFLEN) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("security label exceeds " "maximum length: %d"), VIR_SECURITY_LABEL_BUFLEN - 1); @@ -380,8 +377,7 @@ err: } static int -SELinuxRestoreSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm, +SELinuxRestoreSecurityImageLabel(virDomainObjPtr vm, virDomainDiskDefPtr disk) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; @@ -407,8 +403,7 @@ SELinuxRestoreSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, } static int -SELinuxSetSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm, +SELinuxSetSecurityImageLabel(virDomainObjPtr vm, virDomainDiskDefPtr disk) { @@ -482,8 +477,7 @@ SELinuxSetSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, } static int -SELinuxSetSecurityHostdevLabel(virConnectPtr conn, - virDomainObjPtr vm, +SELinuxSetSecurityHostdevLabel(virDomainObjPtr vm, virDomainHostdevDefPtr dev) { @@ -506,7 +500,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn, if (!usb) goto done; - ret = usbDeviceFileIterate(conn, usb, SELinuxSetSecurityUSBLabel, vm); + ret = usbDeviceFileIterate(NULL, usb, SELinuxSetSecurityUSBLabel, vm); usbFreeDevice(usb); break; } @@ -520,7 +514,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn, if (!pci) goto done; - ret = pciDeviceFileIterate(conn, pci, SELinuxSetSecurityPCILabel, vm); + ret = pciDeviceFileIterate(NULL, pci, SELinuxSetSecurityPCILabel, vm); pciFreeDevice(pci); break; @@ -555,8 +549,7 @@ SELinuxRestoreSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, } static int -SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn, - virDomainObjPtr vm, +SELinuxRestoreSecurityHostdevLabel(virDomainObjPtr vm, virDomainHostdevDefPtr dev) { @@ -579,7 +572,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn, if (!usb) goto done; - ret = usbDeviceFileIterate(conn, usb, SELinuxRestoreSecurityUSBLabel, NULL); + ret = usbDeviceFileIterate(NULL, usb, SELinuxRestoreSecurityUSBLabel, NULL); usbFreeDevice(usb); break; @@ -594,7 +587,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn, if (!pci) goto done; - ret = pciDeviceFileIterate(conn, pci, SELinuxRestoreSecurityPCILabel, NULL); + ret = pciDeviceFileIterate(NULL, pci, SELinuxRestoreSecurityPCILabel, NULL); pciFreeDevice(pci); break; @@ -610,8 +603,7 @@ done: } static int -SELinuxRestoreSecurityAllLabel(virConnectPtr conn, - virDomainObjPtr vm) +SELinuxRestoreSecurityAllLabel(virDomainObjPtr vm) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; int i; @@ -623,11 +615,11 @@ SELinuxRestoreSecurityAllLabel(virConnectPtr conn, return 0; for (i = 0 ; i < vm->def->nhostdevs ; i++) { - if (SELinuxRestoreSecurityHostdevLabel(conn, vm, vm->def->hostdevs[i]) < 0) + if (SELinuxRestoreSecurityHostdevLabel(vm, vm->def->hostdevs[i]) < 0) rc = -1; } for (i = 0 ; i < vm->def->ndisks ; i++) { - if (SELinuxRestoreSecurityImageLabel(conn, vm, + if (SELinuxRestoreSecurityImageLabel(vm, vm->def->disks[i]) < 0) rc = -1; } @@ -636,8 +628,7 @@ SELinuxRestoreSecurityAllLabel(virConnectPtr conn, } static int -SELinuxReleaseSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm) +SELinuxReleaseSecurityLabel(virDomainObjPtr vm) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; @@ -659,8 +650,7 @@ SELinuxReleaseSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -SELinuxSetSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm, +SELinuxSetSavedStateLabel(virDomainObjPtr vm, const char *savefile) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; @@ -673,8 +663,7 @@ SELinuxSetSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -SELinuxRestoreSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainObjPtr vm, +SELinuxRestoreSavedStateLabel(virDomainObjPtr vm, const char *savefile) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; @@ -687,12 +676,12 @@ SELinuxRestoreSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -SELinuxSecurityVerify(virConnectPtr conn, virDomainDefPtr def) +SELinuxSecurityVerify(virDomainDefPtr def) { const virSecurityLabelDefPtr secdef = &def->seclabel; if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC) { if (security_check_context(secdef->label) != 0) { - virSecurityReportError(conn, VIR_ERR_XML_ERROR, + virSecurityReportError(VIR_ERR_XML_ERROR, _("Invalid security label %s"), secdef->label); return -1; } @@ -701,8 +690,7 @@ SELinuxSecurityVerify(virConnectPtr conn, virDomainDefPtr def) } static int -SELinuxSetSecurityProcessLabel(virConnectPtr conn, - virSecurityDriverPtr drv, +SELinuxSetSecurityProcessLabel(virSecurityDriverPtr drv, virDomainObjPtr vm) { /* TODO: verify DOI */ @@ -712,7 +700,7 @@ SELinuxSetSecurityProcessLabel(virConnectPtr conn, return 0; if (!STREQ(drv->name, secdef->model)) { - virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, + virSecurityReportError(VIR_ERR_INTERNAL_ERROR, _("security label driver mismatch: " "'%s' model configured for domain, but " "hypervisor driver is '%s'."), @@ -733,8 +721,7 @@ SELinuxSetSecurityProcessLabel(virConnectPtr conn, } static int -SELinuxSetSecurityAllLabel(virConnectPtr conn, - virDomainObjPtr vm) +SELinuxSetSecurityAllLabel(virDomainObjPtr vm) { const virSecurityLabelDefPtr secdef = &vm->def->seclabel; int i; @@ -749,11 +736,11 @@ SELinuxSetSecurityAllLabel(virConnectPtr conn, vm->def->disks[i]->src, vm->def->disks[i]->dst); continue; } - if (SELinuxSetSecurityImageLabel(conn, vm, vm->def->disks[i]) < 0) + if (SELinuxSetSecurityImageLabel(vm, vm->def->disks[i]) < 0) return -1; } for (i = 0 ; i < vm->def->nhostdevs ; i++) { - if (SELinuxSetSecurityHostdevLabel(conn, vm, vm->def->hostdevs[i]) < 0) + if (SELinuxSetSecurityHostdevLabel(vm, vm->def->hostdevs[i]) < 0) return -1; } -- 1.6.6

On Tue, Feb 09, 2010 at 07:20:35PM +0000, Daniel P. Berrange wrote:
The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Remove use of virConnectPtr from all APIs in security_driver.{h,c} and update all callers to match --- src/qemu/qemu_driver.c | 90 ++++++++++++++++------------------ src/qemu/qemu_security_dac.c | 43 +++++++---------- src/qemu/qemu_security_stacked.c | 99 ++++++++++++++++---------------------- src/security/security_apparmor.c | 69 ++++++++++++-------------- src/security/security_driver.c | 17 +++---- src/security/security_driver.h | 54 +++++++------------- src/security/security_selinux.c | 73 +++++++++++---------------- 7 files changed, 189 insertions(+), 256 deletions(-)
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

2010/2/9 Daniel P. Berrange <berrange@redhat.com>:
Following on from Matthias' work
http://www.redhat.com/archives/libvir-list/2010-February/msg00198.html
This series kills the virConnectPtr from QEMU, and LXC drivers, the security driver support code and the domain XML handling code.
ACK to the complete set. Matthias

On Wed, Feb 10, 2010 at 11:03:11AM +0100, Matthias Bolte wrote:
2010/2/9 Daniel P. Berrange <berrange@redhat.com>:
Following on from Matthias' work
http://www.redhat.com/archives/libvir-list/2010-February/msg00198.html
This series kills the virConnectPtr from QEMU, and LXC drivers, the security driver support code and the domain XML handling code.
ACK to the complete set.
Let's push them quickly as they affect so many files and functions ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wed, Feb 10, 2010 at 11:42:53AM +0100, Daniel Veillard wrote:
On Wed, Feb 10, 2010 at 11:03:11AM +0100, Matthias Bolte wrote:
2010/2/9 Daniel P. Berrange <berrange@redhat.com>:
Following on from Matthias' work
http://www.redhat.com/archives/libvir-list/2010-February/msg00198.html
This series kills the virConnectPtr from QEMU, and LXC drivers, the security driver support code and the domain XML handling code.
ACK to the complete set.
Let's push them quickly as they affect so many files and functions !
These are all pushed now. FYI, I have a second series I'm about to post which removes virConnectPtr from all the remaining XML handling APIs. Then we'll be pretty much done with this in the shared code Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Matthias Bolte