[libvirt] [PATCH 0/9] Remove conn parameter from several functions

This set of patches removes the conn parameter from several internal functions where it was used of error reporting only. Since errors are reported to an error object in thread local storage the conn parameter is not necessary for this anymore. Matthias

--- HACKING | 10 +- daemon/libvirtd.c | 8 +- daemon/remote.c | 2 +- ...-Step-7-of-8-Implement-the-driver-methods.patch | 20 ++-- docs/hacking.html.in | 10 +- src/conf/cpu_conf.c | 8 +- src/conf/domain_conf.c | 82 +++++----- src/conf/domain_event.c | 12 +- src/conf/interface_conf.c | 26 ++-- src/conf/network_conf.c | 24 ++-- src/conf/node_device_conf.c | 18 +- src/conf/secret_conf.c | 6 +- src/conf/storage_conf.c | 38 +++--- src/conf/storage_encryption_conf.c | 8 +- src/cpu/cpu.c | 2 +- src/cpu/cpu_generic.c | 2 +- src/cpu/cpu_map.c | 2 +- src/cpu/cpu_x86.c | 18 +- src/datatypes.c | 36 +++--- src/esx/esx_driver.c | 36 +++--- src/esx/esx_util.c | 10 +- src/esx/esx_vi.c | 24 ++-- src/esx/esx_vi_methods.c | 38 +++--- src/esx/esx_vi_types.c | 10 +- src/esx/esx_vmx.c | 50 +++--- src/interface/netcf_driver.c | 2 +- src/libvirt.c | 6 +- src/lxc/lxc_conf.c | 2 +- src/lxc/lxc_container.c | 18 +- src/lxc/lxc_controller.c | 10 +- src/lxc/lxc_driver.c | 23 ++-- src/network/bridge_driver.c | 25 ++-- src/node_device/node_device_driver.c | 16 +- src/node_device/node_device_linux_sysfs.c | 14 +- src/node_device/node_device_udev.c | 34 ++-- src/opennebula/one_conf.c | 6 +- src/opennebula/one_conf.h | 2 +- src/opennebula/one_driver.c | 8 +- src/openvz/openvz_conf.c | 10 +- src/openvz/openvz_driver.c | 12 +- src/phyp/phyp_driver.c | 76 +++++----- src/qemu/qemu_conf.c | 136 ++++++++--------- src/qemu/qemu_driver.c | 114 +++++++------- src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor_json.c | 40 +++--- src/qemu/qemu_monitor_text.c | 80 +++++----- src/remote/remote_driver.c | 50 +++--- src/secret/secret_driver.c | 34 +++-- src/security/security_apparmor.c | 30 ++-- src/security/security_selinux.c | 2 +- src/storage/storage_backend.c | 22 ++-- src/storage/storage_backend_disk.c | 14 +- src/storage/storage_backend_fs.c | 24 ++-- src/storage/storage_backend_iscsi.c | 8 +- src/storage/storage_backend_logical.c | 24 ++-- src/storage/storage_backend_mpath.c | 12 +- src/storage/storage_backend_scsi.c | 24 ++-- src/storage/storage_driver.c | 16 +- src/test/test_driver.c | 90 ++++++------ src/uml/uml_conf.c | 16 +- src/uml/uml_driver.c | 30 ++-- src/util/conf.c | 26 ++-- src/util/hostusb.c | 4 +- src/util/json.c | 6 +- src/util/pci.c | 12 +- src/util/processinfo.c | 4 +- src/util/qparams.c | 16 +- src/util/storage_file.c | 14 +- src/util/util.c | 20 ++-- src/util/virterror.c | 6 +- src/util/virterror_internal.h | 8 +- src/util/xml.c | 4 +- src/vbox/vbox_tmpl.c | 161 ++++++++++---------- src/xen/block_stats.c | 2 +- src/xen/proxy_internal.c | 6 +- src/xen/sexpr.c | 6 +- src/xen/xen_driver.c | 20 ++-- src/xen/xen_hypervisor.c | 22 ++-- src/xen/xen_inotify.c | 8 +- src/xen/xend_internal.c | 69 ++++----- src/xen/xm_internal.c | 51 +++--- src/xen/xs_internal.c | 18 +- 82 files changed, 1001 insertions(+), 1014 deletions(-) diff --git a/HACKING b/HACKING index 4bf216c..be8725d 100644 --- a/HACKING +++ b/HACKING @@ -171,7 +171,7 @@ routines, use the macros from memory.h virDomainPtr domain; if (VIR_ALLOC(domain) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -182,7 +182,7 @@ routines, use the macros from memory.h int ndomains = 10; if (VIR_ALLOC_N(domains, ndomains) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -192,7 +192,7 @@ routines, use the macros from memory.h int ndomains = 10; if (VIR_ALLOC_N(domains, ndomains) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -201,7 +201,7 @@ routines, use the macros from memory.h ndomains = 20 if (VIR_REALLOC_N(domains, ndomains) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -297,7 +297,7 @@ eg typical usage is as follows: if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(NULL); + virReportOOMError(); return NULL; } diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index d858ccf..1c7e791 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -747,7 +747,7 @@ static int qemudInitPaths(struct qemud_server *server, if (server->privileged) { dir_prefix = strdup (LOCAL_STATE_DIR); if (dir_prefix == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (snprintf (sock_dir, maxlen, "%s/run/libvirt", @@ -768,7 +768,7 @@ static int qemudInitPaths(struct qemud_server *server, sock_dir_prefix = strdup (sock_dir); if (!sock_dir_prefix) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -788,10 +788,10 @@ static int qemudInitPaths(struct qemud_server *server, if (server->privileged) { if (!(server->logDir = strdup (LOCAL_STATE_DIR "/log/libvirt"))) - virReportOOMError(NULL); + virReportOOMError(); } else { if (virAsprintf(&server->logDir, "%s/.libvirt/log", dir_prefix) < 0) - virReportOOMError(NULL); + virReportOOMError(); } if (server->logDir == NULL) diff --git a/daemon/remote.c b/daemon/remote.c index 299f971..09a51b7 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -2824,7 +2824,7 @@ static char *addrToString(remote_error *rerr, } if (virAsprintf(&addr, "%s;%s", host, port) == -1) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } diff --git a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch index 38f57a6..f820b2c 100644 --- a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch +++ b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch @@ -141,7 +141,7 @@ index b84729f..4f73baf 100644 + parent_host, + operation_file) < 0) { + -+ virReportOOMError(conn); ++ virReportOOMError(); + retval = -1; + goto cleanup; + } @@ -163,7 +163,7 @@ index b84729f..4f73baf 100644 + wwpn, + wwnn) < 0) { + -+ virReportOOMError(conn); ++ virReportOOMError(); + retval = -1; + goto cleanup; + } @@ -223,7 +223,7 @@ index b84729f..4f73baf 100644 + VIR_FREE(wwnn); + VIR_FREE(wwpn); + ret = -1; -+ virReportOOMError(conn); ++ virReportOOMError(); + } + + return ret; @@ -431,7 +431,7 @@ index b84729f..4f73baf 100644 + obj = NULL; + + if (parent_name == NULL) { -+ virReportOOMError(dev->conn); ++ virReportOOMError(); + goto out; + } + @@ -964,7 +964,7 @@ index 0000000..1deb6d2 + if (virAsprintf(&sysfs_path, "%s/host%d", + LINUX_SYSFS_FC_HOST_PREFIX, + d->scsi_host.host) < 0) { -+ virReportOOMError(NULL); ++ virReportOOMError(); + goto out; + } + @@ -977,7 +977,7 @@ index 0000000..1deb6d2 + + if (virAsprintf(&wwnn_path, "%s/node_name", + sysfs_path) < 0) { -+ virReportOOMError(NULL); ++ virReportOOMError(); + goto out; + } + @@ -1002,7 +1002,7 @@ index 0000000..1deb6d2 + + d->scsi_host.wwnn = strndup(p, sizeof(buf)); + if (d->scsi_host.wwnn == NULL) { -+ virReportOOMError(NULL); ++ virReportOOMError(); + goto out; + } + @@ -1013,7 +1013,7 @@ index 0000000..1deb6d2 + + if (virAsprintf(&wwpn_path, "%s/port_name", + sysfs_path) < 0) { -+ virReportOOMError(NULL); ++ virReportOOMError(); + goto out; + } + @@ -1038,7 +1038,7 @@ index 0000000..1deb6d2 + + d->scsi_host.wwpn = strndup(p, sizeof(buf)); + if (d->scsi_host.wwpn == NULL) { -+ virReportOOMError(NULL); ++ virReportOOMError(); + goto out; + } + @@ -1066,7 +1066,7 @@ index 0000000..1deb6d2 + if (virAsprintf(&sysfs_path, "%s/host%d/vport_create", + LINUX_SYSFS_FC_HOST_PREFIX, + d->scsi_host.host) < 0) { -+ virReportOOMError(NULL); ++ virReportOOMError(); + goto out; + } + diff --git a/docs/hacking.html.in b/docs/hacking.html.in index 71b4f47..788a49b 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -192,7 +192,7 @@ virDomainPtr domain; if (VIR_ALLOC(domain) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } </pre></li> @@ -204,7 +204,7 @@ int ndomains = 10; if (VIR_ALLOC_N(domains, ndomains) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } </pre></li> @@ -216,7 +216,7 @@ int ndomains = 10; if (VIR_ALLOC_N(domains, ndomains) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } </pre></li> @@ -227,7 +227,7 @@ ndomains = 20 if (VIR_REALLOC_N(domains, ndomains) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } </pre></li> @@ -314,7 +314,7 @@ if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(NULL); + virReportOOMError(); return NULL; } diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 244d670..002fde3 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -80,7 +80,7 @@ virCPUDefParseXML(virConnectPtr conn, unsigned int i; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -232,7 +232,7 @@ cleanup: return def; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virCPUDefFree(def); @@ -259,7 +259,7 @@ virCPUDefFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: virBufferFreeAndReset(&buf); return NULL; @@ -381,6 +381,6 @@ virCPUDefAddFeature(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); return -1; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 766993c..ee5be58 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -232,7 +232,7 @@ int virDomainObjListInit(virDomainObjListPtr doms) { doms->objs = virHashCreate(50); if (!doms->objs) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } return 0; @@ -692,13 +692,13 @@ static virDomainObjPtr virDomainObjNew(virConnectPtr conn, virDomainObjPtr domain; if (VIR_ALLOC(domain) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } if (caps->privateDataAllocFunc && !(domain->privateData = (caps->privateDataAllocFunc)())) { - virReportOOMError(conn); + virReportOOMError(); VIR_FREE(domain); return NULL; } @@ -749,7 +749,7 @@ virDomainObjPtr virDomainAssignDef(virConnectPtr conn, virUUIDFormat(def->uuid, uuidstr); if (virHashAddEntry(doms->objs, uuidstr, domain) < 0) { VIR_FREE(domain); - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1233,7 +1233,7 @@ virDomainDiskDefParseXML(virConnectPtr conn, char *serial = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1476,7 +1476,7 @@ virDomainControllerDefParseXML(virConnectPtr conn, char *idx = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1534,7 +1534,7 @@ virDomainFSDefParseXML(virConnectPtr conn, char *target = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1633,7 +1633,7 @@ virDomainNetDefParseXML(virConnectPtr conn, char *devaddr = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1930,7 +1930,7 @@ virDomainChrDefParseXML(virConnectPtr conn, virDomainChrDefPtr def; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2049,7 +2049,7 @@ virDomainChrDefParseXML(virConnectPtr conn, goto error; } if (VIR_ALLOC(def->target.addr) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } if (virSocketParseAddr(addrStr, def->target.addr, 0) < 0) @@ -2242,7 +2242,7 @@ virDomainInputDefParseXML(virConnectPtr conn, char *bus = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2330,7 +2330,7 @@ virDomainGraphicsDefParseXML(virConnectPtr conn, char *type = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2487,7 +2487,7 @@ virDomainSoundDefParseXML(virConnectPtr conn, virDomainSoundDefPtr def; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2524,7 +2524,7 @@ virDomainWatchdogDefParseXML(virConnectPtr conn, virDomainWatchdogDefPtr def; if (VIR_ALLOC (def) < 0) { - virReportOOMError (conn); + virReportOOMError(); return NULL; } @@ -2624,7 +2624,7 @@ virDomainVideoDefaultType(virDomainDefPtr def) } static virDomainVideoAccelDefPtr -virDomainVideoAccelDefParseXML(virConnectPtr conn, const xmlNodePtr node) { +virDomainVideoAccelDefParseXML(const xmlNodePtr node) { xmlNodePtr cur; virDomainVideoAccelDefPtr def; char *support3d = NULL; @@ -2646,7 +2646,7 @@ virDomainVideoAccelDefParseXML(virConnectPtr conn, const xmlNodePtr node) { return(NULL); if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2681,7 +2681,7 @@ virDomainVideoDefParseXML(virConnectPtr conn, char *vram = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2693,7 +2693,7 @@ virDomainVideoDefParseXML(virConnectPtr conn, type = virXMLPropString(cur, "type"); vram = virXMLPropString(cur, "vram"); heads = virXMLPropString(cur, "heads"); - def->accel = virDomainVideoAccelDefParseXML(conn, cur); + def->accel = virDomainVideoAccelDefParseXML(cur); } } cur = cur->next; @@ -2933,7 +2933,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn, char *mode, *type = NULL, *managed = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } def->target = NULL; @@ -3141,7 +3141,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, } if (VIR_ALLOC(dev) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -3336,7 +3336,7 @@ static char *virDomainDefDefaultEmulator(virConnectPtr conn, retemu = strdup(emulator); if (!retemu) - virReportOOMError(conn); + virReportOOMError(); return retemu; } @@ -3352,7 +3352,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, virDomainDefPtr def; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -3423,7 +3423,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, char *set = tmp; def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN; if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } if (virDomainCpuSetParse(conn, (const char **)&set, @@ -3476,7 +3476,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (def->os.bootloader) { def->os.type = strdup("xen"); if (!def->os.type) { - virReportOOMError(conn); + virReportOOMError(); goto error; } } else { @@ -3494,7 +3494,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, def->virtType == VIR_DOMAIN_VIRT_XEN) { VIR_FREE(def->os.type); if (!(def->os.type = strdup("xen"))) { - virReportOOMError(conn); + virReportOOMError(); goto error; } } @@ -3522,7 +3522,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; } if (!(def->os.arch = strdup(defaultArch))) { - virReportOOMError(conn); + virReportOOMError(); goto error; } } @@ -3535,7 +3535,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, virDomainVirtTypeToString(def->virtType)); if (defaultMachine != NULL) { if (!(def->os.machine = strdup(defaultMachine))) { - virReportOOMError(conn); + virReportOOMError(); goto error; } } @@ -3836,7 +3836,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } if (STREQ(def->os.type, "hvm")) { @@ -3974,7 +3974,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, return def; no_memory: - virReportOOMError(conn); + virReportOOMError(); /* fallthrough */ error: @@ -4165,7 +4165,7 @@ virDomainDefPtr virDomainDefParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4236,7 +4236,7 @@ virDomainObjPtr virDomainObjParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4266,7 +4266,7 @@ static int virDomainDefMaybeAddDiskController(virDomainDefPtr def, return 0; if (VIR_ALLOC(cont) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -4275,7 +4275,7 @@ static int virDomainDefMaybeAddDiskController(virDomainDefPtr def, if (VIR_REALLOC_N(def->controllers, def->ncontrollers+1) < 0) { VIR_FREE(cont); - virReportOOMError(NULL); + virReportOOMError(); return -1; } def->controllers[def->ncontrollers] = cont; @@ -4386,7 +4386,7 @@ virDomainCpuNumberParse(const char **str, int maxcpu) * freed by the caller. */ char * -virDomainCpuSetFormat(virConnectPtr conn, char *cpuset, int maxcpu) +virDomainCpuSetFormat(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, char *cpuset, int maxcpu) { virBuffer buf = VIR_BUFFER_INITIALIZER; int start, cur; @@ -4425,7 +4425,7 @@ virDomainCpuSetFormat(virConnectPtr conn, char *cpuset, int maxcpu) if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -5538,7 +5538,7 @@ char *virDomainDefFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: virBufferFreeAndReset(&buf); return NULL; @@ -5575,7 +5575,7 @@ char *virDomainObjFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virBufferFreeAndReset(&buf); return NULL; @@ -5758,7 +5758,7 @@ static virDomainObjPtr virDomainLoadStatus(virConnectPtr conn, } if (virHashAddEntry(doms->objs, uuidstr, obj) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -5871,14 +5871,14 @@ cleanup: return ret; } -char *virDomainConfigFile(virConnectPtr conn, +char *virDomainConfigFile(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, const char *dir, const char *name) { char *ret = NULL; if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -6102,7 +6102,7 @@ int virDomainObjListGetInactiveNames(virDomainObjListPtr doms, int i; virHashForEach(doms->objs, virDomainObjListCopyInactiveNames, &data); if (data.oom) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index 72f499c..b474b1c 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -219,7 +219,7 @@ virDomainEventCallbackListAdd(virConnectPtr conn, } /* Allocate new event */ if (VIR_ALLOC(event) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } event->conn = conn; @@ -230,7 +230,7 @@ virDomainEventCallbackListAdd(virConnectPtr conn, /* Make space on list */ n = cbList->count; if (VIR_REALLOC_N(cbList->callbacks, n + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); VIR_FREE(event); return -1; } @@ -257,7 +257,7 @@ virDomainEventQueuePtr virDomainEventQueueNew(void) virDomainEventQueuePtr ret; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -271,14 +271,14 @@ virDomainEventPtr virDomainEventNew(int id, const char *name, virDomainEventPtr event; if (VIR_ALLOC(event) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } event->type = type; event->detail = detail; if (!(event->name = strdup(name))) { - virReportOOMError(NULL); + virReportOOMError(); VIR_FREE(event); return NULL; } @@ -379,7 +379,7 @@ virDomainEventQueuePush(virDomainEventQueuePtr evtQueue, /* Make space on queue */ if (VIR_REALLOC_N(evtQueue->events, evtQueue->count + 1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 510df81..b4d6243 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -326,7 +326,7 @@ virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def return 0; if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -336,7 +336,7 @@ virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def virInterfaceIpDefPtr ip; if (VIR_ALLOC(ip) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -385,7 +385,7 @@ virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def return 0; if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -395,7 +395,7 @@ virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def virInterfaceIpDefPtr ip; if (VIR_ALLOC(ip) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -432,7 +432,7 @@ virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def, } if (VIR_ALLOC_N(def->protos, nProtoNodes) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -442,7 +442,7 @@ virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def, virInterfaceProtocolDefPtr proto; if (VIR_ALLOC(proto) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -504,7 +504,7 @@ virInterfaceDefParseBridge(virConnectPtr conn, virInterfaceDefPtr def, } if (nbItf > 0) { if (VIR_ALLOC_N(def->data.bridge.itf, nbItf) < 0) { - virReportOOMError(conn); + virReportOOMError(); ret = -1; goto error; } @@ -545,7 +545,7 @@ virInterfaceDefParseBondItfs(virConnectPtr conn, virInterfaceDefPtr def, goto error; } if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) { - virReportOOMError(conn); + virReportOOMError(); ret = -1; goto error; } @@ -695,7 +695,7 @@ virInterfaceDefParseXML(virConnectPtr conn, VIR_FREE(tmp); if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -844,7 +844,7 @@ virInterfaceDefPtr virInterfaceDefParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -1212,7 +1212,7 @@ virInterfaceDefDevFormat(virConnectPtr conn, virBufferPtr buf, goto no_memory; return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: return -1; } @@ -1319,7 +1319,7 @@ virInterfaceObjPtr virInterfaceAssignDef(virConnectPtr conn, } if (VIR_ALLOC(iface) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } if (virMutexInit(&iface->lock) < 0) { @@ -1332,7 +1332,7 @@ virInterfaceObjPtr virInterfaceAssignDef(virConnectPtr conn, iface->def = def; if (VIR_REALLOC_N(interfaces->objs, interfaces->count + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); VIR_FREE(iface); return NULL; } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index a64adf9..dd42232 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -167,7 +167,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn, } if (VIR_ALLOC(network) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } if (virMutexInit(&network->lock) < 0) { @@ -180,7 +180,7 @@ virNetworkObjPtr virNetworkAssignDef(virConnectPtr conn, network->def = def; if (VIR_REALLOC_N(nets->objs, nets->count + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); VIR_FREE(network); return NULL; } @@ -278,7 +278,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn, if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0) { xmlFree(start); xmlFree(end); - virReportOOMError(conn); + virReportOOMError(); return -1; } def->ranges[def->nranges].start = (char *)start; @@ -330,7 +330,7 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn, VIR_FREE(ip); VIR_FREE(mac); VIR_FREE(name); - virReportOOMError(conn); + virReportOOMError(); return -1; } def->hosts[def->nhosts].mac = (char *)mac; @@ -396,7 +396,7 @@ virNetworkDefParseXML(virConnectPtr conn, char *tmp; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -463,7 +463,7 @@ virNetworkDefParseXML(virConnectPtr conn, netaddr = inet_ntoa(inaddress); if (virAsprintf(&def->network, "%s/%s", netaddr, def->netmask) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -625,7 +625,7 @@ virNetworkDefPtr virNetworkDefParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -637,7 +637,7 @@ cleanup: return def; } -char *virNetworkDefFormat(virConnectPtr conn, +char *virNetworkDefFormat(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, const virNetworkDefPtr def) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -729,7 +729,7 @@ char *virNetworkDefFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); virBufferFreeAndReset(&buf); return NULL; } @@ -937,14 +937,14 @@ error: return ret; } -char *virNetworkConfigFile(virConnectPtr conn, +char *virNetworkConfigFile(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, const char *dir, const char *name) { char *ret = NULL; if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -988,7 +988,7 @@ char *virNetworkAllocateBridge(virConnectPtr conn, if (!virNetworkBridgeInUse(nets, try, NULL)) { if (!(newname = strdup(try))) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } return newname; diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4e8a492..2924ff0 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -187,7 +187,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn, } if (VIR_ALLOC(device) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -204,7 +204,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn, device->def = NULL; virNodeDeviceObjUnlock(device); virNodeDeviceObjFree(device); - virReportOOMError(conn); + virReportOOMError(); return NULL; } devs->objs[devs->count++] = device; @@ -241,7 +241,7 @@ void virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs, } } -char *virNodeDeviceDefFormat(virConnectPtr conn, +char *virNodeDeviceDefFormat(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, const virNodeDeviceDefPtr def) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -492,7 +492,7 @@ char *virNodeDeviceDefFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); virBufferFreeAndReset(&buf); return NULL; } @@ -1083,7 +1083,7 @@ virNodeDevCapsDefParseXML(virConnectPtr conn, int val, ret; if (VIR_ALLOC(caps) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1157,7 +1157,7 @@ virNodeDeviceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt, int create int n, i; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1173,7 +1173,7 @@ virNodeDeviceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt, int create def->name = strdup("new device"); if (!def->name) { - virReportOOMError(conn); + virReportOOMError(); goto error; } } @@ -1226,7 +1226,7 @@ virNodeDeviceDefParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -1360,7 +1360,7 @@ virNodeDeviceGetWWNs(virConnectPtr conn, VIR_FREE(wwnn); VIR_FREE(wwpn); ret = -1; - virReportOOMError(conn); + virReportOOMError(); } return ret; diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 538fa91..4b0068e 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -120,13 +120,13 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } ctxt->node = root; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -325,7 +325,7 @@ virSecretDefFormat(virConnectPtr conn, const virSecretDefPtr def) return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virBufferFreeAndReset(&buf); return NULL; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 62b8394..3e250de 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -431,7 +431,7 @@ virStoragePoolDefParseSource(virConnectPtr conn, if (nsource > 0) { if (VIR_ALLOC_N(source->devices, nsource) < 0) { VIR_FREE(nodeset); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -501,12 +501,12 @@ virStoragePoolDefParseSourceString(virConnectPtr conn, xpath_ctxt = xmlXPathNewContext(doc); if (xpath_ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -612,7 +612,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, char *uuid = NULL; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -684,7 +684,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, /* source name defaults to pool name */ ret->source.name = strdup(ret->name); if (ret->source.name == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -753,7 +753,7 @@ virStoragePoolDefParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -957,7 +957,7 @@ virStoragePoolDefFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: virBufferFreeAndReset(&buf); return NULL; @@ -1046,7 +1046,7 @@ virStorageVolDefParseXML(virConnectPtr conn, return NULL; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1161,7 +1161,7 @@ virStorageVolDefParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -1353,7 +1353,7 @@ virStorageVolDefFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: virBufferFreeAndReset(&buf); return NULL; @@ -1456,7 +1456,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn, } if (VIR_ALLOC(pool) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1474,7 +1474,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn, pool->def = NULL; virStoragePoolObjUnlock(pool); virStoragePoolObjFree(pool); - virReportOOMError(conn); + virReportOOMError(); return NULL; } pools->objs[pools->count++] = pool; @@ -1510,13 +1510,13 @@ virStoragePoolObjLoad(virConnectPtr conn, pool->configFile = strdup(path); if (pool->configFile == NULL) { - virReportOOMError(conn); + virReportOOMError(); virStoragePoolDefFree(def); return NULL; } pool->autostartLink = strdup(autostartLink); if (pool->autostartLink == NULL) { - virReportOOMError(conn); + virReportOOMError(); virStoragePoolDefFree(def); return NULL; } @@ -1609,7 +1609,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn, return -1; } if (!(pool->configFile = strdup(path))) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -1622,7 +1622,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn, return -1; } if (!(pool->autostartLink = strdup(path))) { - virReportOOMError(conn); + virReportOOMError(); VIR_FREE(pool->configFile); return -1; } @@ -1689,13 +1689,13 @@ virStoragePoolObjDeleteDef(virConnectPtr conn, } virStoragePoolSourcePtr -virStoragePoolSourceListNewSource(virConnectPtr conn, +virStoragePoolSourceListNewSource(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, virStoragePoolSourceListPtr list) { virStoragePoolSourcePtr source; if (VIR_REALLOC_N(list->sources, list->nsources+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1738,7 +1738,7 @@ char *virStoragePoolSourceListFormat(virConnectPtr conn, return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: virBufferFreeAndReset(&buf); return NULL; diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index a329622..eba1f12 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -80,7 +80,7 @@ virStorageEncryptionSecretParse(virConnectPtr conn, xmlXPathContextPtr ctxt, char *uuidstr = NULL; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -137,7 +137,7 @@ virStorageEncryptionParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) int format, i, n; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -165,7 +165,7 @@ virStorageEncryptionParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) goto cleanup; } if (n != 0 && VIR_ALLOC_N(ret->secrets, n) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } ret->nsecrets = n; @@ -200,7 +200,7 @@ virStorageEncryptionParseNode(virConnectPtr conn, ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 3e46948..5162d95 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -77,7 +77,7 @@ cpuCompareXML(virConnectPtr conn, doc = xmlParseMemory(xml, strlen(xml)); if (doc == NULL || (ctxt = xmlXPathNewContext(doc)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } diff --git a/src/cpu/cpu_generic.c b/src/cpu/cpu_generic.c index b18c1b4..566fed0 100644 --- a/src/cpu/cpu_generic.c +++ b/src/cpu/cpu_generic.c @@ -68,7 +68,7 @@ genericCompare(virCPUDefPtr host, return VIR_CPU_COMPARE_INCOMPATIBLE; if ((hash = genericHashFeatures(host)) == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index 4731e13..9a80c90 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -124,6 +124,6 @@ cleanup: return ret; no_memory: - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index ce55588..33ce776 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -279,7 +279,7 @@ cleanup: return cpu; no_memory: - virReportOOMError(NULL); + virReportOOMError(); error: virCPUDefFree(cpu); cpu = NULL; @@ -396,7 +396,7 @@ out: return ret; no_memory: - virReportOOMError(NULL); + virReportOOMError(); ret = -1; ignore: @@ -570,7 +570,7 @@ x86ModelFromCPU(const virCPUDefPtr cpu, return model; no_memory: - virReportOOMError(NULL); + virReportOOMError(); error: x86ModelFree(model); @@ -721,7 +721,7 @@ out: return ret; no_memory: - virReportOOMError(NULL); + virReportOOMError(); ret = -1; ignore: @@ -758,7 +758,7 @@ x86LoadMap(void) struct x86_map *map; if (VIR_ALLOC(map) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -912,7 +912,7 @@ out: return ret; no_memory: - virReportOOMError(NULL); + virReportOOMError(); error: ret = VIR_CPU_COMPARE_ERROR; @@ -1025,7 +1025,7 @@ x86EncodePolicy(const virCPUDefPtr cpu, return NULL; if (!(data = x86DataFromModel(model))) - virReportOOMError(NULL); + virReportOOMError(); x86ModelFree(model); @@ -1150,7 +1150,7 @@ cpuidSet(uint32_t base, struct cpuX86cpuid **set) max = cpuid.eax - base; if (VIR_ALLOC_N(*set, max + 1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1170,7 +1170,7 @@ x86NodeData(void) union cpuData *data; if (VIR_ALLOC(data) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } diff --git a/src/datatypes.c b/src/datatypes.c index adc13ad..fa342e0 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -140,7 +140,7 @@ virGetConnect(void) { virConnectPtr ret; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failed; } if (virMutexInit(&ret->lock) < 0) { @@ -320,13 +320,13 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) { if (ret == NULL) { if (VIR_ALLOC(ret) < 0) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->name = strdup(name); if (ret->name == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->magic = VIR_DOMAIN_MAGIC; @@ -462,13 +462,13 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) { if (ret == NULL) { if (VIR_ALLOC(ret) < 0) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->name = strdup(name); if (ret->name == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->magic = VIR_NETWORK_MAGIC; @@ -635,19 +635,19 @@ _("Failed to change interface mac address from %s to %s due to differing lengths } else { if (VIR_ALLOC(ret) < 0) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->name = strdup(name); if (ret->name == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->mac = strdup(mac); if (ret->mac == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -781,13 +781,13 @@ virGetStoragePool(virConnectPtr conn, const char *name, const unsigned char *uui if (ret == NULL) { if (VIR_ALLOC(ret) < 0) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->name = strdup(name); if (ret->name == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->magic = VIR_STORAGE_POOL_MAGIC; @@ -918,19 +918,19 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, const c if (ret == NULL) { if (VIR_ALLOC(ret) < 0) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->pool = strdup(pool); if (ret->pool == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->name = strdup(name); if (ret->name == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } if (virStrcpyStatic(ret->key, key) == NULL) { @@ -1066,7 +1066,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name) if (ret == NULL) { if (VIR_ALLOC(ret) < 0) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->magic = VIR_NODE_DEVICE_MAGIC; @@ -1074,7 +1074,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name) ret->name = strdup(name); if (ret->name == NULL) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -1200,7 +1200,7 @@ virGetSecret(virConnectPtr conn, const unsigned char *uuid, if (ret == NULL) { if (VIR_ALLOC(ret) < 0) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->magic = VIR_SECRET_MAGIC; @@ -1209,7 +1209,7 @@ virGetSecret(virConnectPtr conn, const unsigned char *uuid, ret->usageType = usageType; if (!(ret->usageID = strdup(usageID))) { virMutexUnlock(&conn->lock); - virReportOOMError(conn); + virReportOOMError(); goto error; } if (virHashAddEntry(conn->secrets, uuidstr, ret) < 0) { @@ -1311,7 +1311,7 @@ virStreamPtr virGetStream(virConnectPtr conn) { virMutexLock(&conn->lock); if (VIR_ALLOC(ret) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } ret->magic = VIR_STREAM_MAGIC; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index fc5a50e..a03c5f3 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -172,7 +172,7 @@ esxCapsInit(esxPrivate *priv) } if (caps == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -292,7 +292,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) /* Allocate per-connection private data */ if (VIR_ALLOC(priv) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -341,7 +341,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, conn->uri->server, conn->uri->port) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -349,7 +349,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) username = strdup(conn->uri->user); if (username == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } else { @@ -448,7 +448,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) vCenter = strdup(dynamicProperty->val->string); if (vCenter == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -482,7 +482,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED) if (virAsprintf(&url, "%s://%s/sdk", priv->transport, vCenter) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -777,12 +777,12 @@ esxGetHostname(virConnectPtr conn) complete = strdup(hostName); if (complete == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } else { if (virAsprintf(&complete, "%s.%s", hostName, domainName) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -962,7 +962,7 @@ esxGetCapabilities(virConnectPtr conn) char *xml = virCapabilitiesFormatXML(priv->caps); if (xml == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -1547,7 +1547,7 @@ esxDomainGetOSType(virDomainPtr domain ATTRIBUTE_UNUSED) char *osType = strdup("hvm"); if (osType == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -2168,7 +2168,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags) virBufferURIEncodeString(&buffer, datastoreName); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2322,7 +2322,7 @@ esxListDefinedDomains(virConnectPtr conn, char **const names, int maxnames) names[count] = strdup(dynamicProperty->val->string); if (names[count] == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2546,7 +2546,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED) virBufferURIEncodeString(&buffer, datastoreName); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2555,13 +2555,13 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED) if (directoryName != NULL) { if (virAsprintf(&datastoreRelatedPath, "[%s] %s/%s.vmx", datastoreName, directoryName, def->name) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } else { if (virAsprintf(&datastoreRelatedPath, "[%s] %s.vmx", datastoreName, def->name) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -2724,7 +2724,7 @@ esxDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams) char *type = strdup("allocation"); if (type == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -3012,7 +3012,7 @@ esxDomainMigratePrepare(virConnectPtr dconn, if (virAsprintf(uri_out, "%s://%s:%d/sdk", transport, dconn->uri->server, dconn->uri->port) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -3071,7 +3071,7 @@ esxDomainMigratePerform(virDomainPtr domain, xmlUri = xmlParseURI(uri); if (xmlUri == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index 6dcacd5..5da8e97 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -177,7 +177,7 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter, *transport = strdup(queryParam->value); if (*transport == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -195,7 +195,7 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter, *vCenter = strdup(queryParam->value); if (*vCenter == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } else if (STRCASEEQ(queryParam->name, "no_verify")) { @@ -232,7 +232,7 @@ esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter, *transport = strdup("https"); if (*transport == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -340,7 +340,7 @@ esxUtil_ParseDatastoreRelatedPath(const char *datastoreRelatedPath, *fileName = strdup(separator); if (*fileName == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } else { @@ -452,7 +452,7 @@ esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string, *string = strdup(value->str); if (*string == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 19c85c5..65c2b09 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -376,7 +376,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url, ctx->password = strdup(password); if (ctx->username == NULL || ctx->password == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -543,7 +543,7 @@ esxVI_Context_DownloadFile(esxVI_Context *ctx, const char *url, char **content) } if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -629,7 +629,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, } if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -701,7 +701,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, if (virAsprintf(&xpathExpression, "/soapenv:Envelope/soapenv:Body/vim:%sResponse", methodName) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1128,7 +1128,7 @@ esxVI_Alloc(void **ptrptr, size_t size) } if (virAllocN(ptrptr, size, 1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1655,7 +1655,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine, *name = strdup(dynamicProperty->val->string); if (*name == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2277,7 +2277,7 @@ esxVI_StartVirtualMachineTask(esxVI_Context *ctx, const char *name, esxVI_Response *response = NULL; if (virAsprintf(&methodName, "%s_Task", name) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2328,7 +2328,7 @@ esxVI_StartSimpleVirtualMachineTask virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2383,7 +2383,7 @@ esxVI_SimpleVirtualMachineMethod(esxVI_Context *ctx, const char *name, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2443,7 +2443,7 @@ esxVI_HandleVirtualMachineQuestion } if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2532,7 +2532,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, version = strdup(""); if (version == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2602,7 +2602,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, version = strdup(updateSet->version); if (version == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c index 9a1d002..d3beb07 100644 --- a/src/esx/esx_vi_methods.c +++ b/src/esx/esx_vi_methods.c @@ -131,7 +131,7 @@ esxVI_Login(esxVI_Context *ctx, const char *userName, const char *password, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -185,7 +185,7 @@ esxVI_Logout(esxVI_Context *ctx) virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -248,7 +248,7 @@ esxVI_SessionIsActive(esxVI_Context *ctx, const char *sessionID, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -312,7 +312,7 @@ esxVI_RetrieveProperties(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -409,7 +409,7 @@ esxVI_MigrateVM_Task(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -463,7 +463,7 @@ esxVI_ReconfigVM_Task(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -528,7 +528,7 @@ esxVI_RegisterVM_Task(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -578,7 +578,7 @@ esxVI_CancelTask(esxVI_Context *ctx, esxVI_ManagedObjectReference *task) virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -628,7 +628,7 @@ esxVI_UnregisterVM(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -681,7 +681,7 @@ esxVI_AnswerVM(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -748,7 +748,7 @@ esxVI_CreateFilter(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -803,7 +803,7 @@ esxVI_DestroyPropertyFilter(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -864,7 +864,7 @@ esxVI_WaitForUpdates(esxVI_Context *ctx, const char *version, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -961,7 +961,7 @@ esxVI_ValidateMigration(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1030,7 +1030,7 @@ esxVI_FindByIp(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1105,7 +1105,7 @@ esxVI_FindByUuid(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1186,7 +1186,7 @@ esxVI_QueryAvailablePerfMetric(esxVI_Context *ctx, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1249,7 +1249,7 @@ esxVI_QueryPerfCounter(esxVI_Context *ctx, esxVI_Int *counterIdList, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1312,7 +1312,7 @@ esxVI_QueryPerf(esxVI_Context *ctx, esxVI_PerfQuerySpec *querySpecList, virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index c561e13..c32bf33 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -622,7 +622,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) (*anyType)->value = strdup(""); if ((*anyType)->value == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -713,7 +713,7 @@ esxVI_String_AppendValueToList(esxVI_String **stringList, const char *value) string->value = strdup(value); if (string->value == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -799,7 +799,7 @@ esxVI_String_DeepCopyValue(char **dest, const char *src) *dest = strdup(src); if (*dest == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -858,7 +858,7 @@ esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string) (*string)->value = strdup(""); if ((*string)->value == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -888,7 +888,7 @@ esxVI_String_DeserializeValue(xmlNodePtr node, char **value) *value = strdup(""); if (*value == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } } diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c index 8a6496d..2651ccb 100644 --- a/src/esx/esx_vmx.c +++ b/src/esx/esx_vmx.c @@ -647,7 +647,7 @@ esxVMX_AbsolutePathToDatastoreRelatedPath(esxVI_Context *ctx, if (virAsprintf(&datastoreRelatedPath, "[%s] %s", datastoreName, directoryAndFileName) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -686,7 +686,7 @@ esxVMX_ParseFileName(esxVI_Context *ctx, const char *fileName, src = strdup(fileName); if (src == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -703,7 +703,7 @@ esxVMX_ParseFileName(esxVI_Context *ctx, const char *fileName, /* Found single file name referencing a file inside a datastore */ if (virAsprintf(&src, "[%s] %s/%s", datastoreName, directoryName, fileName) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -742,7 +742,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, } if (VIR_ALLOC(def) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -873,7 +873,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, def->cpumasklen = 0; if (VIR_ALLOC_N(def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -939,7 +939,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, def->os.type = strdup("hvm"); if (def->os.type == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -955,7 +955,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, } if (def->os.arch == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -968,7 +968,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, /* def:graphics */ if (VIR_ALLOC_N(def->graphics, 1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -984,7 +984,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, /* def:disks: 4 * 15 scsi + 2 * 2 ide + 2 floppy = 66 */ if (VIR_ALLOC_N(def->disks, 66) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1084,7 +1084,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, /* def:nets */ if (VIR_ALLOC_N(def->nets, 4) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1112,7 +1112,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, /* def:serials */ if (VIR_ALLOC_N(def->serials, 4) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1132,7 +1132,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, /* def:parallels */ if (VIR_ALLOC_N(def->parallels, 3) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1188,7 +1188,7 @@ esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) } if (VIR_ALLOC(*def) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1356,7 +1356,7 @@ esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus, } if (VIR_ALLOC(*def) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1381,7 +1381,7 @@ esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus, } if (virAsprintf(&prefix, "scsi%d:%d", controller, id) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1397,7 +1397,7 @@ esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus, (*def)->driverName = strdup(virtualDev); if ((*def)->driverName == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -1416,7 +1416,7 @@ esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus, } if (virAsprintf(&prefix, "ide%d:%d", controller, id) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1442,7 +1442,7 @@ esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus, } if (virAsprintf(&prefix, "floppy%d", controller) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1715,7 +1715,7 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) } if (VIR_ALLOC(*def) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -1909,7 +1909,7 @@ esxVMX_ParseSerial(esxVI_Context *ctx, virConfPtr conf, int port, } if (VIR_ALLOC(*def) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2032,7 +2032,7 @@ esxVMX_ParseParallel(esxVI_Context *ctx, virConfPtr conf, int port, } if (VIR_ALLOC(*def) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } @@ -2135,13 +2135,13 @@ esxVMX_FormatFileName(esxVI_Context *ctx ATTRIBUTE_UNUSED, const char *src) if (directoryName == NULL) { if (virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName, fileName) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } else { if (virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s/%s", datastoreName, directoryName, fileName) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } @@ -2150,7 +2150,7 @@ esxVMX_FormatFileName(esxVI_Context *ctx ATTRIBUTE_UNUSED, const char *src) absolutePath = strdup(src); if (absolutePath == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } } else { @@ -2421,7 +2421,7 @@ esxVMX_FormatConfig(esxVI_Context *ctx, virDomainDefPtr def, /* Get final VMX output */ if (virBufferError(&buffer)) { - virReportOOMError(NULL); + virReportOOMError(); goto failure; } diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c index 7fea057..bccb167 100644 --- a/src/interface/netcf_driver.c +++ b/src/interface/netcf_driver.c @@ -120,7 +120,7 @@ static virDrvOpenStatus interfaceOpenInterface(virConnectPtr conn, if (VIR_ALLOC(driverState) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto alloc_error; } diff --git a/src/libvirt.c b/src/libvirt.c index 8a9ee20..2e247dd 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1646,7 +1646,7 @@ virConnectGetURI (virConnectPtr conn) name = (char *)xmlSaveUri(conn->uri); if (!name) { - virReportOOMError (conn); + virReportOOMError(); goto error; } return name; @@ -10250,7 +10250,7 @@ int virStreamSendAll(virStreamPtr stream, } if (VIR_ALLOC_N(bytes, want) < 0) { - virReportOOMError(stream->conn); + virReportOOMError(); goto cleanup; } @@ -10348,7 +10348,7 @@ int virStreamRecvAll(virStreamPtr stream, if (VIR_ALLOC_N(bytes, want) < 0) { - virReportOOMError(stream->conn); + virReportOOMError(); goto cleanup; } diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index bc81543..8d7f69e 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -132,6 +132,6 @@ done: return 0; no_memory: - virReportOOMError(NULL); + virReportOOMError(); return -1; } diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 02242c7..2f07db1 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -314,7 +314,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) } if (virAsprintf(&oldroot, "%s/.oldroot", root->src) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto err; } @@ -336,7 +336,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* Create a directory called 'new' in tmpfs */ if (virAsprintf(&newroot, "%s/new", oldroot) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto err; } @@ -403,7 +403,7 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root) char *devpts; if (virAsprintf(&devpts, "/.oldroot%s/dev/pts", root->src) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return rc; } @@ -507,7 +507,7 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef) continue; if (virAsprintf(&src, "/.oldroot/%s", vmDef->fss[i]->src) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -553,12 +553,12 @@ static int lxcContainerUnmountOldFS(void) if (VIR_REALLOC_N(mounts, nmounts+1) < 0) { endmntent(procmnt); - virReportOOMError(NULL); + virReportOOMError(); return -1; } if (!(mounts[nmounts++] = strdup(mntent.mnt_dir))) { endmntent(procmnt); - virReportOOMError(NULL); + virReportOOMError(); return -1; } } @@ -738,12 +738,12 @@ static int lxcContainerChild( void *data ) if (root) { if (virAsprintf(&ttyPath, "%s%s", root->src, argv->ttyPath) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } } else { if (!(ttyPath = strdup(argv->ttyPath))) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } } @@ -815,7 +815,7 @@ int lxcContainerStart(virDomainDefPtr def, /* allocate a stack for the container */ if (VIR_ALLOC_N(stack, stacksize) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } stacktop = stack + stacksize; diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 6304815..7fd9a1b 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -159,7 +159,7 @@ static char*lxcMonitorPath(virDomainDefPtr def) if (virAsprintf(&sockpath, "%s/%s.sock", LXC_STATE_DIR, def->name) < 0) - virReportOOMError(NULL); + virReportOOMError(); return sockpath; } @@ -552,7 +552,7 @@ lxcControllerRun(virDomainDefPtr def, if (virAsprintf(&devpts, "%s/dev/pts", root->src) < 0 || virAsprintf(&devptmx, "%s/dev/pts/ptmx", root->src) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -683,18 +683,18 @@ int main(int argc, char *argv[]) case 'n': if ((name = strdup(optarg)) == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } break; case 'v': if (VIR_REALLOC_N(veths, nveths+1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if ((veths[nveths++] = strdup(optarg)) == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } break; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index d78f7f7..858b7d4 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -113,7 +113,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn, conn->uri = xmlParseURI("lxc:///"); if (!conn->uri) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } } else { @@ -179,7 +179,7 @@ static char *lxcGetCapabilities(virConnectPtr conn) { lxcDriverLock(driver); if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL) - virReportOOMError(conn); + virReportOOMError(); lxcDriverUnlock(driver); return xml; @@ -536,7 +536,7 @@ static char *lxcGetOSType(virDomainPtr dom) ret = strdup(vm->def->os.type); if (ret == NULL) - virReportOOMError(dom->conn); + virReportOOMError(); cleanup: if (vm) @@ -820,17 +820,17 @@ static int lxcSetupInterfaces(virConnectPtr conn, def->nets[i]->ifname = strdup(parentVeth); } if (VIR_REALLOC_N(*veths, (*nveths)+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error_exit; } if (((*veths)[(*nveths)] = strdup(containerVeth)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto error_exit; } (*nveths)++; if (NULL == def->nets[i]->ifname) { - virReportOOMError(conn); + virReportOOMError(); goto error_exit; } @@ -879,7 +879,7 @@ static int lxcMonitorClient(virConnectPtr conn, if (virAsprintf(&sockpath, "%s/%s.sock", driver->stateDir, vm->def->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -1153,7 +1153,7 @@ static int lxcControllerStart(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: if (largv) { for (i = 0 ; i < largc ; i++) @@ -1202,7 +1202,7 @@ static int lxcVmStart(virConnectPtr conn, if (virAsprintf(&logfile, "%s/%s.log", driver->logDir, vm->def->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -1890,7 +1890,8 @@ static int lxcVersion(virConnectPtr conn, unsigned long *version) return 0; } -static char *lxcGetSchedulerType(virDomainPtr domain, int *nparams) +static char *lxcGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, + int *nparams) { char *schedulerType = NULL; @@ -1900,7 +1901,7 @@ static char *lxcGetSchedulerType(virDomainPtr domain, int *nparams) schedulerType = strdup("posix"); if (schedulerType == NULL) - virReportOOMError(domain->conn); + virReportOOMError(); return schedulerType; } diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 08e5ee6..27678d0 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -152,7 +152,7 @@ networkFindActiveConfigs(struct network_driver *driver) { char *pidpath; if (virAsprintf(&pidpath, "/proc/%d/exe", obj->dnsmasqPid) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (virFileLinkPointsTo(pidpath, DNSMASQ) == 0) @@ -267,7 +267,7 @@ networkStartup(int privileged) { return 0; out_of_memory: - virReportOOMError(NULL); + virReportOOMError(); error: if (driverState) @@ -362,8 +362,7 @@ networkShutdown(void) { static int -networkBuildDnsmasqArgv(virConnectPtr conn, - virNetworkObjPtr network, +networkBuildDnsmasqArgv(virNetworkObjPtr network, const char *pidfile, const char ***argv) { int i, len, r; @@ -518,7 +517,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn, VIR_FREE((*argv)[i]); VIR_FREE(*argv); } - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -553,12 +552,12 @@ dhcpStartDhcpDaemon(virConnectPtr conn, } if (!(pidfile = virFilePid(NETWORK_PID_DIR, network->def->name))) { - virReportOOMError(conn); + virReportOOMError(); return -1; } argv = NULL; - if (networkBuildDnsmasqArgv(conn, network, pidfile, &argv) < 0) { + if (networkBuildDnsmasqArgv(network, pidfile, &argv) < 0) { VIR_FREE(pidfile); return -1; } @@ -844,7 +843,7 @@ static int networkDisableIPV6(virConnectPtr conn, int ret = -1; if (virAsprintf(&field, SYSCTL_PATH "/net/ipv6/conf/%s/disable_ipv6", network->def->bridge) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -862,7 +861,7 @@ static int networkDisableIPV6(virConnectPtr conn, VIR_FREE(field); if (virAsprintf(&field, SYSCTL_PATH "/net/ipv6/conf/%s/accept_ra", network->def->bridge) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -874,7 +873,7 @@ static int networkDisableIPV6(virConnectPtr conn, VIR_FREE(field); if (virAsprintf(&field, SYSCTL_PATH "/net/ipv6/conf/%s/autoconf", network->def->bridge) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -1131,7 +1130,7 @@ static int networkListNetworks(virConnectPtr conn, char **const names, int nname if (virNetworkObjIsActive(driver->networks.objs[i])) { if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) { virNetworkObjUnlock(driver->networks.objs[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } got++; @@ -1175,7 +1174,7 @@ static int networkListDefinedNetworks(virConnectPtr conn, char **const names, in if (!virNetworkObjIsActive(driver->networks.objs[i])) { if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) { virNetworkObjUnlock(driver->networks.objs[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } got++; @@ -1456,7 +1455,7 @@ static char *networkGetBridgeName(virNetworkPtr net) { bridge = strdup(network->def->bridge); if (!bridge) - virReportOOMError(net->conn); + virReportOOMError(); cleanup: if (network) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index fbadfca..74258be 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -85,7 +85,7 @@ static int update_driver_name(virConnectPtr conn, VIR_FREE(dev->def->driver); if (virAsprintf(&driver_link, "%s/driver", dev->def->sysfs_path) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -106,7 +106,7 @@ static int update_driver_name(virConnectPtr conn, if (p) { dev->def->driver = strdup(p+1); if (!dev->def->driver) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -174,7 +174,7 @@ nodeListDevices(virConnectPtr conn, virNodeDeviceHasCap(driver->devs.objs[i], cap)) { if ((names[ndevs++] = strdup(driver->devs.objs[i]->def->name)) == NULL) { virNodeDeviceObjUnlock(driver->devs.objs[i]); - virReportOOMError(conn); + virReportOOMError(); goto failure; } } @@ -314,7 +314,7 @@ static char *nodeDeviceGetParent(virNodeDevicePtr dev) if (obj->def->parent) { ret = strdup(obj->def->parent); if (!ret) - virReportOOMError(dev->conn); + virReportOOMError(); } else { virNodeDeviceReportError(dev->conn, VIR_ERR_INTERNAL_ERROR, "%s", _("no parent for this device")); @@ -380,7 +380,7 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames) for (caps = obj->def->caps; caps && ncaps < maxnames; caps = caps->next) { names[ncaps] = strdup(virNodeDevCapTypeToString(caps->type)); if (names[ncaps++] == NULL) { - virReportOOMError(dev->conn); + virReportOOMError(); goto cleanup; } } @@ -430,7 +430,7 @@ nodeDeviceVportCreateDelete(virConnectPtr conn, parent_host, operation_file) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto cleanup; } @@ -442,7 +442,7 @@ nodeDeviceVportCreateDelete(virConnectPtr conn, wwpn, wwnn) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto cleanup; } @@ -618,7 +618,7 @@ nodeDeviceDestroy(virNodeDevicePtr dev) obj = NULL; if (parent_name == NULL) { - virReportOOMError(dev->conn); + virReportOOMError(); goto out; } diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c index c1fce5d..e11fb2e 100644 --- a/src/node_device/node_device_linux_sysfs.c +++ b/src/node_device/node_device_linux_sysfs.c @@ -46,7 +46,7 @@ static int open_wwn_file(const char *prefix, char *wwn_path = NULL; if (virAsprintf(&wwn_path, "%s/host%d/%s", prefix, host, file) < 0) { - virReportOOMError(NULL); + virReportOOMError(); retval = -1; goto out; } @@ -93,7 +93,7 @@ int read_wwn_linux(int host, const char *file, char **wwn) *wwn = strndup(p, sizeof(buf)); if (*wwn == NULL) { - virReportOOMError(NULL); + virReportOOMError(); retval = -1; goto out; } @@ -122,7 +122,7 @@ int check_fc_host_linux(union _virNodeDevCapData *d) if (virAsprintf(&sysfs_path, "%s/host%d", LINUX_SYSFS_FC_HOST_PREFIX, d->scsi_host.host) < 0) { - virReportOOMError(NULL); + virReportOOMError(); retval = -1; goto out; } @@ -170,7 +170,7 @@ int check_vport_capable_linux(union _virNodeDevCapData *d) if (virAsprintf(&sysfs_path, "%s/host%d/vport_create", LINUX_SYSFS_FC_HOST_PREFIX, d->scsi_host.host) < 0) { - virReportOOMError(NULL); + virReportOOMError(); retval = -1; goto out; } @@ -305,7 +305,7 @@ int get_physical_function_linux(const char *sysfs_path, "with sysfs path '%s'\n", sysfs_path); if (virBuildPath(&device_link, sysfs_path, "physfn") == -1) { - virReportOOMError(NULL); + virReportOOMError(); } else { ret = get_sriov_function(device_link, &d->pci_dev.physical_function); if (ret == SRIOV_FOUND) { @@ -340,14 +340,14 @@ int get_virtual_functions_linux(const char *sysfs_path, unsigned int *num_funcs = &d->pci_dev.num_virtual_functions; if (virBuildPath(&device_link, sysfs_path, entry->d_name) == -1) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } VIR_DEBUG("Number of virtual functions: %d", *num_funcs); if (VIR_REALLOC_N(d->pci_dev.virtual_functions, (*num_funcs) + 1) != 0) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index be765c4..76f83bf 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -125,7 +125,7 @@ static int udevGetDeviceProperty(struct udev_device *udev_device, VIR_ERROR("Failed to allocate memory for property value for " "property key '%s' on device with sysname '%s'", property_key, udev_device_get_sysname(udev_device)); - virReportOOMError(NULL); + virReportOOMError(); ret = PROPERTY_ERROR; goto out; } @@ -214,7 +214,7 @@ static int udevGetDeviceSysfsAttr(struct udev_device *udev_device, VIR_ERROR("Failed to allocate memory for sysfs attribute value for " "sysfs attribute '%s' on device with sysname '%s'", attr_name, udev_device_get_sysname(udev_device)); - virReportOOMError(NULL); + virReportOOMError(); ret = PROPERTY_ERROR; goto out; } @@ -390,7 +390,7 @@ static int udevTranslatePCIIds(unsigned int vendor, if (vendor_name != NULL) { *vendor_string = strdup(vendor_name); if (*vendor_string == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } } @@ -398,7 +398,7 @@ static int udevTranslatePCIIds(unsigned int vendor, if (device_name != NULL) { *product_string = strdup(device_name); if (*product_string == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } } @@ -678,7 +678,7 @@ static int udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUSED, data->scsi_target.name = strdup(sysname); if (data->scsi_target.name == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } @@ -737,7 +737,7 @@ static int udevGetSCSIType(unsigned int type, char **typestring) if (*typestring == NULL) { if (foundtype == 1) { ret = -1; - virReportOOMError(NULL); + virReportOOMError(); } else { VIR_ERROR("Failed to find SCSI device type %d", type); } @@ -819,7 +819,7 @@ static int udevProcessDisk(struct udev_device *device, data->storage.drive_type = strdup("disk"); if (data->storage.drive_type == NULL) { - virReportOOMError(NULL); + virReportOOMError(); ret = -1; goto out; } @@ -906,7 +906,7 @@ static int udevProcessCDROM(struct udev_device *device, VIR_FREE(def->caps->data.storage.drive_type); def->caps->data.storage.drive_type = strdup("cdrom"); if (def->caps->data.storage.drive_type == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } @@ -1232,7 +1232,7 @@ static int udevSetParent(struct udev_device *device, def->parent_sysfs_path = strdup(parent_sysfs_path); if (def->parent_sysfs_path == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } @@ -1245,7 +1245,7 @@ static int udevSetParent(struct udev_device *device, } if (def->parent == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } @@ -1263,7 +1263,7 @@ static int udevAddOneDevice(struct udev_device *device) int ret = -1; if (VIR_ALLOC(def) != 0) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } @@ -1275,7 +1275,7 @@ static int udevAddOneDevice(struct udev_device *device) } if (VIR_ALLOC(def->caps) != 0) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } @@ -1453,18 +1453,18 @@ static int udevSetupSystemDev(void) int ret = -1; if (VIR_ALLOC(def) != 0) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } def->name = strdup("computer"); if (def->name == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } if (VIR_ALLOC(def->caps) != 0) { - virReportOOMError(NULL); + virReportOOMError(); goto out; } @@ -1556,7 +1556,7 @@ static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED) int ret = 0; if (VIR_ALLOC(priv) < 0) { - virReportOOMError(NULL); + virReportOOMError(); ret = -1; goto out; } @@ -1564,7 +1564,7 @@ static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED) priv->watch = -1; if (VIR_ALLOC(driverState) < 0) { - virReportOOMError(NULL); + virReportOOMError(); VIR_FREE(priv); ret = -1; goto out; diff --git a/src/opennebula/one_conf.c b/src/opennebula/one_conf.c index 2ed330b..a2f7073 100644 --- a/src/opennebula/one_conf.c +++ b/src/opennebula/one_conf.c @@ -142,7 +142,7 @@ int oneSubmitVM(virConnectPtr conn, char* templ; int oneid; - if ((templ = xmlOneTemplate(conn,vm->def)) == NULL) + if ((templ = xmlOneTemplate(vm->def)) == NULL) return -1; if ((oneid = c_oneAllocateTemplate(templ)) < 0) { @@ -166,7 +166,7 @@ int oneSubmitVM(virConnectPtr conn, * @return OpenNebula VM template. */ -char* xmlOneTemplate(virConnectPtr conn,virDomainDefPtr def) +char* xmlOneTemplate(virDomainDefPtr def) { int i; virBuffer buf= VIR_BUFFER_INITIALIZER; @@ -277,7 +277,7 @@ char* xmlOneTemplate(virConnectPtr conn,virDomainDefPtr def) return virBufferContentAndReset(&buf); no_memory: - virReportOOMError(conn); + virReportOOMError(); virBufferFreeAndReset(&buf); return NULL; }; diff --git a/src/opennebula/one_conf.h b/src/opennebula/one_conf.h index de865cb..bb01026 100644 --- a/src/opennebula/one_conf.h +++ b/src/opennebula/one_conf.h @@ -43,7 +43,7 @@ virCapsPtr oneCapsInit(void); int oneSubmitVM(virConnectPtr conn ,one_driver_t* driver, virDomainObjPtr vm); -char* xmlOneTemplate(virConnectPtr conn,virDomainDefPtr def); +char* xmlOneTemplate(virDomainDefPtr def); #define oneError(conn, dom, code, fmt...) \ virReportErrorHelper(conn, VIR_FROM_ONE, code, __FILE__, \ diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index c96d24d..8c8985a 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -69,7 +69,7 @@ static virDrvOpenStatus oneOpen(virConnectPtr conn, if (conn->uri == NULL) { conn->uri = xmlParseURI("one:///"); if (!conn->uri) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } } else if (conn->uri->scheme == NULL || @@ -392,7 +392,7 @@ static char *oneGetOSType(virDomainPtr dom) ret = strdup(vm->def->os.type); if (!ret) - virReportOOMError(dom->conn); + virReportOOMError(); cleanup: if (vm) @@ -641,7 +641,7 @@ static int oneStartup(int privileged ATTRIBUTE_UNUSED){ one_driver->nextid=1; if ((one_driver->caps = oneCapsInit()) == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } oneDriverUnlock(one_driver); @@ -702,7 +702,7 @@ static char* oneGetCapabilities(virConnectPtr conn){ char *xml; oneDriverLock(privconn); if ((xml = virCapabilitiesFormatXML(privconn->caps)) == NULL) - virReportOOMError(conn); + virReportOOMError(); oneDriverUnlock(privconn); return xml; } diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 43bbaf2..6baaea2 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -315,7 +315,7 @@ openvzReadNetworkConf(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainNetDefFree(net); return -1; @@ -411,7 +411,7 @@ openvzReadFSConf(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainFSDefFree(fs); return -1; @@ -531,7 +531,7 @@ int openvzLoadDomains(struct openvz_driver *driver) { return 0; no_memory: - virReportOOMError(NULL); + virReportOOMError(); cleanup: fclose(fp); @@ -559,7 +559,7 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va char line[PATH_MAX] ; if (virAsprintf(&temp_file, "%s.tmp", conf_file)<0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -747,7 +747,7 @@ openvzCopyDefaultConfig(int vpsid) goto cleanup; if (virAsprintf(&default_conf_file, "%s/ve-%s.conf-sample", confdir, configfile_value) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 196fd8c..49a7bd2 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -321,7 +321,7 @@ static char *openvzGetOSType(virDomainPtr dom) } if (!(ret = strdup(vm->def->os.type))) - virReportOOMError(dom->conn); + virReportOOMError(); cleanup: if (vm) @@ -812,7 +812,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) if (vmdef->os.init == NULL) { if (!(vmdef->os.init = strdup("/sbin/init"))) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -892,7 +892,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, if (vmdef->os.init == NULL) { if (!(vmdef->os.init = strdup("/sbin/init"))) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -1192,7 +1192,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn, conn->uri = xmlParseURI("openvz:///system"); if (conn->uri == NULL) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } } else { @@ -1231,7 +1231,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn, * here, don't return DECLINED, always use ERROR */ if (VIR_ALLOC(driver) < 0) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } @@ -1372,7 +1372,7 @@ static int openvzListDefinedDomains(virConnectPtr conn, return got; no_memory: - virReportOOMError(conn); + virReportOOMError(); for ( ; got >= 0 ; got--) VIR_FREE(names[got]); return -1; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index bd5cfc7..80ed4b9 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -108,24 +108,24 @@ phypOpen(virConnectPtr conn, } if (VIR_ALLOC(phyp_driver) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto failure; } if (VIR_ALLOC(uuid_table) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto failure; } if (VIR_ALLOC(connection_data) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto failure; } len = strlen(conn->uri->path) + 1; if (VIR_ALLOC_N(string, len) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto failure; } @@ -136,7 +136,7 @@ phypOpen(virConnectPtr conn, managed_system = strdup(conn->uri->path); if (!managed_system) { - virReportOOMError(conn); + virReportOOMError(); goto failure; } @@ -169,7 +169,7 @@ phypOpen(virConnectPtr conn, phyp_driver->managed_system = managed_system; phyp_driver->uuid_table = uuid_table; if ((phyp_driver->caps = phypCapsInit()) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto failure; } @@ -260,12 +260,12 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, goto err; if (virAsprintf(&pubkey, "%s/.ssh/id_rsa.pub", userhome) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } if (virAsprintf(&pvtkey, "%s/.ssh/id_rsa", userhome) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -492,7 +492,7 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status, exit: if (virBufferError(&tex_ret)) { virBufferFreeAndReset(&tex_ret); - virReportOOMError(conn); + virReportOOMError(); return NULL; } return virBufferContentAndReset(&tex_ret); @@ -512,7 +512,7 @@ phypGetLparID(LIBSSH2_SESSION * session, const char *managed_system, if (virAsprintf(&cmd, "lssyscfg -r lpar -m %s --filter lpar_names=%s -F lpar_id", managed_system, name) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -546,7 +546,7 @@ phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system, if (virAsprintf(&cmd, "lssyscfg -r lpar -m %s --filter lpar_ids=%d -F name", managed_system, lpar_id) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -619,7 +619,7 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, "lshwres -m %s -r mem --level lpar -F curr_mem " "--filter lpar_ids=%d", managed_system, lpar_id) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } } else { @@ -627,7 +627,7 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, "lshwres -m %s -r mem --level lpar -F " "curr_max_mem --filter lpar_ids=%d", managed_system, lpar_id) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } } @@ -688,7 +688,7 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, "lshwres -m %s -r proc --level lpar -F " "curr_max_procs --filter lpar_ids=%d", managed_system, lpar_id) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } } else { @@ -696,7 +696,7 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, "lshwres -m %s -r proc --level lpar -F " "curr_procs --filter lpar_ids=%d", managed_system, lpar_id) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } } @@ -739,7 +739,7 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system, "lshwres -m %s -r virtualio --rsubtype scsi -F " "remote_slot_num --filter lpar_names=%s", managed_system, lpar_name) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } ret = phypExec(session, cmd, &exit_status, conn); @@ -786,7 +786,7 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system, "lshwres -m %s -r virtualio --rsubtype scsi -F " "backing_devices --filter slots=%d", managed_system, remote_slot) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -814,7 +814,7 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system, backing_device = strdup(char_ptr); if (backing_device == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto err; } } else { @@ -854,7 +854,7 @@ phypGetLparState(virConnectPtr conn, unsigned int lpar_id) if (virAsprintf(&cmd, "lssyscfg -r lpar -m %s -F state --filter lpar_ids=%d", managed_system, lpar_id) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -897,7 +897,7 @@ phypGetVIOSPartitionID(virConnectPtr conn) if (virAsprintf(&cmd, "lssyscfg -m %s -r lpar -F lpar_id,lpar_env|grep " "vioserver|sed -s 's/,.*$//g'", managed_system) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -937,7 +937,7 @@ phypDiskType(virConnectPtr conn, char *backing_device) "viosvrcmd -m %s -p %d -c \"lssp -field name type " "-fmt , -all|grep %s|sed -e 's/^.*,//g'\"", managed_system, vios_id, backing_device) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -994,7 +994,7 @@ phypNumDomainsGeneric(virConnectPtr conn, unsigned int type) if (virAsprintf(&cmd, "lssyscfg -r lpar -m %s -F lpar_id,state %s |grep -c " "^[0-9]*", managed_system, state) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -1063,7 +1063,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, (&cmd, "lssyscfg -r lpar -m %s -F lpar_id,state %s | sed -e 's/,.*$//g'", managed_system, state) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } ret = phypExec(session, cmd, &exit_status, conn); @@ -1126,7 +1126,7 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames) (&cmd, "lssyscfg -r lpar -m %s -F name,state | grep \"Not Activated\" | " "sed -e 's/,.*$//g'", managed_system) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -1144,7 +1144,7 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames) if (char_ptr2) { *char_ptr2 = '\0'; if ((names[got++] = strdup(domains)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto err; } char_ptr2++; @@ -1291,7 +1291,7 @@ phypDomainResume(virDomainPtr dom) (&cmd, "chsysstate -m %s -r lpar -o on --id %d -f %s", managed_system, dom->id, dom->name) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto err; } @@ -1325,7 +1325,7 @@ phypDomainShutdown(virDomainPtr dom) (&cmd, "chsysstate -m %s -r lpar -o shutdown --id %d", managed_system, dom->id) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto err; } @@ -1381,7 +1381,7 @@ phypDomainDestroy(virDomainPtr dom) if (virAsprintf (&cmd, "rmsyscfg -m %s -r lpar --id %d", managed_system, dom->id) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto err; } @@ -1463,7 +1463,7 @@ phypConnectGetCapabilities(virConnectPtr conn) char *xml; if ((xml = virCapabilitiesFormatXML(phyp_driver->caps)) == NULL) - virReportOOMError(conn); + virReportOOMError(); return xml; } @@ -1550,7 +1550,7 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) "chhwres -r proc -m %s --id %d -o %c --procunits %d 2>&1 |sed" "-e 's/^.*\\([0-9]\\+.[0-9]\\+\\).*$/\\1/g'", managed_system, dom->id, operation, amount) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto err; } @@ -1671,7 +1671,7 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) managed_system, def->name, (int) def->memory, (int) def->memory, (int) def->maxmem, (int) def->vcpus, def->disks[0]->src) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -1734,12 +1734,12 @@ phypUUIDTable_AddLpar(virConnectPtr conn, unsigned char *uuid, int id) i--; if (VIR_REALLOC_N(uuid_table->lpars, uuid_table->nlpars) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } if (VIR_ALLOC(uuid_table->lpars[i]) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -1781,7 +1781,7 @@ phypUUIDTable_ReadFile(virConnectPtr conn) rc = read(fd, &id, sizeof(int)); if (rc == sizeof(int)) { if (VIR_ALLOC(uuid_table->lpars[i]) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } uuid_table->lpars[i]->id = id; @@ -1799,7 +1799,7 @@ phypUUIDTable_ReadFile(virConnectPtr conn) } } } else - virReportOOMError(conn); + virReportOOMError(); close(fd); return 0; @@ -1861,7 +1861,7 @@ phypUUIDTable_Init(virConnectPtr conn) return 0; if (VIR_ALLOC_N(ids, nids) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -1891,7 +1891,7 @@ phypUUIDTable_Init(virConnectPtr conn) if (VIR_ALLOC_N(uuid_table->lpars, uuid_table->nlpars) >= 0) { for (i = 0; i < uuid_table->nlpars; i++) { if (VIR_ALLOC(uuid_table->lpars[i]) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto err; } uuid_table->lpars[i]->id = ids[i]; @@ -1901,7 +1901,7 @@ phypUUIDTable_Init(virConnectPtr conn) ids[i]); } } else { - virReportOOMError(conn); + virReportOOMError(); goto err; } diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3d83a8f..0ce5790 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -104,11 +104,11 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, driver->dynamicOwnership = 1; if (!(driver->vncListen = strdup("127.0.0.1"))) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } if (!(driver->vncTLSx509certdir = strdup(SYSCONF_DIR "/pki/libvirt-vnc"))) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -157,7 +157,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, if (p && p->str) { VIR_FREE(driver->vncTLSx509certdir); if (!(driver->vncTLSx509certdir = strdup(p->str))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -168,7 +168,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, if (p && p->str) { VIR_FREE(driver->vncListen); if (!(driver->vncListen = strdup(p->str))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -179,7 +179,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, if (p && p->str) { VIR_FREE(driver->vncPassword); if (!(driver->vncPassword = strdup(p->str))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -189,7 +189,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, CHECK_TYPE ("security_driver", VIR_CONF_STRING); if (p && p->str) { if (!(driver->securityDriverName = strdup(p->str))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -204,7 +204,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, if (p && p->str) { VIR_FREE(driver->vncSASLdir); if (!(driver->vncSASLdir = strdup(p->str))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -213,7 +213,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, p = virConfGetValue (conf, "user"); CHECK_TYPE ("user", VIR_CONF_STRING); if (!(user = strdup(p && p->str ? p->str : QEMU_USER))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -228,7 +228,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, p = virConfGetValue (conf, "group"); CHECK_TYPE ("group", VIR_CONF_STRING); if (!(group = strdup(p && p->str ? p->str : QEMU_GROUP))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -284,7 +284,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, for (pp = p->list; pp; pp = pp->next) len++; if (VIR_ALLOC_N(driver->cgroupDeviceACL, 1+len) < 0) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -296,7 +296,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, } driver->cgroupDeviceACL[i] = strdup (pp->str); if (driver->cgroupDeviceACL[i] == NULL) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -310,7 +310,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, if (p && p->str) { VIR_FREE(driver->saveImageFormat); if (!(driver->saveImageFormat = strdup(p->str))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -321,7 +321,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, if (p && p->str) { VIR_FREE(driver->hugetlbfs_mount); if (!(driver->hugetlbfs_mount = strdup(p->str))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFree(conf); return -1; } @@ -467,7 +467,7 @@ qemudParseMachineTypesStr(const char *output, return 0; no_memory: - virReportOOMError(NULL); + virReportOOMError(); virCapabilitiesFreeMachines(list, nitems); return -1; } @@ -550,7 +550,7 @@ qemudGetOldMachinesFromInfo(virCapsGuestDomainInfoPtr info, } if (VIR_ALLOC_N(list, info->nmachines) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return 0; } @@ -574,7 +574,7 @@ qemudGetOldMachinesFromInfo(virCapsGuestDomainInfoPtr info, return 1; no_memory: - virReportOOMError(NULL); + virReportOOMError(); virCapabilitiesFreeMachines(list, info->nmachines); return 0; } @@ -731,7 +731,7 @@ qemudProbeCPUModels(const char *qemu, } if (parse(output, count, cpus) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -983,7 +983,7 @@ cleanup: return ret; no_memory: - virReportOOMError(NULL); + virReportOOMError(); error: virCapabilitiesFreeMachines(machines, nmachines); @@ -1003,7 +1003,7 @@ qemudCapsInitCPU(virCapsPtr caps, if (VIR_ALLOC(cpu) < 0 || !(cpu->arch = strdup(arch))) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -1448,7 +1448,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn, return -1; } else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) { if (!(brname = strdup(net->data.bridge.brname))) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } else { @@ -1468,7 +1468,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn, strchr(net->ifname, '%')) { VIR_FREE(net->ifname); if (!(net->ifname = strdup("vnet%d"))) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } /* avoid exposing vnet%d in dumpxml or error outputs */ @@ -1550,7 +1550,7 @@ static int qemuAssignDeviceDiskAliasLegacy(virDomainDiskDefPtr disk) devname = strdup(disk->dst); if (!devname) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1603,7 +1603,7 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk) } if (ret == -1) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1632,7 +1632,7 @@ static int qemuAssignDeviceDiskAliasCustom(virDomainDiskDefPtr disk) return 0; no_memory: - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1670,7 +1670,7 @@ qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx) } if (virAsprintf(&net->info.alias, "net%d", idx) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1697,7 +1697,7 @@ qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr hostdev } if (virAsprintf(&hostdev->info.alias, "hostdev%d", idx) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1712,7 +1712,7 @@ qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller) if (virAsprintf(&controller->info.alias, "%s%d", prefix, controller->idx) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1780,7 +1780,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, int qemuCmdFlags) return 0; no_memory: - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1808,7 +1808,7 @@ static char *qemuPCIAddressAsString(virDomainDeviceInfoPtr dev) dev->addr.pci.domain, dev->addr.pci.bus, dev->addr.pci.slot) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } return addr; @@ -1852,7 +1852,7 @@ qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def) return addrs; no_memory: - virReportOOMError(NULL); + virReportOOMError(); error: qemuDomainPCIAddressSetFree(addrs); return NULL; @@ -2341,7 +2341,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } if (virBufferError(&opt)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2397,7 +2397,7 @@ qemuBuildDriveDevStr(virConnectPtr conn, virBufferVSprintf(&opt, ",id=%s", disk->info.alias); if (virBufferError(&opt)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2430,7 +2430,7 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def) goto error; if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2443,7 +2443,7 @@ error: char * -qemuBuildNicStr(virConnectPtr conn, +qemuBuildNicStr(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, virDomainNetDefPtr net, const char *prefix, int vlan) @@ -2460,7 +2460,7 @@ qemuBuildNicStr(virConnectPtr conn, (net->model ? net->model : ""), (net->info.alias ? ",name=" : ""), (net->info.alias ? net->info.alias : "")) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2496,7 +2496,7 @@ qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan) goto error; if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2509,7 +2509,7 @@ error: char * -qemuBuildHostNetStr(virConnectPtr conn, +qemuBuildHostNetStr(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, virDomainNetDefPtr net, char type_sep, int vlan, @@ -2583,7 +2583,7 @@ qemuBuildHostNetStr(virConnectPtr conn, if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2609,7 +2609,7 @@ qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev) goto error; if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2632,7 +2632,7 @@ qemuBuildUSBInputDevStr(virDomainInputDefPtr dev) virBufferVSprintf(&buf, ",id=%s", dev->info.alias); if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2668,7 +2668,7 @@ qemuBuildSoundDevStr(virDomainSoundDefPtr sound) goto error; if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2695,7 +2695,7 @@ qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev) goto error; if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2716,7 +2716,7 @@ qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev) dev->source.subsys.u.pci.bus, dev->source.subsys.u.pci.slot, dev->source.subsys.u.pci.function) < 0) - virReportOOMError(NULL); + virReportOOMError(); return ret; } @@ -2738,7 +2738,7 @@ qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev) dev->source.subsys.u.usb.bus, dev->source.subsys.u.usb.device, dev->info.alias) < 0) - virReportOOMError(NULL); + virReportOOMError(); return ret; } @@ -2759,7 +2759,7 @@ qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev) if (virAsprintf(&ret, "host:%.3d.%.3d", dev->source.subsys.u.usb.bus, dev->source.subsys.u.usb.device) < 0) - virReportOOMError(NULL); + virReportOOMError(); return ret; } @@ -2834,7 +2834,7 @@ qemuBuildChrChardevStr(virDomainChrDefPtr dev) } if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2913,7 +2913,7 @@ qemuBuildChrArgStr(virDomainChrDefPtr dev, const char *prefix) } if (virBufferError(&buf)) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -3012,13 +3012,12 @@ cleanup: return ret; no_memory: - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } static char * -qemuBuildSmpArgStr(virConnectPtr conn, - const virDomainDefPtr def, +qemuBuildSmpArgStr(const virDomainDefPtr def, int qemuCmdFlags) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -3042,7 +3041,7 @@ qemuBuildSmpArgStr(virConnectPtr conn, if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -3285,7 +3284,7 @@ int qemudBuildCommandLine(virConnectPtr conn, } ADD_ARG_LIT("-smp"); - if (!(smp = qemuBuildSmpArgStr(conn, def, qemuCmdFlags))) + if (!(smp = qemuBuildSmpArgStr(def, qemuCmdFlags))) goto error; ADD_ARG(smp); @@ -4095,7 +4094,7 @@ int qemudBuildCommandLine(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: if (tapfds && *tapfds) { @@ -4229,7 +4228,7 @@ no_memory: for (i = 0 ; i < argcount ; i++) VIR_FREE(arglist[i]); VIR_FREE(arglist); - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -4331,7 +4330,7 @@ qemuParseCommandLineKeywords(virConnectPtr conn, return keywordCount; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: for (i = 0 ; i < keywordCount ; i++) { VIR_FREE(keywords[i]); @@ -4369,7 +4368,7 @@ qemuParseCommandLineDisk(virConnectPtr conn, return NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4409,7 +4408,7 @@ qemuParseCommandLineDisk(virConnectPtr conn, if (!def->driverName) { virDomainDiskDefFree(def); def = NULL; - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } def->driverType = values[i]; @@ -4505,7 +4504,7 @@ qemuParseCommandLineDisk(virConnectPtr conn, if (!def->dst) { virDomainDiskDefFree(def); def = NULL; - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (STREQ(def->dst, "xvda")) @@ -4598,7 +4597,7 @@ qemuParseCommandLineNet(virConnectPtr conn, } if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4746,7 +4745,7 @@ qemuParseCommandLinePCI(virConnectPtr conn, } if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4813,7 +4812,7 @@ qemuParseCommandLineUSB(virConnectPtr conn, } if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4966,7 +4965,7 @@ qemuParseCommandLineChr(virConnectPtr conn, return def; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainChrDefFree(def); return NULL; @@ -4974,14 +4973,13 @@ error: static virCPUDefPtr -qemuInitGuestCPU(virConnectPtr conn, - virDomainDefPtr dom) +qemuInitGuestCPU(virDomainDefPtr dom) { if (!dom->cpu) { virCPUDefPtr cpu; if (VIR_ALLOC(cpu) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -5003,7 +5001,7 @@ qemuParseCommandLineCPU(virConnectPtr conn, const char *p = val; const char *next; - if (!(cpu = qemuInitGuestCPU(conn, dom))) + if (!(cpu = qemuInitGuestCPU(dom))) goto error; do { @@ -5056,7 +5054,7 @@ syntax: goto error; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: return -1; } @@ -5107,7 +5105,7 @@ qemuParseCommandLineSmp(virConnectPtr conn, if (sockets && cores && threads) { virCPUDefPtr cpu; - if (!(cpu = qemuInitGuestCPU(conn, dom))) + if (!(cpu = qemuInitGuestCPU(dom))) goto error; cpu->sockets = sockets; cpu->cores = cores; @@ -5655,7 +5653,7 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, return def; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainDefFree(def); VIR_FREE(nics); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1e796ef..e75e9a2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -207,12 +207,12 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) xmlNodePtr *nodes = NULL; if (VIR_ALLOC(priv->monConfig) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } if (!(priv->monConfig->info.alias = strdup("monitor"))) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -257,7 +257,7 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) if (n) { priv->nvcpupids = n; if (VIR_REALLOC_N(priv->vcpupids, priv->nvcpupids) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -506,7 +506,7 @@ qemudLogFD(virConnectPtr conn, struct qemud_driver *driver, const char* name) if ((ret = snprintf(logfile, sizeof(logfile), "%s/%s.log", driver->logDir, name)) < 0 || ret >= sizeof(logfile)) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -635,15 +635,14 @@ qemudAutostartConfigs(struct qemud_driver *driver) { * Returns 0 on success */ static int -qemudRemoveDomainStatus(virConnectPtr conn, - struct qemud_driver *driver, +qemudRemoveDomainStatus(struct qemud_driver *driver, virDomainObjPtr vm) { char ebuf[1024]; char *file = NULL; if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return(-1); } @@ -792,7 +791,7 @@ findVolumeQcowPassphrase(qemuMonitorPtr mon ATTRIBUTE_UNUSED, if (VIR_ALLOC_N(passphrase, size + 1) < 0) { memset(data, 0, size); VIR_FREE(data); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } memcpy(passphrase, data, size); @@ -940,7 +939,7 @@ qemuCreateCapabilities(virCapsPtr oldcaps, /* Basic host arch / guest machine capabilities */ if (!(caps = qemudCapsInit(oldcaps))) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -970,7 +969,7 @@ qemuCreateCapabilities(virCapsPtr oldcaps, return caps; no_memory: - virReportOOMError(NULL); + virReportOOMError(); virCapabilitiesFree(caps); return NULL; } @@ -1186,7 +1185,7 @@ qemudStartup(int privileged) { return 0; out_of_memory: - virReportOOMError(NULL); + virReportOOMError(); error: if (qemu_driver) qemuDriverUnlock(qemu_driver); @@ -1393,8 +1392,7 @@ qemudReadLogOutput(virConnectPtr conn, * Returns -1 for error, 0 success, 1 continue reading */ static int -qemudExtractTTYPath(virConnectPtr conn, - const char *haystack, +qemudExtractTTYPath(const char *haystack, size_t *offset, char **path) { @@ -1417,7 +1415,7 @@ qemudExtractTTYPath(virConnectPtr conn, if (c_isspace(*tmp)) { *path = strndup(dev, tmp-dev); if (*path == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -1472,7 +1470,7 @@ qemudFindCharDevicePTYsMonitor(virConnectPtr conn, chr->data.file.path = strdup(path); \ \ if (chr->data.file.path == NULL) { \ - virReportOOMError(conn); \ + virReportOOMError(); \ return -1; \ } \ } \ @@ -1487,7 +1485,7 @@ qemudFindCharDevicePTYsMonitor(virConnectPtr conn, } static int -qemudFindCharDevicePTYs(virConnectPtr conn, +qemudFindCharDevicePTYs(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, virDomainObjPtr vm, const char *output, int fd ATTRIBUTE_UNUSED) @@ -1503,7 +1501,7 @@ qemudFindCharDevicePTYs(virConnectPtr conn, for (i = 0 ; i < vm->def->nserials ; i++) { virDomainChrDefPtr chr = vm->def->serials[i]; if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) { - if ((ret = qemudExtractTTYPath(conn, output, &offset, + if ((ret = qemudExtractTTYPath(output, &offset, &chr->data.file.path)) != 0) return ret; } @@ -1513,7 +1511,7 @@ qemudFindCharDevicePTYs(virConnectPtr conn, for (i = 0 ; i < vm->def->nparallels ; i++) { virDomainChrDefPtr chr = vm->def->parallels[i]; if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) { - if ((ret = qemudExtractTTYPath(conn, output, &offset, + if ((ret = qemudExtractTTYPath(output, &offset, &chr->data.file.path)) != 0) return ret; } @@ -1523,7 +1521,7 @@ qemudFindCharDevicePTYs(virConnectPtr conn, for (i = 0 ; i < vm->def->nchannels ; i++) { virDomainChrDefPtr chr = vm->def->channels[i]; if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) { - if ((ret = qemudExtractTTYPath(conn, output, &offset, + if ((ret = qemudExtractTTYPath(output, &offset, &chr->data.file.path)) != 0) return ret; } @@ -1576,7 +1574,7 @@ qemudWaitForMonitor(virConnectPtr conn, * log output method. */ virHashTablePtr paths = virHashCreate(0); if (paths == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1609,7 +1607,7 @@ qemuDetectVcpuPIDs(virConnectPtr conn, if (vm->def->virtType != VIR_DOMAIN_VIRT_KVM) { priv->nvcpupids = 1; if (VIR_ALLOC_N(priv->vcpupids, priv->nvcpupids) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } priv->vcpupids[0] = vm->pid; @@ -1662,7 +1660,7 @@ qemudInitCpuAffinity(virConnectPtr conn, cpumaplen = VIR_CPU_MAPLEN(maxcpu); if (VIR_ALLOC_N(cpumap, cpumaplen) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -2499,8 +2497,7 @@ static int qemudSecurityHook(void *data) { } static int -qemuPrepareMonitorChr(virConnectPtr conn, - struct qemud_driver *driver, +qemuPrepareMonitorChr(struct qemud_driver *driver, virDomainChrDefPtr monConfig, const char *vm) { @@ -2510,13 +2507,13 @@ qemuPrepareMonitorChr(virConnectPtr conn, monConfig->data.nix.listen = 1; if (!(monConfig->info.alias = strdup("monitor"))) { - virReportOOMError(conn); + virReportOOMError(); return -1; } if (virAsprintf(&monConfig->data.nix.path, "%s/%s.monitor", driver->libDir, vm) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -2619,11 +2616,11 @@ static int qemudStartVMDaemon(virConnectPtr conn, goto cleanup; if (VIR_ALLOC(priv->monConfig) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } - if (qemuPrepareMonitorChr(conn, driver, priv->monConfig, vm->def->name) < 0) + if (qemuPrepareMonitorChr(driver, priv->monConfig, vm->def->name) < 0) goto cleanup; #if HAVE_YAJL @@ -2905,7 +2902,7 @@ retry: vm->def->name); } - qemudRemoveDomainStatus(conn, driver, vm); + qemudRemoveDomainStatus(driver, vm); vm->pid = -1; vm->def->id = -1; @@ -2938,7 +2935,7 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn, "qemu:///system" : "qemu:///session"); if (!conn->uri) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } } else { @@ -3088,7 +3085,7 @@ static char *qemudGetCapabilities(virConnectPtr conn) { qemu_driver->caps = caps; if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL) - virReportOOMError(conn); + virReportOOMError(); cleanup: qemuDriverUnlock(driver); @@ -3605,7 +3602,7 @@ static char *qemudDomainGetOSType(virDomainPtr dom) { } if (!(type = strdup(vm->def->os.type))) - virReportOOMError(dom->conn); + virReportOOMError(); cleanup: if (vm) @@ -4512,7 +4509,7 @@ static int qemudDomainRestore(virConnectPtr conn, } if (VIR_ALLOC_N(xml, header.xml_len) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4798,7 +4795,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, goto cleanup; } - if (qemuPrepareMonitorChr(conn, driver, &monConfig, def->name) < 0) + if (qemuPrepareMonitorChr(driver, &monConfig, def->name) < 0) goto cleanup; if (qemudBuildCommandLine(conn, driver, def, @@ -4824,7 +4821,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -4932,7 +4929,7 @@ qemudCanonicalizeMachineFromInfo(virDomainDefPtr def, continue; if (!(*canonical = strdup(machine->canonical))) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -4949,7 +4946,7 @@ qemudCanonicalizeMachineDirect(virDomainDefPtr def, char **canonical) int i, nmachines = 0; if (qemudProbeMachineTypes(def->emulator, &machines, &nmachines) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -5253,7 +5250,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn, } if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -5334,12 +5331,12 @@ static int qemudDomainAttachPciControllerDevice(virConnectPtr conn, } if (!(devstr = qemuBuildControllerDevStr(controller))) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -5392,7 +5389,7 @@ qemuDomainFindOrCreateSCSIDiskController(virConnectPtr conn, /* No SCSI controller present, for back compatability we * now hotplug a controller */ if (VIR_ALLOC(cont) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } cont->type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI; @@ -5466,7 +5463,7 @@ static int qemudDomainAttachSCSIDisk(virConnectPtr conn, } if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -5556,7 +5553,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn, } if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -5738,7 +5735,7 @@ try_tapfd_close: goto cleanup; no_memory: - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -5756,7 +5753,7 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn, char *devstr = NULL; if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -5820,8 +5817,7 @@ error: } -static int qemudDomainAttachHostUsbDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainAttachHostUsbDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, int qemuCmdFlags) @@ -5835,7 +5831,7 @@ static int qemudDomainAttachHostUsbDevice(virConnectPtr conn, goto error; if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -5888,7 +5884,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn, break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: - if (qemudDomainAttachHostUsbDevice(conn, driver, vm, + if (qemudDomainAttachHostUsbDevice(driver, vm, hostdev, qemuCmdFlags) < 0) goto error; break; @@ -6225,7 +6221,7 @@ qemudDomainDetachNetDevice(virConnectPtr conn, } if (virAsprintf(&hostnet_name, "host%s", detach->info.alias) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -6580,7 +6576,7 @@ static char *qemuGetSchedulerType(virDomainPtr dom, ret = strdup("posix"); if (!ret) - virReportOOMError(dom->conn); + virReportOOMError(); cleanup: qemuDriverUnlock(driver); @@ -6997,7 +6993,7 @@ qemudDomainMemoryPeek (virDomainPtr dom, } if (virAsprintf(&tmp, driver->cacheDir, "/qemu.mem.XXXXXX") < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto endjob; } @@ -7313,7 +7309,7 @@ static struct qemuStreamMigFile *qemuStreamMigOpen(virStreamPtr st, int ret; if (VIR_ALLOC(qemust) < 0) { - virReportOOMError(st->conn); + virReportOOMError(); return NULL; } @@ -7484,7 +7480,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, if (virAsprintf(&unixfile, "%s/qemu.tunnelmigrate.dest.%s", driver->stateDir, vm->def->name) < 0) { - virReportOOMError (dconn); + virReportOOMError(); goto endjob; } unlink(unixfile); @@ -7506,7 +7502,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, goto endjob; } if (internalret < 0) { - virReportOOMError(dconn); + virReportOOMError(); goto endjob; } /* Start the QEMU daemon, with the same command-line arguments plus @@ -7637,7 +7633,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, internalret = virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port); VIR_FREE(hostname); if (internalret < 0) { - virReportOOMError (dconn); + virReportOOMError(); goto cleanup; } } else { @@ -7661,7 +7657,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, /* Caller frees */ if (virAsprintf(uri_out, "%s:%d", uri_in, this_port) < 0) { - virReportOOMError (dconn); + virReportOOMError(); goto cleanup; } @@ -7772,7 +7768,7 @@ static int doNativeMigrate(virDomainPtr dom, /* HACK: source host generates bogus URIs, so fix them up */ char *tmpuri; if (virAsprintf(&tmpuri, "tcp://%s", uri + strlen("tcp:")) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } uribits = xmlParseURI(tmpuri); @@ -7898,7 +7894,7 @@ static int doTunnelMigrate(virDomainPtr dom, if (virAsprintf(&unixfile, "%s/qemu.tunnelmigrate.src.%s", driver->stateDir, vm->def->name) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 9e09876..c1db64c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -575,7 +575,7 @@ qemuMonitorOpen(virDomainObjPtr vm, } if (VIR_ALLOC(mon) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a556088..6ced8cd 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -188,11 +188,11 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon, memset(&msg, 0, sizeof msg); if (!(cmdstr = virJSONValueToString(cmd))) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (virAsprintf(&msg.txBuffer, "%s\r\n", cmdstr) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } msg.txLength = strlen(msg.txBuffer); @@ -350,7 +350,7 @@ qemuMonitorJSONCommandAddTimestamp(virJSONValuePtr obj) return 0; no_memory: - virReportOOMError(NULL); + virReportOOMError(); virJSONValueFree(timestamp); return -1; } @@ -446,7 +446,7 @@ qemuMonitorJSONMakeCommand(const char *cmdname, return obj; no_memory: - virReportOOMError(NULL); + virReportOOMError(); error: virJSONValueFree(obj); virJSONValueFree(jargs); @@ -569,7 +569,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply, } if (VIR_REALLOC_N(threads, ncpus) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -975,7 +975,7 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon, virJSONValuePtr cmd; virJSONValuePtr reply = NULL; if (virAsprintf(&bandwidthstr, "%lum", bandwidth) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } cmd = qemuMonitorJSONMakeCommand("migrate_set_speed", @@ -1123,7 +1123,7 @@ int qemuMonitorJSONMigrateToHost(qemuMonitorPtr mon, int ret; if (virAsprintf(&uri, "tcp:%s:%d", hostname, port) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1147,19 +1147,19 @@ int qemuMonitorJSONMigrateToCommand(qemuMonitorPtr mon, argstr = virArgvToString(argv); if (!argstr) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } /* Migrate to file */ safe_target = qemuMonitorEscapeShell(target); if (!safe_target) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (virAsprintf(&dest, "exec:%s >>%s 2>/dev/null", argstr, safe_target) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1180,7 +1180,7 @@ int qemuMonitorJSONMigrateToUnix(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&dest, "unix:%s", unixfile) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1241,7 +1241,7 @@ int qemuMonitorJSONAddUSBDisk(qemuMonitorPtr mon, char *disk; if (virAsprintf(&disk, "disk:%s", path) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1261,7 +1261,7 @@ int qemuMonitorJSONAddUSBDeviceExact(qemuMonitorPtr mon, char *addr; if (virAsprintf(&addr, "host:%.3d.%.3d", bus, dev) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1280,7 +1280,7 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon, char *addr; if (virAsprintf(&addr, "host:%.4x:%.4x", vendor, product) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1346,7 +1346,7 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon, /* XXX hostDomain */ if (virAsprintf(&dev, "host=%.2x:%.2x.%.1x", hostAddr->bus, hostAddr->slot, hostAddr->function) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1387,7 +1387,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon, memset(guestAddr, 0, sizeof(*guestAddr)); if (virAsprintf(&dev, "file=%s,if=%s", path, bus) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1458,7 +1458,7 @@ int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon, /* XXX what about function ? */ if (virAsprintf(&addr, "%.4x:%.2x:%.2x", guestAddr->domain, guestAddr->bus, guestAddr->slot) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1625,7 +1625,7 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply, if (STRPREFIX(type, "pty:")) { char *path = strdup(type + strlen("pty:")); if (!path) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1682,7 +1682,7 @@ int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon, memset(guestAddr, 0, sizeof(*guestAddr)); if (virAsprintf(&dev, "if=%s", bus) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1751,7 +1751,7 @@ int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon, if (virAsprintf(&dev, "%.2x:%.2x.%.1x", controllerAddr->bus, controllerAddr->slot, controllerAddr->function) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 42ce363..ce325f5 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -219,7 +219,7 @@ qemuMonitorCommandWithHandler(qemuMonitorPtr mon, memset(&msg, 0, sizeof msg); if (virAsprintf(&msg.txBuffer, "%s\r", cmd) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } msg.txLength = strlen(msg.txBuffer); @@ -244,7 +244,7 @@ qemuMonitorCommandWithHandler(qemuMonitorPtr mon, } else { *reply = strdup(""); if (!*reply) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } } @@ -765,7 +765,7 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon, * we just worked in bytes with unsigned long long everywhere. */ if (virAsprintf(&cmd, "balloon %lu", (newmem / 1024)) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -798,7 +798,7 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "eject %s", devname) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -837,12 +837,12 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon, int ret = -1; if (!(safepath = qemuMonitorEscapeArg(newmedia))) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (virAsprintf(&cmd, "change %s \"%s\"", devname, safepath) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -882,12 +882,12 @@ static int qemuMonitorTextSaveMemory(qemuMonitorPtr mon, int ret = -1; if (!(safepath = qemuMonitorEscapeArg(path))) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (virAsprintf(&cmd, "%s %llu %zi \"%s\"", cmdtype, offset, length, safepath) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -934,7 +934,7 @@ int qemuMonitorTextSetMigrationSpeed(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "migrate_set_speed %lum", bandwidth) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1049,7 +1049,7 @@ static int qemuMonitorTextMigrate(qemuMonitorPtr mon, const char *extra; if (!safedest) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1059,7 +1059,7 @@ static int qemuMonitorTextMigrate(qemuMonitorPtr mon, extra = " "; if (virAsprintf(&cmd, "migrate %s\"%s\"", extra, safedest) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1102,7 +1102,7 @@ int qemuMonitorTextMigrateToHost(qemuMonitorPtr mon, int ret; if (virAsprintf(&uri, "tcp:%s:%d", hostname, port) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1126,19 +1126,19 @@ int qemuMonitorTextMigrateToCommand(qemuMonitorPtr mon, argstr = virArgvToString(argv); if (!argstr) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } /* Migrate to file */ safe_target = qemuMonitorEscapeShell(target); if (!safe_target) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (virAsprintf(&dest, "exec:%s >>%s 2>/dev/null", argstr, safe_target) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1159,7 +1159,7 @@ int qemuMonitorTextMigrateToUnix(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&dest, "unix:%s", unixfile) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1194,12 +1194,12 @@ int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon, safepath = qemuMonitorEscapeArg(path); if (!safepath) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } if (virAsprintf(&cmd, "usb_add disk:%s", safepath) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1234,7 +1234,7 @@ static int qemuMonitorTextAddUSBDevice(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "usb_add %s", addr) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1269,7 +1269,7 @@ int qemuMonitorTextAddUSBDeviceExact(qemuMonitorPtr mon, char *addr; if (virAsprintf(&addr, "host:%.3d.%.3d", bus, dev) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1287,7 +1287,7 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon, char *addr; if (virAsprintf(&addr, "host:%.4x:%.4x", vendor, product) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1375,7 +1375,7 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon, /* XXX hostAddr->domain */ if (virAsprintf(&cmd, "pci_add pci_addr=auto host host=%.2x:%.2x.%.1x", hostAddr->bus, hostAddr->slot, hostAddr->function) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1419,14 +1419,14 @@ int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon, safe_path = qemuMonitorEscapeArg(path); if (!safe_path) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } try_command: if (virAsprintf(&cmd, "pci_add %s storage file=%s,if=%s", (tryOldSyntax ? "0": "pci_addr=auto"), safe_path, bus) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1468,7 +1468,7 @@ int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "pci_add pci_addr=auto nic %s", nicstr) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1504,14 +1504,14 @@ int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon, try_command: if (tryOldSyntax) { if (virAsprintf(&cmd, "pci_del 0 %.2x", guestAddr->slot) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } } else { /* XXX function ? */ if (virAsprintf(&cmd, "pci_del pci_addr=%.4x:%.2x:%.2x", guestAddr->domain, guestAddr->bus, guestAddr->slot) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } } @@ -1560,7 +1560,7 @@ int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "getfd %s", fdname) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1596,7 +1596,7 @@ int qemuMonitorTextCloseFileHandle(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "closefd %s", fdname) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1632,7 +1632,7 @@ int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "host_net_add %s", netstr) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1662,7 +1662,7 @@ int qemuMonitorTextRemoveHostNetwork(qemuMonitorPtr mon, int ret = -1; if (virAsprintf(&cmd, "host_net_remove %d %s", vlan, netname) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1748,7 +1748,7 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon, *eol = '\0'; char *path = strdup(needle + strlen(NEEDLE)); if (path == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1782,7 +1782,7 @@ int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon, try_command: if (virAsprintf(&cmd, "pci_add %s storage if=%s", (tryOldSyntax ? "0": "pci_addr=auto"), bus) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -1872,7 +1872,7 @@ int qemuMonitorTextAttachDrive(qemuMonitorPtr mon, safe_str = qemuMonitorEscapeArg(drivestr); if (!safe_str) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1882,7 +1882,7 @@ try_command: controllerAddr->domain, controllerAddr->bus, controllerAddr->slot, safe_str); if (ret == -1) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -2013,7 +2013,7 @@ int qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon, GET_INT(p, 16, product); if (VIR_REALLOC_N(addrs, naddrs+1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -2054,12 +2054,12 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon, int ret = -1; if (!(safedev = qemuMonitorEscapeArg(devicestr))) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (virAsprintf(&cmd, "device_add %s", safedev) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } @@ -2094,7 +2094,7 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon, safe_str = qemuMonitorEscapeArg(drivestr); if (!safe_str) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -2102,7 +2102,7 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon, * address required when attaching drives to a controller */ ret = virAsprintf(&cmd, "drive_add dummy %s", safe_str); if (ret == -1) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d6f5fce..809d386 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -557,7 +557,7 @@ doRemoteOpen (virConnectPtr conn, } if (!name) { - virReportOOMError(conn); + virReportOOMError(); goto failed; } @@ -873,18 +873,18 @@ doRemoteOpen (virConnectPtr conn, conn->uri = xmlParseURI(uriret.uri); VIR_FREE(uriret.uri); if (!conn->uri) { - virReportOOMError (conn); + virReportOOMError(); goto failed; } } if(VIR_ALLOC(priv->callbackList)<0) { - virReportOOMError(conn); + virReportOOMError(); goto failed; } if(VIR_ALLOC(priv->domainEvents)<0) { - virReportOOMError(conn); + virReportOOMError(); goto failed; } @@ -932,7 +932,7 @@ doRemoteOpen (virConnectPtr conn, return retcode; out_of_memory: - virReportOOMError (conn); + virReportOOMError(); failed: /* Close the socket if we failed. */ @@ -969,7 +969,7 @@ remoteAllocPrivateData(virConnectPtr conn) { struct private_data *priv; if (VIR_ALLOC(priv) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2907,7 +2907,7 @@ remoteListDefinedDomains (virConnectPtr conn, char **const names, int maxnames) for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -3244,7 +3244,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain, /* Serialise the scheduler parameters. */ args.params.params_len = nparams; if (VIR_ALLOC_N(args.params.params_val, nparams) < 0) { - virReportOOMError(domain->conn); + virReportOOMError(); goto done; } @@ -3253,7 +3253,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain, // call() will free this: args.params.params_val[i].field = strdup (params[i].field); if (args.params.params_val[i].field == NULL) { - virReportOOMError (domain->conn); + virReportOOMError(); do_error = 1; } args.params.params_val[i].value.type = params[i].type; @@ -3640,7 +3640,7 @@ remoteListNetworks (virConnectPtr conn, char **const names, int maxnames) for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -3722,7 +3722,7 @@ remoteListDefinedNetworks (virConnectPtr conn, for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -4195,7 +4195,7 @@ remoteListInterfaces (virConnectPtr conn, char **const names, int maxnames) for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -4276,7 +4276,7 @@ remoteListDefinedInterfaces (virConnectPtr conn, char **const names, int maxname for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -4632,7 +4632,7 @@ remoteListStoragePools (virConnectPtr conn, char **const names, int maxnames) for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -4710,7 +4710,7 @@ remoteListDefinedStoragePools (virConnectPtr conn, for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -5275,7 +5275,7 @@ remoteStoragePoolListVolumes (virStoragePoolPtr pool, char **const names, int ma for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } } @@ -5684,7 +5684,7 @@ static int remoteNodeListDevices(virConnectPtr conn, for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -5846,7 +5846,7 @@ static int remoteNodeDeviceListCaps(virNodeDevicePtr dev, for (--i; i >= 0; --i) VIR_FREE(names[i]); - virReportOOMError(dev->conn); + virReportOOMError(); goto cleanup; } } @@ -6111,7 +6111,7 @@ static char *addrToString(struct sockaddr_storage *sa, socklen_t salen) } if (virAsprintf(&addr, "%s;%s", host, port) == -1) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -6909,7 +6909,7 @@ remoteSecretListSecrets (virConnectPtr conn, char **uuids, int maxuuids) for (--i; i >= 0; --i) VIR_FREE(uuids[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -7123,7 +7123,7 @@ remoteStreamOpen(virStreamPtr st, struct private_stream_data *stpriv; if (VIR_ALLOC(stpriv) < 0) { - virReportOOMError(st->conn); + virReportOOMError(); return NULL; } @@ -7154,7 +7154,7 @@ remoteStreamPacket(virStreamPtr st, memset(&hdr, 0, sizeof hdr); if (VIR_ALLOC(thiscall) < 0) { - virReportOOMError(st->conn); + virReportOOMError(); return -1; } @@ -7333,7 +7333,7 @@ remoteStreamRecv(virStreamPtr st, struct remote_thread_call *thiscall; if (VIR_ALLOC(thiscall) < 0) { - virReportOOMError(st->conn); + virReportOOMError(); goto cleanup; } @@ -7551,7 +7551,7 @@ prepareCall(virConnectPtr conn, struct remote_thread_call *rv; if (VIR_ALLOC(rv) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -8592,7 +8592,7 @@ call (virConnectPtr conn, struct private_data *priv, ret_filter, ret); if (!thiscall) { - virReportOOMError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn); + virReportOOMError(); return -1; } diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 4478296..2b72a28 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -162,7 +162,7 @@ replaceFile(virConnectPtr conn, const char *filename, void *data, size_t size) int fd = -1, ret = -1; if (virAsprintf(&tmp_path, "%sXXXXXX", filename) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } fd = mkstemp (tmp_path); @@ -206,7 +206,7 @@ cleanup: } static char * -secretComputePath(virConnectPtr conn, virSecretDriverStatePtr driver, +secretComputePath(virSecretDriverStatePtr driver, const virSecretEntry *secret, const char *suffix) { char *ret; @@ -216,23 +216,25 @@ secretComputePath(virConnectPtr conn, virSecretDriverStatePtr driver, if (virAsprintf(&ret, "%s/%s%s", driver->directory, uuidstr, suffix) < 0) /* ret is NULL */ - virReportOOMError(conn); + virReportOOMError(); return ret; } static char * -secretXMLPath(virConnectPtr conn, virSecretDriverStatePtr driver, +secretXMLPath(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, + virSecretDriverStatePtr driver, const virSecretEntry *secret) { - return secretComputePath(conn, driver, secret, ".xml"); + return secretComputePath(driver, secret, ".xml"); } static char * -secretBase64Path(virConnectPtr conn, virSecretDriverStatePtr driver, +secretBase64Path(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, + virSecretDriverStatePtr driver, const virSecretEntry *secret) { - return secretComputePath(conn, driver, secret, ".base64"); + return secretComputePath(driver, secret, ".base64"); } static int @@ -293,7 +295,7 @@ secretSaveValue(virConnectPtr conn, virSecretDriverStatePtr driver, base64_encode_alloc((const char *)secret->value, secret->value_size, &base64); if (base64 == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -387,7 +389,7 @@ secretLoadValue(virConnectPtr conn, virSecretDriverStatePtr driver, } if (VIR_ALLOC_N(contents, st.st_size) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (saferead(fd, contents, st.st_size) != st.st_size) { @@ -403,7 +405,7 @@ secretLoadValue(virConnectPtr conn, virSecretDriverStatePtr driver, goto cleanup; } if (value == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -438,7 +440,7 @@ secretLoad(virConnectPtr conn, virSecretDriverStatePtr driver, if (virAsprintf(&xml_filename, "%s/%s", driver->directory, xml_basename) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } def = virSecretDefParseFile(conn, xml_filename); @@ -450,7 +452,7 @@ secretLoad(virConnectPtr conn, virSecretDriverStatePtr driver, goto cleanup; if (VIR_ALLOC(secret) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } secret->def = def; @@ -581,7 +583,7 @@ secretListSecrets(virConnectPtr conn, char **uuids, int maxuuids) if (i == maxuuids) break; if (VIR_ALLOC_N(uuidstr, VIR_UUID_STRING_BUFLEN) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } virUUIDFormat(secret->def->uuid, uuidstr); @@ -705,7 +707,7 @@ secretDefineXML(virConnectPtr conn, const char *xml, /* No existing secret at all, create one */ if (VIR_ALLOC(secret) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -822,7 +824,7 @@ secretSetValue(virSecretPtr obj, const unsigned char *value, virSecretEntryPtr secret; if (VIR_ALLOC_N(new_value, value_size) < 0) { - virReportOOMError(obj->conn); + virReportOOMError(); return -1; } @@ -905,7 +907,7 @@ secretGetValue(virSecretPtr obj, size_t *value_size, unsigned int flags) } if (VIR_ALLOC_N(ret, secret->value_size) < 0) { - virReportOOMError(obj->conn); + virReportOOMError(); goto cleanup; } memcpy(ret, secret->value, secret->value_size); diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index 138751c..15a9d59 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -57,7 +57,7 @@ profile_status(const char *str, const int check_enforcing) /* create string that is '<str> \0' for accurate matching */ if (virAsprintf(&tmp, "%s ", str) == -1) { - virReportOOMError(NULL); + virReportOOMError(); return rc; } @@ -65,7 +65,7 @@ profile_status(const char *str, const int check_enforcing) /* create string that is '<str> (enforce)\0' for accurate matching */ if (virAsprintf(&etmp, "%s (enforce)", str) == -1) { VIR_FREE(tmp); - virReportOOMError(NULL); + virReportOOMError(); return rc; } } @@ -112,7 +112,7 @@ profile_status_file(const char *str) int len; if (virAsprintf(&profile, "%s/%s", APPARMOR_DIR "/libvirt", str) == -1) { - virReportOOMError(NULL); + virReportOOMError(); return rc; } @@ -127,7 +127,7 @@ profile_status_file(const char *str) /* create string that is ' <str> flags=(complain)\0' */ if (virAsprintf(&tmp, " %s flags=(complain)", str) == -1) { - virReportOOMError(NULL); + virReportOOMError(); goto failed; } @@ -237,14 +237,14 @@ remove_profile(const char *profile) } static char * -get_profile_name(virConnectPtr conn, virDomainObjPtr vm) +get_profile_name(virDomainObjPtr vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; char *name = NULL; virUUIDFormat(vm->def->uuid, uuidstr); if (virAsprintf(&name, "%s%s", AA_PREFIX, uuidstr) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -290,7 +290,7 @@ AppArmorSecurityDriverProbe(void) /* see if template file exists */ if (virAsprintf(&template, "%s/TEMPLATE", APPARMOR_DIR "/libvirt") == -1) { - virReportOOMError(NULL); + virReportOOMError(); return rc; } @@ -339,12 +339,12 @@ AppArmorGenSecurityLabel(virConnectPtr conn, virDomainObjPtr vm) return rc; } - if ((profile_name = get_profile_name(conn, vm)) == NULL) + if ((profile_name = get_profile_name(vm)) == NULL) return rc; vm->def->seclabel.label = strndup(profile_name, strlen(profile_name)); if (!vm->def->seclabel.label) { - virReportOOMError(NULL); + virReportOOMError(); goto clean; } @@ -352,13 +352,13 @@ AppArmorGenSecurityLabel(virConnectPtr conn, virDomainObjPtr vm) vm->def->seclabel.imagelabel = strndup(profile_name, strlen(profile_name)); if (!vm->def->seclabel.imagelabel) { - virReportOOMError(NULL); + virReportOOMError(); goto err; } vm->def->seclabel.model = strdup(SECURITY_APPARMOR_NAME); if (!vm->def->seclabel.model) { - virReportOOMError(conn); + virReportOOMError(); goto err; } @@ -405,7 +405,7 @@ AppArmorGetSecurityProcessLabel(virConnectPtr conn, int rc = -1; char *profile_name = NULL; - if ((profile_name = get_profile_name(conn, vm)) == NULL) + if ((profile_name = get_profile_name(vm)) == NULL) return rc; if (virStrcpy(sec->label, profile_name, @@ -471,7 +471,7 @@ AppArmorSetSecurityProcessLabel(virConnectPtr conn, int rc = -1; char *profile_name = NULL; - if ((profile_name = get_profile_name(conn, vm)) == NULL) + if ((profile_name = get_profile_name(vm)) == NULL) return rc; if (STRNEQ(drv->name, secdef->model)) { @@ -511,7 +511,7 @@ AppArmorRestoreSecurityImageLabel(virConnectPtr conn, if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC) return 0; - if ((profile_name = get_profile_name(conn, vm)) == NULL) + if ((profile_name = get_profile_name(vm)) == NULL) return rc; /* Update the profile only if it is loaded */ @@ -555,7 +555,7 @@ AppArmorSetSecurityImageLabel(virConnectPtr conn, return rc; } - if ((profile_name = get_profile_name(conn, vm)) == NULL) + if ((profile_name = get_profile_name(vm)) == NULL) return rc; /* update the profile only if it is loaded */ diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 9f1a644..67687c6 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -204,7 +204,7 @@ SELinuxGenSecurityLabel(virConnectPtr conn, } vm->def->seclabel.model = strdup(SECURITY_SELINUX_NAME); if (!vm->def->seclabel.model) { - virReportOOMError(conn); + virReportOOMError(); goto err; } diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index e79294a..b22c031 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -139,7 +139,7 @@ virStorageBackendCopyToFD(virConnectPtr conn, bzero(&zerobuf, sizeof(zerobuf)); if (VIR_ALLOC_N(buf, bytes) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -434,7 +434,7 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, if (VIR_ALLOC(enc_secret) < 0 || VIR_REALLOC_N(enc->secrets, 1) < 0 || VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -446,7 +446,7 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, def->usage_type = VIR_SECRET_USAGE_TYPE_VOLUME; def->usage.volume = strdup(vol->target.path); if (def->usage.volume == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } xml = virSecretDefFormat(conn, def); @@ -1012,7 +1012,7 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn, } else { target->perms.label = strdup(filecon); if (target->perms.label == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } freecon(filecon); @@ -1164,7 +1164,7 @@ virStorageBackendStablePath(virConnectPtr conn, if (virAsprintf(&stablepath, "%s/%s", pool->def->target.path, dent->d_name) == -1) { - virReportOOMError(conn); + virReportOOMError(); closedir(dh); return NULL; } @@ -1187,7 +1187,7 @@ virStorageBackendStablePath(virConnectPtr conn, stablepath = strdup(devpath); if (stablepath == NULL) - virReportOOMError(conn); + virReportOOMError(); return stablepath; } @@ -1224,7 +1224,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn, /* Compile all regular expressions */ if (VIR_ALLOC_N(reg, nregex) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -1249,11 +1249,11 @@ virStorageBackendRunProgRegex(virConnectPtr conn, /* Storage for matched variables */ if (VIR_ALLOC_N(groups, totgroups) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (VIR_ALLOC_N(vars, maxvars+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -1289,7 +1289,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn, line[vars[j+1].rm_eo] = '\0'; if ((groups[ngroup++] = strdup(line + vars[j+1].rm_so)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -1388,7 +1388,7 @@ virStorageBackendRunProgNul(virConnectPtr conn, return -1; if (VIR_ALLOC_N(v, n_columns) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } for (i = 0; i < n_columns; i++) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 5ecf210..16eba4e 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -48,13 +48,13 @@ virStorageBackendDiskMakeDataVol(virConnectPtr conn, if (vol == NULL) { if (VIR_ALLOC(vol) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); virStorageVolDefFree(vol); return -1; } @@ -65,14 +65,14 @@ virStorageBackendDiskMakeDataVol(virConnectPtr conn, */ tmp = strrchr(groups[0], '/'); if ((vol->name = strdup(tmp ? tmp + 1 : groups[0])) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } if (vol->target.path == NULL) { if ((devpath = strdup(groups[0])) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -91,14 +91,14 @@ virStorageBackendDiskMakeDataVol(virConnectPtr conn, if (vol->key == NULL) { /* XXX base off a unique key of the underlying disk */ if ((vol->key = strdup(vol->target.path)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } if (vol->source.extents == NULL) { if (VIR_ALLOC(vol->source.extents) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } vol->source.nextent = 1; @@ -119,7 +119,7 @@ virStorageBackendDiskMakeDataVol(virConnectPtr conn, if ((vol->source.extents[0].path = strdup(pool->def->source.devices[0].path)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 0d1c7a7..47cdd6a 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -99,7 +99,7 @@ virStorageBackendProbeTarget(virConnectPtr conn, if (encryption != NULL && meta.encrypted) { if (VIR_ALLOC(*encryption) < 0) { - virReportOOMError(conn); + virReportOOMError(); if (backingStore) VIR_FREE(*backingStore); return -1; @@ -166,7 +166,7 @@ virStorageBackendFileSystemNetFindPoolSourcesFunc(virConnectPtr conn, if (!(src->host.name = strdup(state->host)) || !(src->dir = strdup(path))) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } src->format = VIR_STORAGE_POOL_NETFS_NFS; @@ -228,7 +228,7 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn, retval = virStoragePoolSourceListFormat(conn, &state.list); if (retval == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -381,20 +381,20 @@ virStorageBackendFileSystemMount(virConnectPtr conn, if (pool->def->type == VIR_STORAGE_POOL_NETFS) { if (pool->def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS) { if (virAsprintf(&options, "direct-io-mode=1") == -1) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } if (virAsprintf(&src, "%s:%s", pool->def->source.host.name, pool->def->source.dir) == -1) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } else { if ((src = strdup(pool->def->source.devices[0].path)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } @@ -510,7 +510,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn, char *p; if ((parent = strdup(pool->def->target.path)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto error; } if (!(p = strrchr(parent, '/'))) { @@ -676,7 +676,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); /* fallthrough */ cleanup: @@ -746,7 +746,7 @@ virStorageBackendFileSystemDelete(virConnectPtr conn, * function), and can drop the parent pool lock during the (slow) allocation. */ static int -virStorageBackendFileSystemVolCreate(virConnectPtr conn, +virStorageBackendFileSystemVolCreate(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, virStorageVolDefPtr vol) { @@ -757,14 +757,14 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn, if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, vol->name) == -1) { - virReportOOMError(conn); + virReportOOMError(); return -1; } VIR_FREE(vol->key); vol->key = strdup(vol->target.path); if (vol->key == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -914,7 +914,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn, if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 || VIR_ALLOC(encsec) < 0) { VIR_FREE(vol->target.encryption->secrets); - virReportOOMError(conn); + virReportOOMError(); virSecretFree(sec); return -1; } diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 0d3c7b1..74e63f3 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -90,7 +90,7 @@ virStorageBackendISCSITargetIP(virConnectPtr conn, } static int -virStorageBackendISCSIExtractSession(virConnectPtr conn, +virStorageBackendISCSIExtractSession(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, char **const groups, void *data) @@ -99,7 +99,7 @@ virStorageBackendISCSIExtractSession(virConnectPtr conn, if (STREQ(groups[1], pool->def->source.devices[0].path)) { if ((*session = strdup(groups[0])) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } @@ -223,7 +223,7 @@ virStorageBackendIQNFound(virConnectPtr conn, *ifacename = strdup(token); if (*ifacename == NULL) { ret = IQN_ERROR; - virReportOOMError(conn); + virReportOOMError(); goto out; } VIR_DEBUG("Found interface '%s' with IQN '%s'", *ifacename, iqn); @@ -487,7 +487,7 @@ virStorageBackendISCSIPortal(virConnectPtr conn, return NULL; if (VIR_ALLOC_N(portal, strlen(ipaddr) + 1 + 4 + 2 + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index c2e74a5..8caf8cb 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -85,21 +85,21 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn, /* Or a completely new volume */ if (vol == NULL) { if (VIR_ALLOC(vol) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } vol->type = VIR_STORAGE_VOL_BLOCK; if ((vol->name = strdup(groups[0])) == NULL) { - virReportOOMError(conn); + virReportOOMError(); virStorageVolDefFree(vol); return -1; } if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1)) { - virReportOOMError(conn); + virReportOOMError(); virStorageVolDefFree(vol); return -1; } @@ -109,7 +109,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn, if (vol->target.path == NULL) { if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, vol->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); virStorageVolDefFree(vol); return -1; } @@ -118,7 +118,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn, if (groups[1] && !STREQ(groups[1], "")) { if (virAsprintf(&vol->backingStore.path, "%s/%s", pool->def->target.path, groups[1]) < 0) { - virReportOOMError(conn); + virReportOOMError(); virStorageVolDefFree(vol); return -1; } @@ -128,7 +128,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn, if (vol->key == NULL && (vol->key = strdup(groups[2])) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -139,13 +139,13 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn, /* Finally fill in extents information */ if (VIR_REALLOC_N(vol->source.extents, vol->source.nextent + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } if ((vol->source.extents[vol->source.nextent].path = strdup(groups[3])) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -266,7 +266,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn, vgname = strdup(groups[1]); if (pvname == NULL || vgname == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto err_no_memory; } @@ -289,7 +289,7 @@ virStorageBackendLogicalFindPoolSourcesFunc(virConnectPtr conn, VIR_FREE(vgname); if (VIR_REALLOC_N(thisSource->devices, thisSource->ndevice + 1) != 0) { - virReportOOMError(conn); + virReportOOMError(); goto err_no_memory; } @@ -390,7 +390,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn, memset(zeros, 0, sizeof(zeros)); if (VIR_ALLOC_N(vgargv, 3 + pool->def->source.ndevice) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -603,7 +603,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, if (virAsprintf(&vol->target.path, "%s/%s", pool->def->target.path, vol->name) == -1) { - virReportOOMError(conn); + virReportOOMError(); return -1; } diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index fcc38ba..029ff3b 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -98,19 +98,19 @@ virStorageBackendMpathNewVol(virConnectPtr conn, int ret = -1; if (VIR_ALLOC(vol) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } vol->type = VIR_STORAGE_VOL_BLOCK; if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -128,13 +128,13 @@ virStorageBackendMpathNewVol(virConnectPtr conn, /* XXX should use logical unit's UUID instead */ vol->key = strdup(vol->target.path); if (vol->key == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } pool->volumes.objs[pool->volumes.count++] = vol; @@ -253,7 +253,7 @@ virStorageBackendCreateVols(virConnectPtr conn, if (is_mpath == 1) { if (virAsprintf(&map_device, "mapper/%s", names->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto out; } diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 4b181d7..1405f10 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -55,7 +55,7 @@ getDeviceType(virConnectPtr conn, if (virAsprintf(&type_path, "/sys/bus/scsi/devices/%u:%u:%u:%u/type", host, bus, target, lun) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto out; } @@ -206,7 +206,7 @@ virStorageBackendSCSINewLun(virConnectPtr conn, int retval = 0; if (VIR_ALLOC(vol) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto out; } @@ -214,13 +214,13 @@ virStorageBackendSCSINewLun(virConnectPtr conn, vol->type = VIR_STORAGE_VOL_BLOCK; if (virAsprintf(&(vol->name), "%u.%u.%u.%u", host, bus, target, lun) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto free_vol; } if (virAsprintf(&devpath, "/dev/%s", dev) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto free_vol; } @@ -266,7 +266,7 @@ virStorageBackendSCSINewLun(virConnectPtr conn, /* XXX should use logical unit's UUID instead */ vol->key = strdup(vol->target.path); if (vol->key == NULL) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto free_vol; } @@ -276,7 +276,7 @@ virStorageBackendSCSINewLun(virConnectPtr conn, if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto free_vol; } @@ -304,7 +304,7 @@ getNewStyleBlockDevice(virConnectPtr conn, int retval = 0; if (virAsprintf(&block_path, "%s/block", lun_path) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto out; } @@ -328,7 +328,7 @@ getNewStyleBlockDevice(virConnectPtr conn, *block_device = strdup(block_dirent->d_name); if (*block_device == NULL) { - virReportOOMError(conn); + virReportOOMError(); closedir(block_dir); retval = -1; goto out; @@ -369,7 +369,7 @@ getOldStyleBlockDevice(virConnectPtr conn, *block_device = strdup(blockp); if (*block_device == NULL) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto out; } @@ -397,7 +397,7 @@ getBlockDevice(virConnectPtr conn, if (virAsprintf(&lun_path, "/sys/bus/scsi/devices/%u:%u:%u:%u", host, bus, target, lun) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto out; } @@ -512,7 +512,7 @@ virStorageBackendSCSIFindLUs(virConnectPtr conn, virFileWaitForDevices(conn); if (virAsprintf(&device_path, "/sys/bus/scsi/devices") < 0) { - virReportOOMError(conn); + virReportOOMError(); goto out; } @@ -596,7 +596,7 @@ virStorageBackendSCSITriggerRescan(virConnectPtr conn, VIR_DEBUG(_("Triggering rescan of host %d"), host); if (virAsprintf(&path, "/sys/class/scsi_host/host%u/scan", host) < 0) { - virReportOOMError(conn); + virReportOOMError(); retval = -1; goto out; } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 37be77d..0c805da 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -172,7 +172,7 @@ storageDriverStartup(int privileged) { return 0; out_of_memory: - virReportOOMError(NULL); + virReportOOMError(); error: VIR_FREE(base); storageDriverUnlock(driverState); @@ -358,7 +358,7 @@ storageListPools(virConnectPtr conn, if (virStoragePoolObjIsActive(driver->pools.objs[i])) { if (!(names[got] = strdup(driver->pools.objs[i]->def->name))) { virStoragePoolObjUnlock(driver->pools.objs[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } got++; @@ -406,7 +406,7 @@ storageListDefinedPools(virConnectPtr conn, if (!virStoragePoolObjIsActive(driver->pools.objs[i])) { if (!(names[got] = strdup(driver->pools.objs[i]->def->name))) { virStoragePoolObjUnlock(driver->pools.objs[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } got++; @@ -1104,7 +1104,7 @@ storagePoolListVolumes(virStoragePoolPtr obj, for (i = 0 ; i < pool->volumes.count && n < maxnames ; i++) { if ((names[n++] = strdup(pool->volumes.objs[i]->name)) == NULL) { - virReportOOMError(obj->conn); + virReportOOMError(); goto cleanup; } } @@ -1288,7 +1288,7 @@ storageVolumeCreateXML(virStoragePoolPtr obj, if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count+1) < 0) { - virReportOOMError(obj->conn); + virReportOOMError(); goto cleanup; } @@ -1312,7 +1312,7 @@ storageVolumeCreateXML(virStoragePoolPtr obj, virStorageVolDefPtr buildvoldef = NULL; if (VIR_ALLOC(buildvoldef) < 0) { - virReportOOMError(obj->conn); + virReportOOMError(); voldef = NULL; goto cleanup; } @@ -1457,7 +1457,7 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj, if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count+1) < 0) { - virReportOOMError(obj->conn); + virReportOOMError(); goto cleanup; } @@ -1737,7 +1737,7 @@ storageVolumeGetPath(virStorageVolPtr obj) { ret = strdup(vol->target.path); if (ret == NULL) - virReportOOMError(obj->conn); + virReportOOMError(); cleanup: if (pool) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2122a1b..52e8eec 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -208,7 +208,7 @@ testBuildCapabilities(virConnectPtr conn) { return caps; no_memory: - virReportOOMError(conn); + virReportOOMError(); virCapabilitiesFree(caps); return NULL; } @@ -301,8 +301,7 @@ static const char *defaultNodeXML = static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ull); static const unsigned long long defaultPoolAlloc = 0; -static int testStoragePoolObjSetDefaults(virConnectPtr conn, - virStoragePoolObjPtr pool); +static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool); static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); static char * @@ -316,7 +315,7 @@ testDomainGenerateIfname(virConnectPtr conn, int found = 0; if (virAsprintf(&ifname, "testnet%d", ifctr) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -423,12 +422,12 @@ testDomainUpdateVCPUs(virConnectPtr conn, cpumaplen = VIR_CPU_MAPLEN(maxcpu); if (VIR_REALLOC_N(privdata->vcpu_infos, nvcpus) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (VIR_REALLOC_N(privdata->cpumaps, nvcpus * cpumaplen) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -501,7 +500,7 @@ static int testOpenDefault(virConnectPtr conn) { virNodeDeviceObjPtr nodeobj = NULL; if (VIR_ALLOC(privconn) < 0) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } if (virMutexInit(&privconn->lock) < 0) { @@ -587,7 +586,7 @@ static int testOpenDefault(virConnectPtr conn) { goto error; } - if (testStoragePoolObjSetDefaults(conn, poolobj) == -1) { + if (testStoragePoolObjSetDefaults(poolobj) == -1) { virStoragePoolObjUnlock(poolobj); goto error; } @@ -662,7 +661,7 @@ static int testOpenVolumesForPool(virConnectPtr conn, /* Find storage volumes */ if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", poolidx) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -698,20 +697,20 @@ static int testOpenVolumesForPool(virConnectPtr conn, if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } if (virAsprintf(&def->target.path, "%s/%s", pool->def->target.path, def->name) == -1) { - virReportOOMError(conn); + virReportOOMError(); goto error; } def->key = strdup(def->target.path); if (def->key == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -746,7 +745,7 @@ static int testOpenFromFile(virConnectPtr conn, virDomainObjPtr dom; testConnPtr privconn; if (VIR_ALLOC(privconn) < 0) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } if (virMutexInit(&privconn->lock) < 0) { @@ -1026,7 +1025,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - if (testStoragePoolObjSetDefaults(conn, pool) == -1) { + if (testStoragePoolObjSetDefaults(pool) == -1) { virStoragePoolObjUnlock(pool); goto error; } @@ -1142,7 +1141,7 @@ static virDrvOpenStatus testOpen(virConnectPtr conn, /* Init callback list */ if (VIR_ALLOC(privconn->domainEventCallbacks) < 0 || !(privconn->domainEventQueue = virDomainEventQueueNew())) { - virReportOOMError(NULL); + virReportOOMError(); testDriverUnlock(privconn); testClose(conn); return VIR_DRV_OPEN_ERROR; @@ -1222,7 +1221,7 @@ static char *testGetCapabilities (virConnectPtr conn) char *xml; testDriverLock(privconn); if ((xml = virCapabilitiesFormatXML(privconn->caps)) == NULL) - virReportOOMError(conn); + virReportOOMError(); testDriverUnlock(privconn); return xml; } @@ -1826,7 +1825,7 @@ static int testDomainRestore(virConnectPtr conn, goto cleanup; } if (VIR_ALLOC_N(xml, len+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (saferead(fd, xml, len) != len) { @@ -1935,10 +1934,10 @@ cleanup: return ret; } -static char *testGetOSType(virDomainPtr dom) { +static char *testGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) { char *ret = strdup("linux"); if (!ret) - virReportOOMError(dom->conn); + virReportOOMError(); return ret; } @@ -2481,7 +2480,7 @@ cleanup: return ret; } -static char *testDomainGetSchedulerType(virDomainPtr domain, +static char *testDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams) { char *type = NULL; @@ -2489,7 +2488,7 @@ static char *testDomainGetSchedulerType(virDomainPtr domain, *nparams = 1; type = strdup("fair"); if (!type) - virReportOOMError(domain->conn); + virReportOOMError(); return type; } @@ -2783,7 +2782,7 @@ static int testListNetworks(virConnectPtr conn, char **const names, int nnames) return n; no_memory: - virReportOOMError(conn); + virReportOOMError(); for (n = 0 ; n < nnames ; n++) VIR_FREE(names[n]); testDriverUnlock(privconn); @@ -2826,7 +2825,7 @@ static int testListDefinedNetworks(virConnectPtr conn, char **const names, int n return n; no_memory: - virReportOOMError(conn); + virReportOOMError(); for (n = 0 ; n < nnames ; n++) VIR_FREE(names[n]); testDriverUnlock(privconn); @@ -3064,7 +3063,7 @@ static char *testNetworkGetBridgeName(virNetworkPtr network) { } if (!(bridge = strdup(privnet->def->bridge))) { - virReportOOMError(network->conn); + virReportOOMError(); goto cleanup; } @@ -3186,7 +3185,7 @@ static int testListInterfaces(virConnectPtr conn, char **const names, int nnames return n; no_memory: - virReportOOMError(conn); + virReportOOMError(); for (n = 0 ; n < nnames ; n++) VIR_FREE(names[n]); testDriverUnlock(privconn); @@ -3232,7 +3231,7 @@ static int testListDefinedInterfaces(virConnectPtr conn, char **const names, int return n; no_memory: - virReportOOMError(conn); + virReportOOMError(); for (n = 0 ; n < nnames ; n++) VIR_FREE(names[n]); testDriverUnlock(privconn); @@ -3460,8 +3459,7 @@ cleanup: */ -static int testStoragePoolObjSetDefaults(virConnectPtr conn, - virStoragePoolObjPtr pool) { +static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) { pool->def->capacity = defaultPoolCap; pool->def->allocation = defaultPoolAlloc; @@ -3469,7 +3467,7 @@ static int testStoragePoolObjSetDefaults(virConnectPtr conn, pool->configFile = strdup("\0"); if (!pool->configFile) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -3582,7 +3580,7 @@ testStorageListPools(virConnectPtr conn, return n; no_memory: - virReportOOMError(conn); + virReportOOMError(); for (n = 0 ; n < nnames ; n++) VIR_FREE(names[n]); testDriverUnlock(privconn); @@ -3629,7 +3627,7 @@ testStorageListDefinedPools(virConnectPtr conn, return n; no_memory: - virReportOOMError(conn); + virReportOOMError(); for (n = 0 ; n < nnames ; n++) VIR_FREE(names[n]); testDriverUnlock(privconn); @@ -3741,7 +3739,7 @@ testStorageFindPoolSources(virConnectPtr conn, case VIR_STORAGE_POOL_LOGICAL: ret = strdup(defaultPoolSourcesLogicalXML); if (!ret) - virReportOOMError(conn); + virReportOOMError(); break; case VIR_STORAGE_POOL_NETFS: @@ -3753,7 +3751,7 @@ testStorageFindPoolSources(virConnectPtr conn, if (virAsprintf(&ret, defaultPoolSourcesNetFSXML, source->host.name) < 0) - virReportOOMError(conn); + virReportOOMError(); break; default: @@ -3793,7 +3791,7 @@ testStoragePoolCreate(virConnectPtr conn, goto cleanup; def = NULL; - if (testStoragePoolObjSetDefaults(conn, pool) == -1) { + if (testStoragePoolObjSetDefaults(pool) == -1) { virStoragePoolObjRemove(&privconn->pools, pool); pool = NULL; goto cleanup; @@ -3831,7 +3829,7 @@ testStoragePoolDefine(virConnectPtr conn, goto cleanup; def = NULL; - if (testStoragePoolObjSetDefaults(conn, pool) == -1) { + if (testStoragePoolObjSetDefaults(pool) == -1) { virStoragePoolObjRemove(&privconn->pools, pool); pool = NULL; goto cleanup; @@ -4190,7 +4188,7 @@ testStoragePoolListVolumes(virStoragePoolPtr pool, for (i = 0 ; i < privpool->volumes.count && n < maxnames ; i++) { if ((names[n++] = strdup(privpool->volumes.objs[i]->name)) == NULL) { - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } } @@ -4366,20 +4364,20 @@ testStorageVolumeCreateXML(virStoragePoolPtr pool, if (VIR_REALLOC_N(privpool->volumes.objs, privpool->volumes.count+1) < 0) { - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } if (virAsprintf(&privvol->target.path, "%s/%s", privpool->def->target.path, privvol->name) == -1) { - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } privvol->key = strdup(privvol->target.path); if (privvol->key == NULL) { - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } @@ -4457,20 +4455,20 @@ testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool, if (VIR_REALLOC_N(privpool->volumes.objs, privpool->volumes.count+1) < 0) { - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } if (virAsprintf(&privvol->target.path, "%s/%s", privpool->def->target.path, privvol->name) == -1) { - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } privvol->key = strdup(privvol->target.path); if (privvol->key == NULL) { - virReportOOMError(pool->conn); + virReportOOMError(); goto cleanup; } @@ -4691,7 +4689,7 @@ testStorageVolumeGetPath(virStorageVolPtr vol) { ret = strdup(privvol->target.path); if (ret == NULL) - virReportOOMError(vol->conn); + virReportOOMError(); cleanup: if (privpool) @@ -4842,7 +4840,7 @@ testNodeDeviceGetParent(virNodeDevicePtr dev) if (obj->def->parent) { ret = strdup(obj->def->parent); if (!ret) - virReportOOMError(dev->conn); + virReportOOMError(); } else { virNodeDeviceReportError(dev->conn, VIR_ERR_INTERNAL_ERROR, "%s", _("no parent for this device")); @@ -4961,7 +4959,7 @@ testNodeDeviceCreateXML(virConnectPtr conn, * we don't have. Use WWPN instead. */ VIR_FREE(def->name); if (!(def->name = strdup(wwpn))) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -5017,7 +5015,7 @@ testNodeDeviceDestroy(virNodeDevicePtr dev) parent_name = strdup(obj->def->parent); if (parent_name == NULL) { - virReportOOMError(dev->conn); + virReportOOMError(); goto out; } diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 895a94d..d0aa219 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -152,7 +152,7 @@ umlConnectTapDevice(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: brShutdown(brctl); return -1; @@ -257,7 +257,7 @@ umlBuildCommandLineNet(virConnectPtr conn, } if (virBufferError(&buf)) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -278,14 +278,14 @@ umlBuildCommandLineChr(virConnectPtr conn, switch (def->type) { case VIR_DOMAIN_CHR_TYPE_NULL: if (virAsprintf(&ret, "%s%d=null", dev, def->target.port) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } break; case VIR_DOMAIN_CHR_TYPE_PTY: if (virAsprintf(&ret, "%s%d=pts", dev, def->target.port) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } break; @@ -293,14 +293,14 @@ umlBuildCommandLineChr(virConnectPtr conn, case VIR_DOMAIN_CHR_TYPE_DEV: if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->target.port, def->data.file.path) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } break; case VIR_DOMAIN_CHR_TYPE_STDIO: if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->target.port) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } break; @@ -314,7 +314,7 @@ umlBuildCommandLineChr(virConnectPtr conn, if (virAsprintf(&ret, "%s%d=port:%s", dev, def->target.port, def->data.tcp.service) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } break; @@ -534,7 +534,7 @@ int umlBuildCommandLine(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: if (qargv) { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 31cea5c..2152dbf 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -189,8 +189,7 @@ umlAutostartConfigs(struct uml_driver *driver) { static int -umlIdentifyOneChrPTY(virConnectPtr conn, - struct uml_driver *driver, +umlIdentifyOneChrPTY(struct uml_driver *driver, virDomainObjPtr dom, virDomainChrDefPtr def, const char *dev) @@ -199,7 +198,7 @@ umlIdentifyOneChrPTY(virConnectPtr conn, char *res = NULL; int retries = 0; if (virAsprintf(&cmd, "config %s%d", dev, def->target.port) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } requery: @@ -209,7 +208,7 @@ requery: if (res && STRPREFIX(res, "pts:")) { VIR_FREE(def->data.file.path); if ((def->data.file.path = strdup(res + 4)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); VIR_FREE(res); VIR_FREE(cmd); return -1; @@ -231,21 +230,20 @@ requery: } static int -umlIdentifyChrPTY(virConnectPtr conn, - struct uml_driver *driver, +umlIdentifyChrPTY(struct uml_driver *driver, virDomainObjPtr dom) { int i; if (dom->def->console && dom->def->console->type == VIR_DOMAIN_CHR_TYPE_PTY) - if (umlIdentifyOneChrPTY(conn, driver, dom, + if (umlIdentifyOneChrPTY(driver, dom, dom->def->console, "con") < 0) return -1; for (i = 0 ; i < dom->def->nserials; i++) if (dom->def->serials[i]->type == VIR_DOMAIN_CHR_TYPE_PTY && - umlIdentifyOneChrPTY(conn, driver, dom, + umlIdentifyOneChrPTY(driver, dom, dom->def->serials[i], "ssl") < 0) return -1; @@ -326,7 +324,7 @@ reread: if (umlOpenMonitor(NULL, driver, dom) < 0) { VIR_WARN0("Could not open monitor for new domain"); umlShutdownVMDaemon(NULL, driver, dom); - } else if (umlIdentifyChrPTY(NULL, driver, dom) < 0) { + } else if (umlIdentifyChrPTY(driver, dom) < 0) { VIR_WARN0("Could not identify charater devices for new domain"); umlShutdownVMDaemon(NULL, driver, dom); } @@ -573,7 +571,7 @@ static int umlReadPidFile(virConnectPtr conn, vm->pid = -1; if (virAsprintf(&pidfile, "%s/%s/pid", driver->monitorDir, vm->def->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -616,7 +614,7 @@ static int umlMonitorAddress(virConnectPtr conn, if (virAsprintf(&sockname, "%s/%s/mconsole", driver->monitorDir, vm->def->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -749,7 +747,7 @@ static int umlMonitorCommand(virConnectPtr conn, } if (VIR_REALLOC_N(retdata, retlen + res.length) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } memcpy(retdata + retlen, res.data, res.length); @@ -849,7 +847,7 @@ static int umlStartVMDaemon(virConnectPtr conn, if (virAsprintf(&logfile, "%s/%s.log", driver->logDir, vm->def->name) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -976,7 +974,7 @@ static virDrvOpenStatus umlOpen(virConnectPtr conn, "uml:///system" : "uml:///session"); if (!conn->uri) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } } else { @@ -1053,7 +1051,7 @@ static char *umlGetCapabilities(virConnectPtr conn) { umlDriverLock(driver); if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL) - virReportOOMError(conn); + virReportOOMError(); umlDriverUnlock(driver); return xml; @@ -1376,7 +1374,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) { } if (!(type = strdup(vm->def->os.type))) - virReportOOMError(dom->conn); + virReportOOMError(); cleanup: if (vm) diff --git a/src/util/conf.c b/src/util/conf.c index 60cf0b4..24588c2 100644 --- a/src/util/conf.c +++ b/src/util/conf.c @@ -164,7 +164,7 @@ virConfNew(void) virConfPtr ret; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return(NULL); } ret->filename = NULL; @@ -216,7 +216,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm) return(NULL); if (VIR_ALLOC(ret) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return(NULL); } @@ -389,7 +389,7 @@ virConfParseString(virConfParserCtxtPtr ctxt) } ret = strndup(base, ctxt->cur - base); if (ret == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } NEXT; @@ -409,7 +409,7 @@ virConfParseString(virConfParserCtxtPtr ctxt) } ret = strndup(base, ctxt->cur - base); if (ret == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } ctxt->cur += 3; @@ -424,7 +424,7 @@ virConfParseString(virConfParserCtxtPtr ctxt) } ret = strndup(base, ctxt->cur - base); if (ret == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } NEXT; @@ -517,7 +517,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt) return(NULL); } if (VIR_ALLOC(ret) < 0) { - virReportOOMError(NULL); + virReportOOMError(); virConfFreeList(lst); VIR_FREE(str); return(NULL); @@ -558,7 +558,7 @@ virConfParseName(virConfParserCtxtPtr ctxt) NEXT; ret = strndup(base, ctxt->cur - base); if (ret == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return(NULL); } return(ret); @@ -585,7 +585,7 @@ virConfParseComment(virConfParserCtxtPtr ctxt) while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT; comm = strndup(base, ctxt->cur - base); if (comm == NULL) { - virReportOOMError(NULL); + virReportOOMError(); return(-1); } virConfAddEntry(ctxt->conf, NULL, NULL, comm); @@ -660,7 +660,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt) while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT; comm = strndup(base, ctxt->cur - base); if (comm == NULL) { - virReportOOMError(NULL); + virReportOOMError(); VIR_FREE(name); virConfFreeValue(value); return(-1); @@ -872,13 +872,13 @@ virConfSetValue (virConfPtr conf, if (!cur) { if (VIR_ALLOC(cur) < 0) { - virReportOOMError(NULL); + virReportOOMError(); virConfFreeValue(value); return (-1); } cur->comment = NULL; if (!(cur->name = strdup(setting))) { - virReportOOMError(NULL); + virReportOOMError(); virConfFreeValue(value); VIR_FREE(cur); return (-1); @@ -931,7 +931,7 @@ virConfWriteFile(const char *filename, virConfPtr conf) if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -987,7 +987,7 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf) if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(NULL); + virReportOOMError(); return -1; } diff --git a/src/util/hostusb.c b/src/util/hostusb.c index 71f6435..11a0426 100644 --- a/src/util/hostusb.c +++ b/src/util/hostusb.c @@ -69,7 +69,7 @@ static int usbSysReadFile(virConnectPtr conn, tmp = virAsprintf(&filename, USB_SYSFS "/devices/%s/%s", d_name, f_name); if (tmp < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -169,7 +169,7 @@ usbGetDevice(virConnectPtr conn, usbDevice *dev; if (VIR_ALLOC(dev) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } diff --git a/src/util/json.c b/src/util/json.c index 1b3c359..62bf8e2 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -1010,17 +1010,17 @@ char *virJSONValueToString(virJSONValuePtr object) g = yajl_gen_alloc(&conf, NULL); if (virJSONValueToStringOne(object, g) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (yajl_gen_get_buf(g, &str, &len) != yajl_gen_status_ok) { - virReportOOMError(NULL); + virReportOOMError(); goto cleanup; } if (!(ret = strdup((const char *)str))) - virReportOOMError(NULL); + virReportOOMError(); cleanup: yajl_gen_free(g); diff --git a/src/util/pci.c b/src/util/pci.c index 0274806..12e6e91 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -1016,7 +1016,7 @@ pciGetDevice(virConnectPtr conn, char *vendor, *product; if (VIR_ALLOC(dev) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1077,12 +1077,12 @@ unsigned pciDeviceGetManaged(pciDevice *dev) } pciDeviceList * -pciDeviceListNew(virConnectPtr conn) +pciDeviceListNew(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/) { pciDeviceList *list; if (VIR_ALLOC(list) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1120,7 +1120,7 @@ pciDeviceListAdd(virConnectPtr conn, } if (VIR_REALLOC_N(list->devs, list->count+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -1216,7 +1216,7 @@ int pciDeviceFileIterate(virConnectPtr conn, if (virAsprintf(&pcidir, "/sys/bus/pci/devices/%04x:%02x:%02x.%x", dev->domain, dev->bus, dev->slot, dev->function) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -1234,7 +1234,7 @@ int pciDeviceFileIterate(virConnectPtr conn, STRPREFIX(ent->d_name, "resource") || STREQ(ent->d_name, "rom")) { if (virAsprintf(&file, "%s/%s", pcidir, ent->d_name) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if ((actor)(conn, dev, file, opaque) < 0) diff --git a/src/util/processinfo.c b/src/util/processinfo.c index 397848e..66efa8b 100644 --- a/src/util/processinfo.c +++ b/src/util/processinfo.c @@ -56,7 +56,7 @@ realloc: mask = CPU_ALLOC(numcpus); if (!mask) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -122,7 +122,7 @@ realloc: mask = CPU_ALLOC(numcpus); if (!mask) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } diff --git a/src/util/qparams.c b/src/util/qparams.c index 9b96c2a..9535ca4 100644 --- a/src/util/qparams.c +++ b/src/util/qparams.c @@ -45,14 +45,14 @@ new_qparam_set (int init_alloc, ...) if (init_alloc <= 0) init_alloc = 1; if (VIR_ALLOC(ps) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } ps->n = 0; ps->alloc = init_alloc; if (VIR_ALLOC_N(ps->p, ps->alloc) < 0) { VIR_FREE (ps); - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -96,7 +96,7 @@ grow_qparam_set (struct qparam_set *ps) { if (ps->n >= ps->alloc) { if (VIR_REALLOC_N(ps->p, ps->alloc * 2) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } ps->alloc *= 2; @@ -113,14 +113,14 @@ append_qparam (struct qparam_set *ps, pname = strdup (name); if (!pname) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } pvalue = strdup (value); if (!pvalue) { VIR_FREE (pname); - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -155,7 +155,7 @@ qparam_get_query (const struct qparam_set *ps) if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -183,7 +183,7 @@ qparam_query_parse (const char *query) ps = new_qparam_set (0, NULL); if (!ps) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -256,7 +256,7 @@ qparam_query_parse (const char *query) return ps; out_of_memory: - virReportOOMError(NULL); + virReportOOMError(); free_qparam_set (ps); return NULL; } diff --git a/src/util/storage_file.c b/src/util/storage_file.c index 44057d2..1a490ba 100644 --- a/src/util/storage_file.c +++ b/src/util/storage_file.c @@ -139,7 +139,7 @@ static struct FileTypeInfo const fileTypeInfo[] = { }; static int -cowGetBackingStore(virConnectPtr conn, +cowGetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, char **res, const unsigned char *buf, size_t buf_size) @@ -153,14 +153,14 @@ cowGetBackingStore(virConnectPtr conn, *res = strndup ((const char*)buf + 4+4, COW_FILENAME_MAXLEN); if (*res == NULL) { - virReportOOMError(conn); + virReportOOMError(); return BACKING_STORE_ERROR; } return BACKING_STORE_OK; } static int -qcowXGetBackingStore(virConnectPtr conn, +qcowXGetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, char **res, const unsigned char *buf, size_t buf_size) @@ -192,7 +192,7 @@ qcowXGetBackingStore(virConnectPtr conn, if (size + 1 == 0) return BACKING_STORE_INVALID; if (VIR_ALLOC_N(*res, size + 1) < 0) { - virReportOOMError(conn); + virReportOOMError(); return BACKING_STORE_ERROR; } memcpy(*res, buf + offset, size); @@ -202,7 +202,7 @@ qcowXGetBackingStore(virConnectPtr conn, static int -vmdk4GetBackingStore(virConnectPtr conn, +vmdk4GetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, char **res, const unsigned char *buf, size_t buf_size) @@ -233,7 +233,7 @@ vmdk4GetBackingStore(virConnectPtr conn, *end = '\0'; *res = strdup(start); if (*res == NULL) { - virReportOOMError(conn); + virReportOOMError(); return BACKING_STORE_ERROR; } return BACKING_STORE_OK; @@ -381,7 +381,7 @@ virStorageFileGetMetadataFromFD(virConnectPtr conn, meta->backingStore = absolutePathFromBaseFile(path, base); VIR_FREE(base); if (meta->backingStore == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } } diff --git a/src/util/util.c b/src/util/util.c index 7e0cd50..d40a790 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -625,13 +625,13 @@ virExecWithHook(virConnectPtr conn, char *envp_str; if ((argv_str = virArgvToString(argv)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } if (envp) { if ((envp_str = virArgvToString(envp)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); return -1; } VIR_DEBUG("%s %s", envp_str, argv_str); @@ -774,7 +774,7 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd, buf = ((fds[i].fd == outfd) ? outbuf : errbuf); size = (*buf ? strlen(*buf) : 0); if (VIR_REALLOC_N(*buf, size+got+1) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } memmove(*buf+size, data, got); @@ -826,7 +826,7 @@ virRunWithHook(virConnectPtr conn, char *argv_str = NULL; if ((argv_str = virArgvToString(argv)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto error; } DEBUG0(argv_str); @@ -2187,7 +2187,7 @@ char *virIndexToDiskName(int idx, const char *prefix) offset = strlen(prefix); if (VIR_ALLOC_N(name, offset + i + 1)) { - virReportOOMError(NULL); + virReportOOMError(); return NULL; } @@ -2239,7 +2239,7 @@ char *virGetHostname(virConnectPtr conn) /* Caller frees this string. */ result = strdup (info->ai_canonname); if (!result) - virReportOOMError(conn); + virReportOOMError(); freeaddrinfo(info); return result; @@ -2355,7 +2355,7 @@ static char *virGetUserEnt(virConnectPtr conn, } if (VIR_ALLOC_N(strbuf, strbuflen) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2381,7 +2381,7 @@ static char *virGetUserEnt(virConnectPtr conn, VIR_FREE(strbuf); if (!ret) - virReportOOMError(conn); + virReportOOMError(); return ret; } @@ -2415,7 +2415,7 @@ int virGetUserID(virConnectPtr conn, } if (VIR_ALLOC_N(strbuf, strbuflen) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -2458,7 +2458,7 @@ int virGetGroupID(virConnectPtr conn, } if (VIR_ALLOC_N(strbuf, strbuflen) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } diff --git a/src/util/virterror.c b/src/util/virterror.c index d72b307..1454ea0 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -1250,7 +1250,6 @@ void virReportSystemErrorFull(virConnectPtr conn, /** * virReportOOMErrorFull: - * @conn: the hyperisor connection * @domcode: the virErrorDomain indicating where it's coming from * @filename: filename where error was raised * @funcname: function name where error was raised @@ -1259,8 +1258,7 @@ void virReportSystemErrorFull(virConnectPtr conn, * Convenience internal routine called when an out of memory error is * detected */ -void virReportOOMErrorFull(virConnectPtr conn, - int domcode, +void virReportOOMErrorFull(int domcode, const char *filename, const char *funcname, size_t linenr) @@ -1268,7 +1266,7 @@ void virReportOOMErrorFull(virConnectPtr conn, const char *virerr; virerr = virErrorMsg(VIR_ERR_NO_MEMORY, NULL); - virRaiseErrorFull(conn, filename, funcname, linenr, + virRaiseErrorFull(NULL, filename, funcname, linenr, domcode, VIR_ERR_NO_MEMORY, VIR_ERR_ERROR, virerr, NULL, NULL, -1, -1, virerr, NULL); } diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h index c713497..e4b644c 100644 --- a/src/util/virterror_internal.h +++ b/src/util/virterror_internal.h @@ -79,15 +79,13 @@ void virReportSystemErrorFull(virConnectPtr conn, __FILE__, __FUNCTION__, __LINE__, \ (fmt), __VA_ARGS__) -void virReportOOMErrorFull(virConnectPtr conn, - int domcode, +void virReportOOMErrorFull(int domcode, const char *filename, const char *funcname, size_t linenr); -#define virReportOOMError(conn) \ - virReportOOMErrorFull((conn), VIR_FROM_THIS, \ - __FILE__, __FUNCTION__, __LINE__) +#define virReportOOMError() \ + virReportOOMErrorFull(VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) int virSetError(virErrorPtr newerr); diff --git a/src/util/xml.c b/src/util/xml.c index 4fa443d..0338373 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -71,7 +71,7 @@ virXPathString(virConnectPtr conn, ret = strdup((char *) obj->stringval); xmlXPathFreeObject(obj); if (ret == NULL) { - virReportOOMError(conn); + virReportOOMError(); } return (ret); } @@ -504,7 +504,7 @@ virXPathNodeSet(virConnectPtr conn, ret = obj->nodesetval->nodeNr; if (list != NULL && ret) { if (VIR_ALLOC_N(*list, ret) < 0) { - virReportOOMError(conn); + virReportOOMError(); ret = -1; } else { memcpy(*list, obj->nodesetval->nodeTab, diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index e40c848..9f5e4ea 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -313,11 +313,11 @@ static bool vboxIIDEqual(vboxIID *firstIID, vboxIID *secondIID) { return false; } -static void vboxIIDtoUtf8(virConnectPtr conn, vboxIID *iid, char **uuidstr) { +static void vboxIIDtoUtf8(vboxIID *iid, char **uuidstr) { unsigned char hddUUID[VIR_UUID_BUFLEN]; if (VIR_ALLOC_N(*uuidstr, VIR_UUID_STRING_BUFLEN) < 0) { - virReportOOMError(conn); + virReportOOMError(); return; } @@ -325,11 +325,11 @@ static void vboxIIDtoUtf8(virConnectPtr conn, vboxIID *iid, char **uuidstr) { virUUIDFormat(hddUUID, *uuidstr); } -static void vboxUtf8toIID(virConnectPtr conn, char *uuidstr, vboxIID **iid) { +static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) { unsigned char hddUUID[VIR_UUID_BUFLEN]; if (VIR_ALLOC(*iid) < 0) { - virReportOOMError(conn); + virReportOOMError(); return; } @@ -394,16 +394,16 @@ static bool vboxIIDEqual(vboxIID *firstIID, vboxIID *secondIID) { return false; } -static void vboxIIDtoUtf8(virConnectPtr conn, vboxIID *iid, char **uuidstr) { +static void vboxIIDtoUtf8(vboxIID *iid, char **uuidstr) { g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(iid, uuidstr); if (!(*uuidstr)) - virReportOOMError(conn); + virReportOOMError(); } -static void vboxUtf8toIID(virConnectPtr conn, char *uuidstr, vboxIID **iid) { +static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) { g_pVBoxGlobalData->pFuncs->pfnUtf8ToUtf16(uuidstr, iid); if (!(*iid)) - virReportOOMError(conn); + virReportOOMError(); } #if VBOX_API_VERSION >= 3001 @@ -770,7 +770,7 @@ static virDrvOpenStatus vboxOpen(virConnectPtr conn, if (conn->uri == NULL) { conn->uri = xmlParseURI(uid ? "vbox:///session" : "vbox:///system"); if (conn->uri == NULL) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } } @@ -805,7 +805,7 @@ static virDrvOpenStatus vboxOpen(virConnectPtr conn, } if (VIR_ALLOC(data) < 0) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } @@ -823,7 +823,7 @@ static virDrvOpenStatus vboxOpen(virConnectPtr conn, #else /* !(VBOX_API_VERSION == 2002) */ if (VIR_ALLOC(data->domainEventCallbacks) < 0) { - virReportOOMError(conn); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } @@ -1313,7 +1313,7 @@ static int vboxDomainSuspend(virDomainPtr dom) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1370,7 +1370,7 @@ static int vboxDomainResume(virDomainPtr dom) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1430,7 +1430,7 @@ static int vboxDomainShutdown(virDomainPtr dom) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1487,7 +1487,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1540,7 +1540,7 @@ static int vboxDomainDestroy(virDomainPtr dom) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1592,7 +1592,7 @@ cleanup: return ret; } -static char *vboxDomainGetOSType(virDomainPtr dom) { +static char *vboxDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) { /* Returning "hvm" always as suggested on list, cause * this functions seems to be badly named and it * is supposed to pass the ABI name and not the domain @@ -1601,7 +1601,7 @@ static char *vboxDomainGetOSType(virDomainPtr dom) { char *osType = strdup("hvm"); if (osType == NULL) - virReportOOMError(dom->conn); + virReportOOMError(); return osType; } @@ -1616,7 +1616,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1788,7 +1788,7 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) { */ #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1840,7 +1840,7 @@ static int vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -1910,13 +1910,13 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif if (VIR_ALLOC(def) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } @@ -2079,11 +2079,11 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->videos[0]->accel->support3d = accelerate3DEnabled; def->videos[0]->accel->support2d = accelerate2DEnabled; } else - virReportOOMError(dom->conn); + virReportOOMError(); } else - virReportOOMError(dom->conn); + virReportOOMError(); } else - virReportOOMError(dom->conn); + virReportOOMError(); } /* dump display options vrdp/gui/sdl */ @@ -2132,7 +2132,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { if (valueDisplayUtf8) sdlDisplay = strdup(valueDisplayUtf8); if (sdlDisplay == NULL) { - virReportOOMError(dom->conn); + virReportOOMError(); /* just don't go to cleanup yet as it is ok to have * sdlDisplay as NULL and we check it below if it * exist and then only use it there @@ -2146,7 +2146,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { if (valueDisplayUtf8) guiDisplay = strdup(valueDisplayUtf8); if (guiDisplay == NULL) { - virReportOOMError(dom->conn); + virReportOOMError(); /* just don't go to cleanup yet as it is ok to have * guiDisplay as NULL and we check it below if it * exist and then only use it there @@ -2183,7 +2183,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP; def->graphics[def->ngraphics]->data.desktop.display = strdup(getenv("DISPLAY")); if (def->graphics[def->ngraphics]->data.desktop.display == NULL) { - virReportOOMError(dom->conn); + virReportOOMError(); /* just don't go to cleanup yet as it is ok to have * display as NULL */ @@ -2246,7 +2246,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->ngraphics++; } else - virReportOOMError(dom->conn); + virReportOOMError(); } VBOX_RELEASE(VRDPServer); } @@ -2278,7 +2278,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->disks[i]->bus = VIR_DOMAIN_DISK_BUS_IDE; def->disks[i]->type = VIR_DOMAIN_DISK_TYPE_FILE; } else - virReportOOMError(dom->conn); + virReportOOMError(); } } @@ -2372,13 +2372,13 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { if (VIR_ALLOC_N(def->disks, def->ndisks) >= 0) { for (i = 0; i < def->ndisks; i++) { if (VIR_ALLOC(def->disks[i]) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); error = true; break; } } } else { - virReportOOMError(dom->conn); + virReportOOMError(); error = true; } @@ -2431,7 +2431,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { if (!(def->disks[diskCount]->src)) { VBOX_RELEASE(medium); VBOX_RELEASE(storageController); - virReportOOMError(dom->conn); + virReportOOMError(); error = true; break; } @@ -2524,7 +2524,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { for (i = 0; i < def->nnets; i++) { if (VIR_ALLOC(def->nets[i]) >= 0) { } else - virReportOOMError(dom->conn); + virReportOOMError(); } } @@ -2663,11 +2663,11 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { } else { VIR_FREE(def->sounds); def->nsounds = 0; - virReportOOMError(dom->conn); + virReportOOMError(); } } else { def->nsounds = 0; - virReportOOMError(dom->conn); + virReportOOMError(); } } VBOX_RELEASE(audioAdapter); @@ -2702,11 +2702,11 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->disks[def->ndisks - 1]->dst = strdup("hdc"); } else { def->ndisks--; - virReportOOMError(dom->conn); + virReportOOMError(); } } else { def->ndisks--; - virReportOOMError(dom->conn); + virReportOOMError(); } VBOX_UTF8_FREE(location); @@ -2749,11 +2749,11 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->disks[def->ndisks - 1]->dst = strdup("fda"); } else { def->ndisks--; - virReportOOMError(dom->conn); + virReportOOMError(); } } else { def->ndisks--; - virReportOOMError(dom->conn); + virReportOOMError(); } VBOX_UTF8_FREE(location); @@ -2792,7 +2792,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { for (i = 0; i < def->nserials; i++) { if (VIR_ALLOC(def->serials[i]) >= 0) { } else - virReportOOMError(dom->conn); + virReportOOMError(); } } @@ -2876,7 +2876,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { for (i = 0; i < def->nparallels; i++) { if (VIR_ALLOC(def->parallels[i]) >= 0) { } else - virReportOOMError(dom->conn); + virReportOOMError(); } } @@ -2994,11 +2994,11 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { USBFilterCount++; } else - virReportOOMError(dom->conn); + virReportOOMError(); } } } else - virReportOOMError(dom->conn); + virReportOOMError(); } } @@ -3062,7 +3062,7 @@ static int vboxListDefinedDomains(virConnectPtr conn, char ** const names, int m machine->vtbl->GetName(machine, &machineNameUtf16); VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName); if (!(names[j++] = strdup(machineName))) { - virReportOOMError(conn); + virReportOOMError(); for ( ; j >= 0 ; j--) VIR_FREE(names[j]); ret = -1; @@ -3362,7 +3362,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } #endif @@ -4310,7 +4310,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { if (def->graphics[i]->data.desktop.display) { guiDisplay = strdup(def->graphics[i]->data.desktop.display); if (guiDisplay == NULL) { - virReportOOMError(conn); + virReportOOMError(); /* just don't go to cleanup yet as it is ok to have * guiDisplay as NULL and we check it below if it * exist and then only use it there @@ -4324,7 +4324,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { if (def->graphics[i]->data.sdl.display) { sdlDisplay = strdup(def->graphics[i]->data.sdl.display); if (sdlDisplay == NULL) { - virReportOOMError(conn); + virReportOOMError(); /* just don't go to cleanup yet as it is ok to have * sdlDisplay as NULL and we check it below if it * exist and then only use it there @@ -4526,7 +4526,7 @@ static int vboxDomainUndefine(virDomainPtr dom) { #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -4647,27 +4647,27 @@ static int vboxDomainAttachDevice(virDomainPtr dom, const char *xml) { nsresult rc; if (VIR_ALLOC(def) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); return ret; } def->os.type = strdup("hvm"); if (def->os.type == NULL) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } dev = virDomainDeviceDefParse(dom->conn, data->caps, def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -4845,27 +4845,27 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) { nsresult rc; if (VIR_ALLOC(def) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); return ret; } def->os.type = strdup("hvm"); if (def->os.type == NULL) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } dev = virDomainDeviceDefParse(dom->conn, data->caps, def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } #endif @@ -5251,14 +5251,14 @@ static nsresult vboxCallbackQueryInterface(nsISupports *pThis, const nsID *iid, } -static IVirtualBoxCallback *vboxAllocCallbackObj (virConnectPtr conn) { +static IVirtualBoxCallback *vboxAllocCallbackObj(void) { IVirtualBoxCallback *vboxCallback = NULL; /* Allocate, Initialize and return a validi * IVirtualBoxCallback object here */ if ((VIR_ALLOC(vboxCallback) < 0) || (VIR_ALLOC(vboxCallback->vtbl) < 0)) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -5317,7 +5317,7 @@ static int vboxDomainEventRegister (virConnectPtr conn, vboxDriverLock(data); if (data->vboxCallback == NULL) { - data->vboxCallback = vboxAllocCallbackObj(conn); + data->vboxCallback = vboxAllocCallbackObj(); if (data->vboxCallback != NULL) { rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback); if (NS_SUCCEEDED(rc)) { @@ -5612,7 +5612,7 @@ static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(iid) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } #endif @@ -5749,7 +5749,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char * if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", networkInterfaceNameUtf8) < 0) { VBOX_RELEASE(host); VBOX_RELEASE(networkInterface); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } } @@ -5877,7 +5877,7 @@ static int vboxNetworkUndefineDestroy(virNetworkPtr network, bool removeinterfac */ if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", network->name) < 0) { - virReportOOMError(network->conn); + virReportOOMError(); goto cleanup; } @@ -5967,7 +5967,7 @@ static int vboxNetworkCreate(virNetworkPtr network) { */ if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", network->name) < 0) { - virReportOOMError(network->conn); + virReportOOMError(); goto cleanup; } @@ -6035,12 +6035,12 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE char *networkNameUtf8 = NULL; if (VIR_ALLOC(def) < 0) { - virReportOOMError(network->conn); + virReportOOMError(); goto cleanup; } if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", network->name) < 0) { - virReportOOMError(network->conn); + virReportOOMError(); goto cleanup; } @@ -6099,7 +6099,7 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE VBOX_UTF16_FREE(toIPAddressUtf16); } else { def->nranges = 0; - virReportOOMError(network->conn); + virReportOOMError(); } def->nhosts = 1; @@ -6205,13 +6205,14 @@ static int vboxStorageNumOfPools(virConnectPtr conn ATTRIBUTE_UNUSED) { return 1; } -static int vboxStorageListPools(virConnectPtr conn, char **const names, int nnames) { +static int vboxStorageListPools(virConnectPtr conn ATTRIBUTE_UNUSED, + char **const names, int nnames) { int numActive = 0; if (nnames == 1) { names[numActive] = strdup("default-pool"); if (names[numActive] == NULL) { - virReportOOMError(conn); + virReportOOMError(); } else { numActive++; } @@ -6305,7 +6306,7 @@ static int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names DEBUG("nnames[%d]: %s", numActive, nameUtf8); names[numActive] = strdup(nameUtf8); if (names[numActive] == NULL) { - virReportOOMError(pool->conn); + virReportOOMError(); } else { numActive++; } @@ -6368,7 +6369,7 @@ static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID); if (hddIID) { - vboxIIDtoUtf8(pool->conn, hddIID, &hddIIDUtf8); + vboxIIDtoUtf8(hddIID, &hddIIDUtf8); vboxIIDUnalloc(hddIID); } @@ -6413,7 +6414,7 @@ static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char #if VBOX_API_VERSION == 2002 if (VIR_ALLOC(hddIID) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -6504,7 +6505,7 @@ static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const cha } if (hddIID) { - vboxIIDtoUtf8(conn, hddIID, &hddIIDUtf8); + vboxIIDtoUtf8(hddIID, &hddIIDUtf8); vboxIIDUnalloc(hddIID); } @@ -6609,7 +6610,7 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool, if (NS_SUCCEEDED(rc)) { char *hddKey = NULL; - vboxIIDtoUtf8(pool->conn, hddIID, &hddKey); + vboxIIDtoUtf8(hddIID, &hddKey); if (hddKey) ret = virGetStorageVol(pool->conn, pool->name, def->name, hddKey); @@ -6643,7 +6644,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, int i = 0; int j = 0; - vboxUtf8toIID(vol->conn, vol->key, &hddIID); + vboxUtf8toIID(vol->key, &hddIID); if (!hddIID) return ret; @@ -6772,7 +6773,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info if (!info) return ret; - vboxUtf8toIID(vol->conn, vol->key, &hddIID); + vboxUtf8toIID(vol->key, &hddIID); if (!hddIID) return ret; @@ -6821,7 +6822,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A memset(&pool, 0, sizeof(pool)); memset(&def, 0, sizeof(def)); - vboxUtf8toIID(vol->conn, vol->key, &hddIID); + vboxUtf8toIID(vol->key, &hddIID); if (!hddIID) return ret; @@ -6910,7 +6911,7 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) { vboxIID *hddIID = NULL; nsresult rc; - vboxUtf8toIID(vol->conn, vol->key, &hddIID); + vboxUtf8toIID(vol->key, &hddIID); if (!hddIID) return ret; @@ -6930,7 +6931,7 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) { ret = strdup(hddLocationUtf8); if (!ret) - virReportOOMError(vol->conn); + virReportOOMError(); DEBUG("Storage Volume Name: %s", vol->name); DEBUG("Storage Volume Path: %s", hddLocationUtf8); diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c index fdcaff7..8e699b1 100644 --- a/src/xen/block_stats.c +++ b/src/xen/block_stats.c @@ -295,7 +295,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path) retval = virAsprintf(&mod_path, "/dev/%s", path); if (retval < 0) { - virReportOOMError (conn); + virReportOOMError(); return -1; } diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c index bde3eda..e37bce1 100644 --- a/src/xen/proxy_internal.c +++ b/src/xen/proxy_internal.c @@ -939,7 +939,7 @@ xenProxyGetCapabilities (virConnectPtr conn) xmllen = ans.len - sizeof (virProxyPacket); if (VIR_ALLOC_N(xml, xmllen+1) < 0) { - virReportOOMError (conn); + virReportOOMError(); return NULL; } memmove (xml, ans.extra.str, xmllen); @@ -989,7 +989,7 @@ xenProxyDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED) } xmllen = ans.len - sizeof(virProxyPacket); if (VIR_ALLOC_N(xml, xmllen+1) < 0) { - virReportOOMError(domain->conn); + virReportOOMError(); return NULL; } memmove(xml, &ans.extra.dinfo, xmllen); @@ -1044,7 +1044,7 @@ xenProxyDomainGetOSType(virDomainPtr domain) } oslen = ans.len - sizeof(virProxyPacket); if (VIR_ALLOC_N(ostype, oslen+1) < 0) { - virReportOOMError(domain->conn); + virReportOOMError(); return NULL; } memmove(ostype, &ans.extra.dinfo, oslen); diff --git a/src/xen/sexpr.c b/src/xen/sexpr.c index 085500d..2455dfa 100644 --- a/src/xen/sexpr.c +++ b/src/xen/sexpr.c @@ -42,7 +42,7 @@ sexpr_new(void) struct sexpr *ret; if (VIR_ALLOC(ret) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return (NULL); } ret->kind = SEXPR_NIL; @@ -349,7 +349,7 @@ _string2sexpr(const char *buffer, size_t * end) ret->u.value = strndup(start, ptr - start); if (ret->u.value == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } @@ -365,7 +365,7 @@ _string2sexpr(const char *buffer, size_t * end) ret->u.value = strndup(start, ptr - start); if (ret->u.value == NULL) { - virReportOOMError(NULL); + virReportOOMError(); goto error; } } diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 72f56ae..c5da026 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -140,17 +140,17 @@ xenDomainUsedCpus(virDomainPtr dom) return(NULL); if (VIR_ALLOC_N(cpulist, priv->nbNodeCpus) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto done; } if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto done; } cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo)); if (xalloc_oversized(nb_vcpu, cpumaplen) || VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0) { - virReportOOMError(dom->conn); + virReportOOMError(); goto done; } @@ -246,7 +246,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags) conn->uri = xmlParseURI("xen:///"); if (!conn->uri) { - virReportOOMError (NULL); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } } else { @@ -292,7 +292,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags) /* Allocate per-connection private data. */ if (VIR_ALLOC(priv) < 0) { - virReportOOMError (NULL); + virReportOOMError(); return VIR_DRV_OPEN_ERROR; } if (virMutexInit(&priv->lock) < 0) { @@ -304,7 +304,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags) /* Allocate callback list */ if (VIR_ALLOC(cbList) < 0) { - virReportOOMError (NULL); + virReportOOMError(); virMutexDestroy(&priv->lock); VIR_FREE(priv); return VIR_DRV_OPEN_ERROR; @@ -546,7 +546,7 @@ xenUnifiedGetCapabilities (virConnectPtr conn) char *xml; if (!(xml = virCapabilitiesFormatXML(priv->caps))) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -816,7 +816,7 @@ xenUnifiedDomainisPersistent(virDomainPtr dom) virUUIDFormat(dom->uuid, uuidstr); if (virAsprintf(&path, "%s/%s", XEND_DOMAINS_DIR, uuidstr) < 0) { - virReportOOMError(NULL); + virReportOOMError(); goto done; } if (access(path, R_OK) == 0) @@ -1237,7 +1237,7 @@ xenUnifiedDomainXMLToNative(virConnectPtr conn, goto cleanup; if (VIR_ALLOC_N(ret, len) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -1948,7 +1948,7 @@ xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr list, list->count++; return 0; memory_error: - virReportOOMError (NULL); + virReportOOMError(); if (info) VIR_FREE(info->name); VIR_FREE(info); diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 16c91e1..13a5d3d 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -1173,14 +1173,14 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams) case XEN_SCHEDULER_SEDF: schedulertype = strdup("sedf"); if (schedulertype == NULL) - virReportOOMError(domain->conn); + virReportOOMError(); if (nparams) *nparams = 6; break; case XEN_SCHEDULER_CREDIT: schedulertype = strdup("credit"); if (schedulertype == NULL) - virReportOOMError(domain->conn); + virReportOOMError(); if (nparams) *nparams = 2; break; @@ -1727,7 +1727,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu, * for Xen, and also nr_cpus must be 'sizeof(uint64_t) * 8' */ if (maplen < 8) { if (VIR_ALLOC_N(new, sizeof(uint64_t)) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return (-1); } memcpy(new, cpumap, maplen); @@ -2052,7 +2052,7 @@ xenHypervisorInit(void) hypervisor_version = 2; if (VIR_ALLOC(ipt) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return(-1); } /* Currently consider RHEL5.0 Fedora7, xen-3.1, and xen-unstable */ @@ -2460,7 +2460,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn) utsname.machine, pae, hvm, guest_arches, i)) == NULL) - virReportOOMError(NULL); + virReportOOMError(); return caps; } @@ -2623,7 +2623,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn, return caps; no_memory: - virReportOOMError(NULL); + virReportOOMError(); virCapabilitiesFree(caps); return NULL; } @@ -2696,7 +2696,7 @@ xenHypervisorGetCapabilities (virConnectPtr conn) char *xml; if (!(xml = virCapabilitiesFormatXML(priv->caps))) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -2729,7 +2729,7 @@ xenHypervisorNumOfDomains(virConnectPtr conn) retry: if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { - virReportOOMError(conn); + virReportOOMError(); return(-1); } @@ -2790,7 +2790,7 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids) return(0); if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { - virReportOOMError(conn); + virReportOOMError(); return(-1); } @@ -2862,7 +2862,7 @@ xenHypervisorDomainGetOSType (virDomainPtr dom) ostype = strdup("linux"); if (ostype == NULL) - virReportOOMError(dom->conn); + virReportOOMError(); return ostype; } @@ -2940,7 +2940,7 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn, retry: if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { - virReportOOMError(conn); + virReportOOMError(); return(NULL); } diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c index d9dfbb7..2445b58 100644 --- a/src/xen/xen_inotify.c +++ b/src/xen/xen_inotify.c @@ -105,7 +105,7 @@ xenInotifyXenCacheLookup(virConnectPtr conn, if (!*name) { DEBUG0("Error getting dom from def"); - virReportOOMError(conn); + virReportOOMError(); return -1; } return 0; @@ -144,7 +144,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn, const char *filename, if (!memcmp(rawuuid, priv->configInfoList->doms[i]->uuid, VIR_UUID_BUFLEN)) { *name = strdup(priv->configInfoList->doms[i]->name); if (!*name) { - virReportOOMError(conn); + virReportOOMError(); return -1; } memcpy(uuid, priv->configInfoList->doms[i]->uuid, VIR_UUID_BUFLEN); @@ -158,7 +158,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn, const char *filename, } if (!(*name = strdup(dom->name))) { - virReportOOMError(conn); + virReportOOMError(); return -1; } memcpy(uuid, dom->uuid, VIR_UUID_BUFLEN); @@ -397,7 +397,7 @@ xenInotifyOpen(virConnectPtr conn, priv->useXenConfigCache = 0; if (VIR_ALLOC(priv->configInfoList) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 9c5127f..402a209 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -527,7 +527,7 @@ xend_op_ext(virConnectPtr xend, const char *path, char *error, if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -709,7 +709,7 @@ urlencode(const char *string) size_t i; if (VIR_ALLOC_N(buffer, len * 3 + 1) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return (NULL); } ptr = buffer; @@ -1061,7 +1061,7 @@ xenDaemonDomainLookupByID(virConnectPtr xend, if (domname) { *domname = strdup(name); if (*domname == NULL) { - virReportOOMError(xend); + virReportOOMError(); goto error; } } @@ -1210,7 +1210,7 @@ xenDaemonParseSxprOS(virConnectPtr xend, return 0; no_memory: - virReportOOMError(xend); + virReportOOMError(); return -1; } @@ -1421,7 +1421,7 @@ xend_parse_sexp_desc_char(virConnectPtr conn, if (ret == -1) { no_memory: - virReportOOMError(conn); + virReportOOMError(); } error: @@ -1445,7 +1445,7 @@ xenDaemonParseSxprChar(virConnectPtr conn, virDomainChrDefPtr def; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1573,7 +1573,7 @@ xenDaemonParseSxprChar(virConnectPtr conn, return def; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainChrDefFree(def); return NULL; @@ -1752,7 +1752,7 @@ xenDaemonParseSxprDisks(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainDiskDefFree(disk); @@ -1861,7 +1861,7 @@ xenDaemonParseSxprNets(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: virDomainNetDefFree(net); return -1; @@ -1941,15 +1941,14 @@ xenDaemonParseSxprSound(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: return -1; } static int -xenDaemonParseSxprUSB(virConnectPtr conn, - virDomainDefPtr def, +xenDaemonParseSxprUSB(virDomainDefPtr def, const struct sexpr *root) { struct sexpr *cur, *node; @@ -1985,7 +1984,7 @@ xenDaemonParseSxprUSB(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -2076,7 +2075,7 @@ xenDaemonParseSxprGraphicsOld(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); virDomainGraphicsDefFree(graphics); return -1; } @@ -2179,7 +2178,7 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainGraphicsDefFree(graphics); return -1; @@ -2303,7 +2302,7 @@ xenDaemonParseSxprPCI(virConnectPtr conn, return 0; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: virDomainHostdevDefFree(dev); @@ -2407,7 +2406,7 @@ xenDaemonParseSxpr(virConnectPtr conn, if (cpus != NULL) { def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN; if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -2567,7 +2566,7 @@ xenDaemonParseSxpr(virConnectPtr conn, /* in case of HVM we have USB device emulation */ if (hvm && - xenDaemonParseSxprUSB(conn, def, root) < 0) + xenDaemonParseSxprUSB(def, root) < 0) goto error; /* Character device config */ @@ -2620,7 +2619,7 @@ xenDaemonParseSxpr(virConnectPtr conn, return def; no_memory: - virReportOOMError(conn); + virReportOOMError(); error: VIR_FREE(tty); virDomainDefFree(def); @@ -2841,7 +2840,7 @@ sexpr_to_xend_topology(virConnectPtr conn, memory_error: VIR_FREE(cpuNums); VIR_FREE(cpuset); - virReportOOMError(conn); + virReportOOMError(); return (-1); } @@ -2962,7 +2961,7 @@ xenDaemonOpen(virConnectPtr conn, } else if (STRCASEEQ (conn->uri->scheme, "http")) { if (conn->uri->port && virAsprintf(&port, "%d", conn->uri->port) == -1) { - virReportOOMError(conn); + virReportOOMError(); goto failed; } @@ -3182,7 +3181,7 @@ xenDaemonDomainGetOSType(virDomainPtr domain) } if (type == NULL) - virReportOOMError(domain->conn); + virReportOOMError(); sexpr_free(root); @@ -3984,7 +3983,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid) name = strdup(*tmp); if (name == NULL) - virReportOOMError(conn); + virReportOOMError(); break; } @@ -4011,7 +4010,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid) name = strdup(domname); if (name == NULL) - virReportOOMError(conn); + virReportOOMError(); } sexpr_free(root); @@ -4364,7 +4363,7 @@ xenDaemonDomainSetAutostart(virDomainPtr domain, autonode->u.s.car->u.value = (autostart ? strdup("start") : strdup("ignore")); if (!(autonode->u.s.car->u.value)) { - virReportOOMError(domain->conn); + virReportOOMError(); goto error; } @@ -4516,7 +4515,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain, } hostname = strdup (uriptr->server); if (!hostname) { - virReportOOMError (conn); + virReportOOMError(); xmlFreeURI (uriptr); return -1; } @@ -4538,7 +4537,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain, n = p - uri; /* n = Length of hostname in bytes. */ hostname = strdup (uri); if (!hostname) { - virReportOOMError (conn); + virReportOOMError(); return -1; } hostname[n] = '\0'; @@ -4546,7 +4545,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain, else { /* "hostname" (or IP address) */ hostname = strdup (uri); if (!hostname) { - virReportOOMError (conn); + virReportOOMError(); return -1; } } @@ -4740,7 +4739,7 @@ xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames continue; if ((names[ret++] = strdup(node->u.value)) == NULL) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -4808,14 +4807,14 @@ xenDaemonGetSchedulerType(virDomainPtr domain, int *nparams) if (STREQ (ret, "credit")) { schedulertype = strdup("credit"); if (schedulertype == NULL){ - virReportOOMError(domain->conn); + virReportOOMError(); goto error; } *nparams = XEN_SCHED_CRED_NPARAM; } else if (STREQ (ret, "sedf")) { schedulertype = strdup("sedf"); if (schedulertype == NULL){ - virReportOOMError(domain->conn); + virReportOOMError(); goto error; } *nparams = XEN_SCHED_SEDF_NPARAM; @@ -5337,7 +5336,7 @@ xenDaemonFormatSxprChr(virConnectPtr conn, } if (virBufferError(buf)) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -5684,7 +5683,7 @@ xenDaemonFormatSxprSound(virConnectPtr conn, } if (virBufferError(buf)) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -5960,7 +5959,7 @@ xenDaemonFormatSxpr(virConnectPtr conn, virBufferAddLit(&buf, ")"); /* closes (vm */ if (virBufferError(&buf)) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -6050,7 +6049,7 @@ virDomainXMLDevID(virDomainPtr domain, def->source.subsys.u.pci.bus, def->source.subsys.u.pci.slot, def->source.subsys.u.pci.function) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 944d5d5..23e11d7 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -251,7 +251,7 @@ static int xenXMConfigCopyStringInternal(virConnectPtr conn, } if (!(*value = strdup(val->str))) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -432,7 +432,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename) } else { /* Completely new entry */ newborn = 1; if (VIR_ALLOC(entry) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } memcpy(entry->filename, filename, PATH_MAX); @@ -683,7 +683,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { const char *defaultArch, *defaultMachine; if (VIR_ALLOC(def) < 0) { - virReportOOMError(conn); + virReportOOMError(); return NULL; } @@ -1464,7 +1464,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { return def; no_memory: - virReportOOMError(conn); + virReportOOMError(); /* fallthrough */ cleanup: virDomainGraphicsDefFree(graphics); @@ -1745,7 +1745,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain, if (virBufferError(&mapbuf)) { virBufferFreeAndReset(&mapbuf); - virReportOOMError(domain->conn); + virReportOOMError(); goto cleanup; } @@ -1753,7 +1753,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain, mapsave = mapstr; if (VIR_ALLOC_N(cpuset, maxcpu) < 0) { - virReportOOMError(domain->conn); + virReportOOMError(); goto cleanup; } if (virDomainCpuSetParse(domain->conn, @@ -1934,7 +1934,7 @@ int xenXMConfigSetInt(virConfPtr conf, const char *setting, long l) { virConfValuePtr value = NULL; if (VIR_ALLOC(value) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1951,7 +1951,7 @@ int xenXMConfigSetString(virConfPtr conf, const char *setting, const char *str) virConfValuePtr value = NULL; if (VIR_ALLOC(value) < 0) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -1959,7 +1959,7 @@ int xenXMConfigSetString(virConfPtr conf, const char *setting, const char *str) value->next = NULL; if (!(value->str = strdup(str))) { VIR_FREE(value); - virReportOOMError(NULL); + virReportOOMError(); return -1; } @@ -2014,12 +2014,12 @@ static int xenXMDomainConfigFormatDisk(virConnectPtr conn, virBufferAddLit(&buf, ",w"); if (virBufferError(&buf)) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (VIR_ALLOC(val) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -2124,12 +2124,12 @@ static int xenXMDomainConfigFormatNet(virConnectPtr conn, net->ifname); if (virBufferError(&buf)) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } if (VIR_ALLOC(val) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -2153,8 +2153,7 @@ cleanup: static int -xenXMDomainConfigFormatPCI(virConnectPtr conn, - virConfPtr conf, +xenXMDomainConfigFormatPCI(virConfPtr conf, virDomainDefPtr def) { @@ -2171,7 +2170,7 @@ xenXMDomainConfigFormatPCI(virConnectPtr conn, return 0; if (VIR_ALLOC(pciVal) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -2189,13 +2188,13 @@ xenXMDomainConfigFormatPCI(virConnectPtr conn, def->hostdevs[i]->source.subsys.u.pci.bus, def->hostdevs[i]->source.subsys.u.pci.slot, def->hostdevs[i]->source.subsys.u.pci.function) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } if (VIR_ALLOC(val) < 0) { VIR_FREE(buf); - virReportOOMError(conn); + virReportOOMError(); goto error; } val->type = VIR_CONF_STRING; @@ -2550,7 +2549,7 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn, } VIR_FREE(netVal); - if (xenXMDomainConfigFormatPCI(conn, conf, def) < 0) + if (xenXMDomainConfigFormatPCI(conf, def) < 0) goto cleanup; if (hvm) { @@ -2608,7 +2607,7 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn, return conf; no_memory: - virReportOOMError(conn); + virReportOOMError(); cleanup: virConfFreeValue(diskVal); @@ -2726,7 +2725,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) { goto error; if (VIR_ALLOC(entry) < 0) { - virReportOOMError(conn); + virReportOOMError(); goto error; } @@ -2875,7 +2874,7 @@ int xenXMListDefinedDomains(virConnectPtr conn, char **const names, int maxnames for (i = 0; i < ctx.count; i++) VIR_FREE(ctx.names[i]); - virReportOOMError(conn); + virReportOOMError(); goto cleanup; } @@ -2962,7 +2961,7 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) { case VIR_DOMAIN_DEVICE_DISK: { if (virDomainDiskInsert(def, dev->data.disk) < 0) { - virReportOOMError(domain->conn); + virReportOOMError(); goto cleanup; } dev->data.disk = NULL; @@ -2972,7 +2971,7 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) { case VIR_DOMAIN_DEVICE_NET: { if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0) { - virReportOOMError(domain->conn); + virReportOOMError(); goto cleanup; } def->nets[def->nnets++] = dev->data.net; @@ -3138,7 +3137,7 @@ int xenXMDomainGetAutostart(virDomainPtr dom, int *autostart) int ret = -1; if (!linkname || !config) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } @@ -3166,7 +3165,7 @@ int xenXMDomainSetAutostart(virDomainPtr dom, int autostart) int ret = -1; if (!linkname || !config) { - virReportOOMError(dom->conn); + virReportOOMError(); goto cleanup; } diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c index 620c482..4294dad 100644 --- a/src/xen/xs_internal.c +++ b/src/xen/xs_internal.c @@ -305,7 +305,7 @@ xenStoreOpen(virConnectPtr conn, #ifndef PROXY /* Init activeDomainList */ if (VIR_ALLOC(priv->activeDomainList) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -313,7 +313,7 @@ xenStoreOpen(virConnectPtr conn, so we can know if it is the first time through when the callback fires */ if (VIR_ALLOC(priv->xsWatchList) < 0) { - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -908,7 +908,7 @@ xenStoreDomainGetOSTypeID(virConnectPtr conn, int id) { if (str == NULL) str = strdup("linux"); if (str == NULL) - virReportOOMError(conn); + virReportOOMError(); return (str); } @@ -962,7 +962,7 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) { ret = strdup(list[i]); if (ret == NULL) - virReportOOMError(conn); + virReportOOMError(); break; } @@ -1020,7 +1020,7 @@ xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev) { ret = strdup(list[i]); if (ret == NULL) - virReportOOMError(conn); + virReportOOMError(); VIR_FREE (val); VIR_FREE (list); @@ -1043,7 +1043,7 @@ xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev) { ret = strdup(list[i]); if (ret == NULL) - virReportOOMError(conn); + virReportOOMError(); VIR_FREE (val); VIR_FREE (list); @@ -1235,7 +1235,7 @@ int xenStoreAddWatch(virConnectPtr conn, VIR_FREE(watch); } - virReportOOMError(conn); + virReportOOMError(); return -1; } @@ -1371,7 +1371,7 @@ retry: return -1; if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } nread = xenStoreDoListDomains(conn, priv, new_domids, new_domain_cnt); @@ -1454,7 +1454,7 @@ retry: return -1; if( VIR_ALLOC_N(new_domids,new_domain_cnt) < 0 ) { - virReportOOMError(NULL); + virReportOOMError(); return -1; } nread = xenStoreDoListDomains(conn, priv, new_domids, new_domain_cnt); -- 1.6.3.3

--- ...-Step-7-of-8-Implement-the-driver-methods.patch | 4 +- src/conf/domain_conf.c | 12 +- src/conf/network_conf.c | 12 +- src/conf/storage_conf.c | 10 +- src/lxc/lxc_container.c | 60 +++++----- src/lxc/lxc_controller.c | 62 +++++----- src/lxc/lxc_driver.c | 30 +++--- src/network/bridge_driver.c | 80 ++++++------- src/node_device/node_device_driver.c | 12 +- src/nodeinfo.c | 2 +- src/qemu/qemu_bridge_filter.c | 14 +-- src/qemu/qemu_bridge_filter.h | 10 +- src/qemu/qemu_conf.c | 27 ++-- src/qemu/qemu_conf.h | 3 +- src/qemu/qemu_driver.c | 126 ++++++++++---------- src/qemu/qemu_monitor.c | 6 +- src/qemu/qemu_monitor_json.c | 4 +- src/qemu/qemu_monitor_text.c | 2 +- src/qemu/qemu_security_dac.c | 49 ++++---- src/remote/remote_driver.c | 34 +++--- src/secret/secret_driver.c | 32 +++--- src/security/security_apparmor.c | 8 +- src/security/security_selinux.c | 69 +++++------ src/storage/storage_backend.c | 101 +++++++--------- src/storage/storage_backend.h | 15 +-- src/storage/storage_backend_disk.c | 6 +- src/storage/storage_backend_fs.c | 36 +++--- src/storage/storage_backend_iscsi.c | 4 +- src/storage/storage_backend_logical.c | 20 ++-- src/storage/storage_backend_mpath.c | 9 +- src/storage/storage_backend_scsi.c | 41 +++---- src/storage/storage_driver.c | 9 +- src/test/test_driver.c | 36 +++--- src/uml/uml_conf.c | 6 +- src/uml/uml_driver.c | 38 +++--- src/util/hostusb.c | 2 +- src/util/pci.c | 39 +++--- src/util/processinfo.c | 12 +- src/util/storage_file.c | 4 +- src/util/util.c | 129 ++++++++++---------- src/util/virterror.c | 6 +- src/util/virterror_internal.h | 10 +- src/xen/proxy_internal.c | 6 +- src/xen/xen_hypervisor.c | 6 +- src/xen/xen_inotify.c | 6 +- src/xen/xend_internal.c | 6 +- src/xen/xm_internal.c | 12 +- 47 files changed, 589 insertions(+), 638 deletions(-) diff --git a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch index f820b2c..7586cd4 100644 --- a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch +++ b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch @@ -151,7 +151,7 @@ index b84729f..4f73baf 100644 + fd = open(operation_path, O_WRONLY); + + if (fd < 0) { -+ virReportSystemError(conn, errno, ++ virReportSystemError(errno, + _("Could not open '%s' for vport operation"), + operation_path); + retval = -1; @@ -171,7 +171,7 @@ index b84729f..4f73baf 100644 + towrite = strlen(vport_name); + written = safewrite(fd, vport_name, towrite); + if (written != towrite) { -+ virReportSystemError(conn, errno, ++ virReportSystemError(errno, + _("Write of '%s' to '%s' during " + "vport create/delete failed " + "(towrite: %lu written: %d)"), diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ee5be58..daa63a9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5597,7 +5597,7 @@ int virDomainSaveXML(virConnectPtr conn, goto cleanup; if (virFileMakePath(configDir)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot create config directory '%s'"), configDir); goto cleanup; @@ -5606,7 +5606,7 @@ int virDomainSaveXML(virConnectPtr conn, if ((fd = open(configFile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR )) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot create config file '%s'"), configFile); goto cleanup; @@ -5614,14 +5614,14 @@ int virDomainSaveXML(virConnectPtr conn, towrite = strlen(xml); if (safewrite(fd, xml, towrite) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot write config file '%s'"), configFile); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot save config file '%s'"), configFile); goto cleanup; @@ -5792,7 +5792,7 @@ int virDomainLoadAllConfigs(virConnectPtr conn, if (!(dir = opendir(configDir))) { if (errno == ENOENT) return 0; - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to open dir '%s'"), configDir); return -1; @@ -5857,7 +5857,7 @@ int virDomainDeleteConfig(virConnectPtr conn, if (unlink(configFile) < 0 && errno != ENOENT) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot remove config %s"), configFile); goto cleanup; diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index dd42232..4e4a58c 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -748,7 +748,7 @@ int virNetworkSaveXML(virConnectPtr conn, goto cleanup; if ((err = virFileMakePath(configDir))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot create config directory '%s'"), configDir); goto cleanup; @@ -757,7 +757,7 @@ int virNetworkSaveXML(virConnectPtr conn, if ((fd = open(configFile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR )) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot create config file '%s'"), configFile); goto cleanup; @@ -765,14 +765,14 @@ int virNetworkSaveXML(virConnectPtr conn, towrite = strlen(xml); if (safewrite(fd, xml, towrite) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot write config file '%s'"), configFile); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot save config file '%s'"), configFile); goto cleanup; @@ -874,7 +874,7 @@ int virNetworkLoadAllConfigs(virConnectPtr conn, if (!(dir = opendir(configDir))) { if (errno == ENOENT) return 0; - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to open dir '%s'"), configDir); return -1; @@ -923,7 +923,7 @@ int virNetworkDeleteConfig(virConnectPtr conn, unlink(autostartLink); if (unlink(configFile) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot remove config file '%s'"), configFile); goto error; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 3e250de..9c0981d 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1539,7 +1539,7 @@ virStoragePoolLoadAllConfigs(virConnectPtr conn, if (!(dir = opendir(configDir))) { if (errno == ENOENT) return 0; - virReportSystemError(conn, errno, _("Failed to open dir '%s'"), + virReportSystemError(errno, _("Failed to open dir '%s'"), configDir); return -1; } @@ -1596,7 +1596,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn, char path[PATH_MAX]; if ((err = virFileMakePath(driver->configDir))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot create config directory %s"), driver->configDir); return -1; @@ -1637,7 +1637,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn, if ((fd = open(pool->configFile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR )) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot create config file %s"), pool->configFile); goto cleanup; @@ -1645,14 +1645,14 @@ virStoragePoolObjSaveDef(virConnectPtr conn, towrite = strlen(xml); if (safewrite(fd, xml, towrite) != towrite) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot write config file %s"), pool->configFile); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot save config file %s"), pool->configFile); goto cleanup; diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 2f07db1..1cc7ed0 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -125,13 +125,13 @@ static int lxcContainerSetStdio(int control, int ttyfd) int open_max, i; if (setsid() < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("setsid failed")); goto cleanup; } if (ioctl(ttyfd, TIOCSCTTY, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("ioctl(TIOCSTTY) failed")); goto cleanup; } @@ -144,19 +144,19 @@ static int lxcContainerSetStdio(int control, int ttyfd) close(i); if (dup2(ttyfd, 0) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("dup2(stdin) failed")); goto cleanup; } if (dup2(ttyfd, 1) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("dup2(stdout) failed")); goto cleanup; } if (dup2(ttyfd, 2) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("dup2(stderr) failed")); goto cleanup; } @@ -184,7 +184,7 @@ int lxcContainerSendContinue(int control) writeCount = safewrite(control, &msg, sizeof(msg)); if (writeCount != sizeof(msg)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to send container continue message")); goto error_out; } @@ -213,7 +213,7 @@ static int lxcContainerWaitForContinue(int control) readLen = saferead(control, &msg, sizeof(msg)); if (readLen != sizeof(msg) || msg != LXC_CONTINUE_MSG) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to read the container continue message")); return -1; } @@ -308,7 +308,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* root->parent must be private, so make / private. */ if (mount("", "/", NULL, MS_PRIVATE|MS_REC, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to make root private")); goto err; } @@ -319,7 +319,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) } if ((rc = virFileMakePath(oldroot)) != 0) { - virReportSystemError(NULL, rc, + virReportSystemError(rc, _("Failed to create %s"), oldroot); goto err; @@ -328,7 +328,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* Create a tmpfs root since old and new roots must be * on separate filesystems */ if (mount("tmprootfs", oldroot, "tmpfs", 0, NULL) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to mount empty tmpfs at %s"), oldroot); goto err; @@ -341,7 +341,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) } if ((rc = virFileMakePath(newroot)) != 0) { - virReportSystemError(NULL, rc, + virReportSystemError(rc, _("Failed to create %s"), newroot); goto err; @@ -349,7 +349,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* ... and mount our root onto it */ if (mount(root->src, newroot, NULL, MS_BIND|MS_REC, NULL) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to bind new root %s into tmpfs"), root->src); goto err; @@ -358,7 +358,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* Now we chroot into the tmpfs, then pivot into the * root->src bind-mounted onto '/new' */ if (chdir(newroot) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to chroot into %s"), newroot); goto err; } @@ -366,7 +366,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* The old root directory will live at /.oldroot after * this and will soon be unmounted completely */ if (pivot_root(".", ".oldroot") < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to pivot root")); goto err; } @@ -409,13 +409,13 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root) for (i = 0 ; i < ARRAY_CARDINALITY(mnts) ; i++) { if (virFileMakePath(mnts[i].dst) != 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to mkdir %s"), mnts[i].src); goto cleanup; } if (mount(mnts[i].src, mnts[i].dst, mnts[i].type, 0, NULL) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to mount %s on %s"), mnts[i].type, mnts[i].type); goto cleanup; @@ -423,14 +423,14 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root) } if ((rc = virFileMakePath("/dev/pts") != 0)) { - virReportSystemError(NULL, rc, "%s", + virReportSystemError(rc, "%s", _("Cannot create /dev/pts")); goto cleanup; } VIR_DEBUG("Trying to move %s to %s", devpts, "/dev/pts"); if ((rc = mount(devpts, "/dev/pts", NULL, MS_MOVE, NULL)) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to mount /dev/pts in container")); goto cleanup; } @@ -465,7 +465,7 @@ static int lxcContainerPopulateDevices(void) dev_t dev = makedev(devs[i].maj, devs[i].min); if (mknod(devs[i].path, S_IFCHR, dev) < 0 || chmod(devs[i].path, devs[i].mode)) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to make device %s"), devs[i].path); return -1; @@ -474,7 +474,7 @@ static int lxcContainerPopulateDevices(void) if (access("/dev/pts/ptmx", W_OK) == 0) { if (symlink("/dev/pts/ptmx", "/dev/ptmx") < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to create symlink /dev/ptmx to /dev/pts/ptmx")); return -1; } @@ -482,7 +482,7 @@ static int lxcContainerPopulateDevices(void) dev_t dev = makedev(LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX); if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 || chmod("/dev/ptmx", 0666)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to make device /dev/ptmx")); return -1; } @@ -512,14 +512,14 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef) } if (virFileMakePath(vmDef->fss[i]->dst) != 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to create %s"), vmDef->fss[i]->dst); VIR_FREE(src); return -1; } if (mount(src, vmDef->fss[i]->dst, NULL, MS_BIND, NULL) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to mount %s at %s"), src, vmDef->fss[i]->dst); VIR_FREE(src); @@ -542,7 +542,7 @@ static int lxcContainerUnmountOldFS(void) char mntbuf[1024]; if (!(procmnt = setmntent("/proc/mounts", "r"))) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to read /proc/mounts")); return -1; } @@ -571,7 +571,7 @@ static int lxcContainerUnmountOldFS(void) for (i = 0 ; i < nmounts ; i++) { VIR_DEBUG("Umount %s", mounts[i]); if (umount(mounts[i]) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to unmount '%s'"), mounts[i]); return -1; @@ -621,7 +621,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef) int i; if (mount("", "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to make / slave")); return -1; } @@ -635,7 +635,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef) NULL, MS_BIND, NULL) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to mount %s at %s"), vmDef->fss[i]->src, vmDef->fss[i]->dst); @@ -645,7 +645,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef) /* mount /proc */ if (mount("lxcproc", "/proc", "proc", 0, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to mount /proc")); return -1; } @@ -750,7 +750,7 @@ static int lxcContainerChild( void *data ) ttyfd = open(ttyPath, O_RDWR|O_NOCTTY); if (ttyfd < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to open tty %s"), ttyPath); VIR_FREE(ttyPath); @@ -833,7 +833,7 @@ int lxcContainerStart(virDomainDefPtr def, DEBUG("clone() returned, %d", pid); if (pid < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to run clone container")); return -1; } diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 7fd9a1b..7a45989 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -88,14 +88,14 @@ static int lxcSetContainerResources(virDomainDefPtr def) if (rc == -ENXIO || rc == -ENOENT) return 0; - virReportSystemError(NULL, -rc, "%s", + virReportSystemError(-rc, "%s", _("Unable to get cgroup for driver")); return rc; } rc = virCgroupForDomain(driver, def->name, &cgroup, 1); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("Unable to create cgroup for domain %s"), def->name); goto cleanup; @@ -103,7 +103,7 @@ static int lxcSetContainerResources(virDomainDefPtr def) rc = virCgroupSetMemory(cgroup, def->maxmem); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("Unable to set memory limit for domain %s"), def->name); goto cleanup; @@ -111,7 +111,7 @@ static int lxcSetContainerResources(virDomainDefPtr def) rc = virCgroupDenyAllDevices(cgroup); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("Unable to deny devices for domain %s"), def->name); goto cleanup; @@ -124,7 +124,7 @@ static int lxcSetContainerResources(virDomainDefPtr def) dev->major, dev->minor); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("Unable to allow device %c:%d:%d for domain %s"), dev->type, dev->major, dev->minor, def->name); goto cleanup; @@ -133,7 +133,7 @@ static int lxcSetContainerResources(virDomainDefPtr def) rc = virCgroupAllowDeviceMajor(cgroup, 'c', LXC_DEV_MAJ_PTY); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("Unable to allow PYT devices for domain %s"), def->name); goto cleanup; @@ -141,7 +141,7 @@ static int lxcSetContainerResources(virDomainDefPtr def) rc = virCgroupAddTask(cgroup, getpid()); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("Unable to add task %d to cgroup for domain %s"), getpid(), def->name); } @@ -169,7 +169,7 @@ static int lxcMonitorServer(const char *sockpath) struct sockaddr_un addr; if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("failed to create server socket '%s'"), sockpath); goto error; @@ -185,13 +185,13 @@ static int lxcMonitorServer(const char *sockpath) } if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("failed to bind server socket '%s'"), sockpath); goto error; } if (listen(fd, 30 /* backlog */ ) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("failed to listen server socket %s"), sockpath); goto error; @@ -225,14 +225,14 @@ static int lxcFdForward(int readFd, int writeFd) goto cleanup; } - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("read of fd %d failed"), readFd); goto cleanup; } if (1 != (safewrite(writeFd, buf, 1))) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("write to fd %d failed"), writeFd); goto cleanup; @@ -305,7 +305,7 @@ static int lxcControllerMain(int monitor, /* create the epoll fild descriptor */ epollFd = epoll_create(2); if (0 > epollFd) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_create(2) failed")); goto cleanup; } @@ -315,13 +315,13 @@ static int lxcControllerMain(int monitor, epollEvent.events = EPOLLIN|EPOLLET; /* edge triggered */ epollEvent.data.fd = appPty; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, appPty, &epollEvent)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_ctl(appPty) failed")); goto cleanup; } epollEvent.data.fd = contPty; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, contPty, &epollEvent)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_ctl(contPty) failed")); goto cleanup; } @@ -329,7 +329,7 @@ static int lxcControllerMain(int monitor, epollEvent.events = EPOLLIN; epollEvent.data.fd = monitor; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, monitor, &epollEvent)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_ctl(monitor) failed")); goto cleanup; } @@ -337,7 +337,7 @@ static int lxcControllerMain(int monitor, epollEvent.events = EPOLLHUP; epollEvent.data.fd = client; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, client, &epollEvent)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_ctl(client) failed")); goto cleanup; } @@ -357,13 +357,13 @@ static int lxcControllerMain(int monitor, epollEvent.events = EPOLLHUP; epollEvent.data.fd = client; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, client, &epollEvent)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_ctl(client) failed")); goto cleanup; } } else if (client != -1 && epollEvent.data.fd == client) { if (0 > epoll_ctl(epollFd, EPOLL_CTL_DEL, client, &epollEvent)) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_ctl(client) failed")); goto cleanup; } @@ -401,7 +401,7 @@ static int lxcControllerMain(int monitor, } /* error */ - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("epoll_wait() failed")); goto cleanup; @@ -509,7 +509,7 @@ lxcControllerRun(virDomainDefPtr def, char *devptmx = NULL; if (socketpair(PF_UNIX, SOCK_STREAM, 0, control) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("sockpair failed")); goto cleanup; } @@ -539,13 +539,13 @@ lxcControllerRun(virDomainDefPtr def, if (root) { VIR_DEBUG0("Setting up private /dev/pts"); if (unshare(CLONE_NEWNS) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Cannot unshare mount namespace")); goto cleanup; } if (mount("", "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to switch root mount into slave mode")); goto cleanup; } @@ -557,7 +557,7 @@ lxcControllerRun(virDomainDefPtr def, } if (virFileMakePath(devpts) != 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to make path %s"), devpts); goto cleanup; @@ -565,7 +565,7 @@ lxcControllerRun(virDomainDefPtr def, VIR_DEBUG("Mouting 'devpts' on %s", devpts); if (mount("devpts", devpts, "devpts", 0, "newinstance,ptmxmode=0666") < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to mount devpts on %s"), devpts); goto cleanup; @@ -583,7 +583,7 @@ lxcControllerRun(virDomainDefPtr def, &containerPty, &containerPtyPath, 0) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to allocate tty")); goto cleanup; } @@ -592,7 +592,7 @@ lxcControllerRun(virDomainDefPtr def, if (virFileOpenTty(&containerPty, &containerPtyPath, 0) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to allocate tty")); goto cleanup; } @@ -769,7 +769,7 @@ int main(int argc, char *argv[]) if (pid > 0) { if ((rc = virFileWritePid(LXC_STATE_DIR, name, pid)) != 0) { - virReportSystemError(NULL, rc, + virReportSystemError(rc, _("Unable to write pid file '%s/%s.pid'"), LXC_STATE_DIR, name); _exit(1); @@ -783,13 +783,13 @@ int main(int argc, char *argv[]) /* Don't hold onto any cwd we inherit from libvirtd either */ if (chdir("/") < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to change to root dir")); goto cleanup; } if (setsid() < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to become session leader")); goto cleanup; } @@ -800,7 +800,7 @@ int main(int argc, char *argv[]) /* Accept initial client which is the libvirtd daemon */ if ((client = accept(monitor, NULL, 0)) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to accept a connection from driver")); goto cleanup; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 858b7d4..a4143f5 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -707,7 +707,7 @@ static int lxcVmCleanup(virConnectPtr conn, ; /* empty */ if ((waitRc != vm->pid) && (errno != ECHILD)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("waitpid failed to wait for container %d: %d"), vm->pid, waitRc); } @@ -838,7 +838,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, char macaddr[VIR_MAC_STRING_BUFLEN]; virFormatMacAddr(def->nets[i]->mac, macaddr); if (0 != (rc = setMacAddr(containerVeth, macaddr))) { - virReportSystemError(conn, rc, + virReportSystemError(rc, _("Failed to set %s to %s"), macaddr, containerVeth); goto error_exit; @@ -846,14 +846,14 @@ static int lxcSetupInterfaces(virConnectPtr conn, } if (0 != (rc = brAddInterface(brctl, bridge, parentVeth))) { - virReportSystemError(conn, rc, + virReportSystemError(rc, _("Failed to add %s device to %s"), parentVeth, bridge); goto error_exit; } if (0 != (rc = vethInterfaceUpOrDown(parentVeth, 1))) { - virReportSystemError(conn, rc, + virReportSystemError(rc, _("Failed to enable %s device"), parentVeth); goto error_exit; @@ -884,7 +884,7 @@ static int lxcMonitorClient(virConnectPtr conn, } if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to create client socket")); goto error; } @@ -898,7 +898,7 @@ static int lxcMonitorClient(virConnectPtr conn, } if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to connect to client socket")); goto error; } @@ -930,7 +930,7 @@ static int lxcVmTerminate(virConnectPtr conn, if (kill(vm->pid, signum) < 0) { if (errno != ESRCH) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to kill pid %d"), vm->pid); return -1; @@ -1131,7 +1131,7 @@ static int lxcControllerStart(virConnectPtr conn, */ while ((rc = waitpid(child, &status, 0) == -1) && errno == EINTR); if (rc == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Cannot wait for '%s'"), largv[0]); goto cleanup; @@ -1194,7 +1194,7 @@ static int lxcVmStart(virConnectPtr conn, lxcDomainObjPrivatePtr priv = vm->privateData; if ((r = virFileMakePath(driver->logDir)) != 0) { - virReportSystemError(conn, r, + virReportSystemError(r, _("Cannot create log directory '%s'"), driver->logDir); return -1; @@ -1208,7 +1208,7 @@ static int lxcVmStart(virConnectPtr conn, /* open parent tty */ if (virFileOpenTty(&parentTty, &parentTtyPath, 1) < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("Failed to allocate tty")); goto cleanup; } @@ -1229,7 +1229,7 @@ static int lxcVmStart(virConnectPtr conn, if ((logfd = open(logfile, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR|S_IWUSR)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to open '%s'"), logfile); goto cleanup; @@ -1249,7 +1249,7 @@ static int lxcVmStart(virConnectPtr conn, /* And get its pid */ if ((r = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) != 0) { - virReportSystemError(conn, r, + virReportSystemError(r, _("Failed to read pid file %s/%s.pid"), driver->stateDir, vm->def->name); goto cleanup; @@ -2139,21 +2139,21 @@ static int lxcDomainSetAutostart(virDomainPtr dom, int err; if ((err = virFileMakePath(driver->autostartDir))) { - virReportSystemError(dom->conn, err, + virReportSystemError(err, _("Cannot create autostart directory %s"), driver->autostartDir); goto cleanup; } if (symlink(configFile, autostartLink) < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Failed to create symlink '%s to '%s'"), autostartLink, configFile); goto cleanup; } } else { if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Failed to delete symlink '%s'"), autostartLink); goto cleanup; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 27678d0..63cd53e 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -242,7 +242,7 @@ networkStartup(int privileged) { VIR_FREE(base); if ((err = brInit(&driverState->brctl))) { - virReportSystemError(NULL, err, "%s", + virReportSystemError(err, "%s", _("cannot initialize bridge support")); goto error; } @@ -539,13 +539,13 @@ dhcpStartDhcpDaemon(virConnectPtr conn, } if ((err = virFileMakePath(NETWORK_PID_DIR)) != 0) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot create directory %s"), NETWORK_PID_DIR); return -1; } if ((err = virFileMakePath(NETWORK_STATE_DIR)) != 0) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot create directory %s"), NETWORK_STATE_DIR); return -1; @@ -589,16 +589,15 @@ cleanup: } static int -networkAddMasqueradingIptablesRules(virConnectPtr conn, - struct network_driver *driver, - virNetworkObjPtr network) { +networkAddMasqueradingIptablesRules(struct network_driver *driver, + virNetworkObjPtr network) { int err; /* allow forwarding packets from the bridge interface */ if ((err = iptablesAddForwardAllowOut(driver->iptables, network->def->network, network->def->bridge, network->def->forwardDev))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow forwarding from '%s'"), network->def->bridge); goto masqerr1; @@ -609,7 +608,7 @@ networkAddMasqueradingIptablesRules(virConnectPtr conn, network->def->network, network->def->bridge, network->def->forwardDev))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow forwarding to '%s'"), network->def->bridge); goto masqerr2; @@ -619,7 +618,7 @@ networkAddMasqueradingIptablesRules(virConnectPtr conn, if ((err = iptablesAddForwardMasquerade(driver->iptables, network->def->network, network->def->forwardDev))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to enable masquerading to '%s'\n"), network->def->forwardDev ? network->def->forwardDev : NULL); goto masqerr3; @@ -642,16 +641,15 @@ networkAddMasqueradingIptablesRules(virConnectPtr conn, } static int -networkAddRoutingIptablesRules(virConnectPtr conn, - struct network_driver *driver, - virNetworkObjPtr network) { +networkAddRoutingIptablesRules(struct network_driver *driver, + virNetworkObjPtr network) { int err; /* allow routing packets from the bridge interface */ if ((err = iptablesAddForwardAllowOut(driver->iptables, network->def->network, network->def->bridge, network->def->forwardDev))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow routing from '%s'"), network->def->bridge); goto routeerr1; @@ -662,7 +660,7 @@ networkAddRoutingIptablesRules(virConnectPtr conn, network->def->network, network->def->bridge, network->def->forwardDev))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow routing to '%s'"), network->def->bridge); goto routeerr2; @@ -681,21 +679,20 @@ networkAddRoutingIptablesRules(virConnectPtr conn, } static int -networkAddIptablesRules(virConnectPtr conn, - struct network_driver *driver, - virNetworkObjPtr network) { +networkAddIptablesRules(struct network_driver *driver, + virNetworkObjPtr network) { int err; /* allow DHCP requests through to dnsmasq */ if ((err = iptablesAddTcpInput(driver->iptables, network->def->bridge, 67))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow DHCP requests from '%s'"), network->def->bridge); goto err1; } if ((err = iptablesAddUdpInput(driver->iptables, network->def->bridge, 67))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow DHCP requests from '%s'"), network->def->bridge); goto err2; @@ -703,14 +700,14 @@ networkAddIptablesRules(virConnectPtr conn, /* allow DNS requests through to dnsmasq */ if ((err = iptablesAddTcpInput(driver->iptables, network->def->bridge, 53))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow DNS requests from '%s'"), network->def->bridge); goto err3; } if ((err = iptablesAddUdpInput(driver->iptables, network->def->bridge, 53))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow DNS requests from '%s'"), network->def->bridge); goto err4; @@ -720,14 +717,14 @@ networkAddIptablesRules(virConnectPtr conn, /* Catch all rules to block forwarding to/from bridges */ if ((err = iptablesAddForwardRejectOut(driver->iptables, network->def->bridge))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to block outbound traffic from '%s'"), network->def->bridge); goto err5; } if ((err = iptablesAddForwardRejectIn(driver->iptables, network->def->bridge))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to block inbound traffic to '%s'"), network->def->bridge); goto err6; @@ -735,7 +732,7 @@ networkAddIptablesRules(virConnectPtr conn, /* Allow traffic between guests on the same bridge */ if ((err = iptablesAddForwardAllowCross(driver->iptables, network->def->bridge))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add iptables rule to allow cross bridge traffic on '%s'"), network->def->bridge); goto err7; @@ -744,11 +741,11 @@ networkAddIptablesRules(virConnectPtr conn, /* If masquerading is enabled, set up the rules*/ if (network->def->forwardType == VIR_NETWORK_FORWARD_NAT && - !networkAddMasqueradingIptablesRules(conn, driver, network)) + !networkAddMasqueradingIptablesRules(driver, network)) goto err8; /* else if routing is enabled, set up the rules*/ else if (network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE && - !networkAddRoutingIptablesRules(conn, driver, network)) + !networkAddRoutingIptablesRules(driver, network)) goto err8; return 1; @@ -818,7 +815,7 @@ networkReloadIptablesRules(struct network_driver *driver) if (virNetworkObjIsActive(driver->networks.objs[i])) { networkRemoveIptablesRules(driver, driver->networks.objs[i]); - if (!networkAddIptablesRules(NULL, driver, driver->networks.objs[i])) { + if (!networkAddIptablesRules(driver, driver->networks.objs[i])) { /* failed to add but already logged */ } } @@ -836,8 +833,7 @@ networkEnableIpForwarding(void) #define SYSCTL_PATH "/proc/sys" -static int networkDisableIPV6(virConnectPtr conn, - virNetworkObjPtr network) +static int networkDisableIPV6(virNetworkObjPtr network) { char *field = NULL; int ret = -1; @@ -854,7 +850,7 @@ static int networkDisableIPV6(virConnectPtr conn, } if (virFileWriteStr(field, "1") < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot enable %s"), field); goto cleanup; } @@ -866,7 +862,7 @@ static int networkDisableIPV6(virConnectPtr conn, } if (virFileWriteStr(field, "0") < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot disable %s"), field); goto cleanup; } @@ -878,7 +874,7 @@ static int networkDisableIPV6(virConnectPtr conn, } if (virFileWriteStr(field, "1") < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot enable %s"), field); goto cleanup; } @@ -901,13 +897,13 @@ static int networkStartNetworkDaemon(virConnectPtr conn, } if ((err = brAddBridge(driver->brctl, network->def->bridge))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot create bridge '%s'"), network->def->bridge); return -1; } - if (networkDisableIPV6(conn, network) < 0) + if (networkDisableIPV6(network) < 0) goto err_delbr; if (brSetForwardDelay(driver->brctl, network->def->bridge, network->def->delay) < 0) @@ -918,7 +914,7 @@ static int networkStartNetworkDaemon(virConnectPtr conn, if (network->def->ipAddress && (err = brSetInetAddress(driver->brctl, network->def->bridge, network->def->ipAddress))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot set IP address on bridge '%s' to '%s'"), network->def->bridge, network->def->ipAddress); goto err_delbr; @@ -926,25 +922,25 @@ static int networkStartNetworkDaemon(virConnectPtr conn, if (network->def->netmask && (err = brSetInetNetmask(driver->brctl, network->def->bridge, network->def->netmask))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot set netmask on bridge '%s' to '%s'"), network->def->bridge, network->def->netmask); goto err_delbr; } if ((err = brSetInterfaceUp(driver->brctl, network->def->bridge, 1))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to bring the bridge '%s' up"), network->def->bridge); goto err_delbr; } - if (!networkAddIptablesRules(conn, driver, network)) + if (!networkAddIptablesRules(driver, network)) goto err_delbr1; if (network->def->forwardType != VIR_NETWORK_FORWARD_NONE && networkEnableIpForwarding() < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("failed to enable IP forwarding")); goto err_delbr2; } @@ -1519,21 +1515,21 @@ static int networkSetAutostart(virNetworkPtr net, if (autostart) { if (virFileMakePath(driver->networkAutostartDir)) { - virReportSystemError(net->conn, errno, + virReportSystemError(errno, _("cannot create autostart directory '%s'"), driver->networkAutostartDir); goto cleanup; } if (symlink(configFile, autostartLink) < 0) { - virReportSystemError(net->conn, errno, + virReportSystemError(errno, _("Failed to create symlink '%s' to '%s'"), autostartLink, configFile); goto cleanup; } } else { if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { - virReportSystemError(net->conn, errno, + virReportSystemError(errno, _("Failed to delete symlink '%s'"), autostartLink); goto cleanup; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 74258be..fd96874 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -74,8 +74,7 @@ static int update_caps(virNodeDeviceObjPtr dev) /* Under libudev changes to the driver name should be picked up as * "change" events, so we don't call update driver name unless we're * using the HAL backend. */ -static int update_driver_name(virConnectPtr conn, - virNodeDeviceObjPtr dev) +static int update_driver_name(virNodeDeviceObjPtr dev) { char *driver_link = NULL; char *devpath = NULL; @@ -97,7 +96,7 @@ static int update_driver_name(virConnectPtr conn, } if (virFileResolveLink(driver_link, &devpath) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot resolve driver link %s"), driver_link); goto cleanup; } @@ -119,8 +118,7 @@ cleanup: } #else /* XXX: Implement me for non-linux */ -static int update_driver_name(virConnectPtr conn ATTRIBUTE_UNUSED, - virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED) +static int update_driver_name(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED) { return 0; } @@ -282,7 +280,7 @@ static char *nodeDeviceDumpXML(virNodeDevicePtr dev, goto cleanup; } - update_driver_name(dev->conn, obj); + update_driver_name(obj); update_caps(obj); ret = virNodeDeviceDefFormat(dev->conn, obj->def); @@ -448,7 +446,7 @@ nodeDeviceVportCreateDelete(virConnectPtr conn, } if (virFileWriteStr(operation_path, vport_name) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Write of '%s' to '%s' during " "vport create/delete failed"), vport_name, operation_path); diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 7d26b2b..2d44609 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -155,7 +155,7 @@ int nodeGetInfo(virConnectPtr conn, int ret; FILE *cpuinfo = fopen(CPUINFO_PATH, "r"); if (!cpuinfo) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open %s"), CPUINFO_PATH); return -1; } diff --git a/src/qemu/qemu_bridge_filter.c b/src/qemu/qemu_bridge_filter.c index f591917..f700631 100644 --- a/src/qemu/qemu_bridge_filter.c +++ b/src/qemu/qemu_bridge_filter.c @@ -39,7 +39,7 @@ networkAddEbtablesRules(struct qemud_driver *driver) { /* Set forward policy to DROP */ if ((err = ebtablesAddForwardPolicyReject(driver->ebtables))) { - virReportSystemError(NULL, err, + virReportSystemError(err, _("failed to add ebtables rule to set default policy to drop on '%s'"), __FILE__); return err; @@ -55,7 +55,7 @@ networkDisableAllFrames(struct qemud_driver *driver) { /* add default rules */ if ((err = networkAddEbtablesRules(driver))) { - virReportSystemError(NULL, err, + virReportSystemError(err, _("cannot filter mac addresses on bridge '%s'"), __FILE__); return err; @@ -64,8 +64,7 @@ networkDisableAllFrames(struct qemud_driver *driver) { } int -networkAllowMacOnPort(virConnectPtr conn, - struct qemud_driver *driver, +networkAllowMacOnPort(struct qemud_driver *driver, const char * ifname, const unsigned char * mac) { @@ -76,7 +75,7 @@ networkAllowMacOnPort(virConnectPtr conn, if ((err = ebtablesAddForwardAllowIn(ebtablescontext, ifname, mac))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add ebtables rule to allow routing to '%s'"), ifname); } @@ -86,8 +85,7 @@ networkAllowMacOnPort(virConnectPtr conn, int -networkDisallowMacOnPort(virConnectPtr conn, - struct qemud_driver *driver, +networkDisallowMacOnPort(struct qemud_driver *driver, const char * ifname, const unsigned char * mac) { @@ -98,7 +96,7 @@ networkDisallowMacOnPort(virConnectPtr conn, if ((err = ebtablesRemoveForwardAllowIn(ebtablescontext, ifname, mac))) { - virReportSystemError(conn, err, + virReportSystemError(err, _("failed to add ebtables rule to allow routing to '%s'"), ifname); } diff --git a/src/qemu/qemu_bridge_filter.h b/src/qemu/qemu_bridge_filter.h index ccb4710..23937f1 100644 --- a/src/qemu/qemu_bridge_filter.h +++ b/src/qemu/qemu_bridge_filter.h @@ -24,12 +24,10 @@ #define __QEMUD_BRIDGE_FILTER_H__ -int networkAllowMacOnPort(virConnectPtr conn, - struct qemud_driver *driver, - const char * ifname, - const unsigned char * mac); -int networkDisallowMacOnPort(virConnectPtr conn, - struct qemud_driver *driver, +int networkAllowMacOnPort(struct qemud_driver *driver, + const char * ifname, + const unsigned char * mac); +int networkDisallowMacOnPort(struct qemud_driver *driver, const char * ifname, const unsigned char * mac); int networkDisableAllFrames(struct qemud_driver *driver); diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 0ce5790..3d16ed9 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -119,7 +119,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, if (driver->privileged && !(driver->hugetlbfs_mount = virFileFindMountPoint("hugetlbfs"))) { if (errno != ENOENT) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("unable to find hugetlbfs mountpoint")); return -1; } @@ -333,13 +333,13 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, driver->macFilter = p->l; if (!(driver->ebtables = ebtablesContextNew("qemu"))) { driver->macFilter = 0; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("failed to enable mac filter in in '%s'"), __FILE__); } if ((errno = networkDisableAllFrames(driver))) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("failed to add rule to drop all frames in '%s'"), __FILE__); } @@ -491,7 +491,7 @@ qemudProbeMachineTypes(const char *binary, len = virFileReadLimFD(newstdout, MAX_MACHINES_OUTPUT_SIZE, &output); if (len < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to read 'qemu -M ?' output")); goto cleanup; } @@ -725,7 +725,7 @@ qemudProbeCPUModels(const char *qemu, len = virFileReadLimFD(newstdout, MAX_MACHINES_OUTPUT_SIZE, &output); if (len < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to read QEMU supported CPU models")); goto cleanup; } @@ -1338,7 +1338,7 @@ int qemudExtractVersionInfo(const char *qemu, enum { MAX_HELP_OUTPUT_SIZE = 1024*64 }; int len = virFileReadLimFD(newstdout, MAX_HELP_OUTPUT_SIZE, &help); if (len < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to read QEMU help output")); goto cleanup2; } @@ -1392,8 +1392,7 @@ uname_normalize (struct utsname *ut) ut->machine[1] = '6'; } -int qemudExtractVersion(virConnectPtr conn, - struct qemud_driver *driver) { +int qemudExtractVersion(struct qemud_driver *driver) { const char *binary; struct stat sb; struct utsname ut; @@ -1409,7 +1408,7 @@ int qemudExtractVersion(virConnectPtr conn, return -1; if (stat(binary, &sb) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Cannot find QEMU binary %s"), binary); return -1; } @@ -1458,7 +1457,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn, } if (!driver->brctl && (err = brInit(&driver->brctl))) { - virReportSystemError(conn, err, "%s", + virReportSystemError(err, "%s", _("cannot initialize bridge support")); goto cleanup; } @@ -1487,11 +1486,11 @@ qemudNetworkIfaceConnect(virConnectPtr conn, _("Failed to add tap interface to bridge. " "%s is not a bridge device"), brname); } else if (template_ifname) { - virReportSystemError(conn, err, + virReportSystemError(err, _("Failed to add tap interface to bridge '%s'"), brname); } else { - virReportSystemError(conn, err, + virReportSystemError(err, _("Failed to add tap interface '%s' to bridge '%s'"), net->ifname, brname); } @@ -1501,8 +1500,8 @@ qemudNetworkIfaceConnect(virConnectPtr conn, } if (driver->macFilter) { - if ((err = networkAllowMacOnPort(conn, driver, net->ifname, net->mac))) { - virReportSystemError(conn, err, + if ((err = networkAllowMacOnPort(driver, net->ifname, net->mac))) { + virReportSystemError(err, _("failed to add ebtables rule to allow MAC address on '%s'"), net->ifname); } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 101f187..5525b6c 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -167,8 +167,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, virCapsPtr qemudCapsInit (virCapsPtr old_caps); -int qemudExtractVersion (virConnectPtr conn, - struct qemud_driver *driver); +int qemudExtractVersion (struct qemud_driver *driver); int qemudExtractVersionInfo (const char *qemu, unsigned int *version, unsigned int *flags); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e75e9a2..98086f5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -307,7 +307,7 @@ static int qemuDomainObjBeginJob(virDomainObjPtr obj) unsigned long long then; if (gettimeofday(&now, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("cannot get time of day")); return -1; } @@ -323,7 +323,7 @@ static int qemuDomainObjBeginJob(virDomainObjPtr obj) qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_TIMEOUT, "%s", _("cannot acquire state change lock")); else - virReportSystemError(NULL, errno, + virReportSystemError(errno, "%s", _("cannot acquire job mutex")); return -1; } @@ -349,7 +349,7 @@ static int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver, unsigned long long then; if (gettimeofday(&now, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("cannot get time of day")); return -1; } @@ -366,7 +366,7 @@ static int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver, qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_TIMEOUT, "%s", _("cannot acquire state change lock")); else - virReportSystemError(NULL, errno, + virReportSystemError(errno, "%s", _("cannot acquire job mutex")); qemuDriverLock(driver); return -1; @@ -497,7 +497,7 @@ static int qemuCgroupControllerActive(struct qemud_driver *driver, } static int -qemudLogFD(virConnectPtr conn, struct qemud_driver *driver, const char* name) +qemudLogFD(struct qemud_driver *driver, const char* name) { char logfile[PATH_MAX]; mode_t logmode; @@ -518,13 +518,13 @@ qemudLogFD(virConnectPtr conn, struct qemud_driver *driver, const char* name) logmode |= O_TRUNC; if ((fd = open(logfile, logmode, S_IRUSR | S_IWUSR)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to create logfile %s"), logfile); return -1; } if (virSetCloseExec(fd) < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to set VM logfile close-on-exec flag")); close(fd); return -1; @@ -550,19 +550,19 @@ qemudLogReadFD(virConnectPtr conn, const char* logDir, const char* name, off_t p if ((fd = open(logfile, logmode)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to create logfile %s"), logfile); return -1; } if (virSetCloseExec(fd) < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("Unable to set VM logfile close-on-exec flag")); close(fd); return -1; } if (pos < 0 || lseek(fd, pos, SEEK_SET) < 0) { - virReportSystemError(conn, pos < 0 ? 0 : errno, + virReportSystemError(pos < 0 ? 0 : errno, _("Unable to seek to %lld in %s"), (long long) pos, logfile); close(fd); @@ -1114,13 +1114,13 @@ qemudStartup(int privileged) { if (privileged) { if (chown(qemu_driver->libDir, qemu_driver->user, qemu_driver->group) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("unable to set ownership of '%s' to user %d:%d"), qemu_driver->libDir, qemu_driver->user, qemu_driver->group); goto error; } if (chown(qemu_driver->cacheDir, qemu_driver->user, qemu_driver->group) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("unable to set ownership of '%s' to %d:%d"), qemu_driver->cacheDir, qemu_driver->user, qemu_driver->group); goto error; @@ -1141,14 +1141,14 @@ qemudStartup(int privileged) { goto out_of_memory; if ((rc = virFileMakePath(mempath)) != 0) { - virReportSystemError(NULL, rc, + virReportSystemError(rc, _("unable to create hugepage path %s"), mempath); VIR_FREE(mempath); goto error; } if (qemu_driver->privileged && chown(mempath, qemu_driver->user, qemu_driver->group) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("unable to set ownership on %s to %d:%d"), mempath, qemu_driver->user, qemu_driver->group); VIR_FREE(mempath); @@ -1348,7 +1348,7 @@ qemudReadLogOutput(virConnectPtr conn, * always have something useful to report on failure. */ ret = saferead(fd, buf+got, buflen-got-1); if (ret < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failure while reading %s log output"), what); return -1; @@ -2324,8 +2324,7 @@ static const char *const defaultDeviceACL[] = { #define DEVICE_PTY_MAJOR 136 #define DEVICE_SND_MAJOR 116 -static int qemuSetupCgroup(virConnectPtr conn, - struct qemud_driver *driver, +static int qemuSetupCgroup(struct qemud_driver *driver, virDomainObjPtr vm) { virCgroupPtr cgroup = NULL; @@ -2341,7 +2340,7 @@ static int qemuSetupCgroup(virConnectPtr conn, rc = virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 1); if (rc != 0) { - virReportSystemError(conn, -rc, + virReportSystemError(-rc, _("Unable to create cgroup for %s"), vm->def->name); goto cleanup; @@ -2355,7 +2354,7 @@ static int qemuSetupCgroup(virConnectPtr conn, goto done; } - virReportSystemError(conn, -rc, + virReportSystemError(-rc, _("Unable to deny all devices for %s"), vm->def->name); goto cleanup; } @@ -2368,7 +2367,7 @@ static int qemuSetupCgroup(virConnectPtr conn, rc = virCgroupAllowDevicePath(cgroup, vm->def->disks[i]->src); if (rc != 0) { - virReportSystemError(conn, -rc, + virReportSystemError(-rc, _("Unable to allow device %s for %s"), vm->def->disks[i]->src, vm->def->name); goto cleanup; @@ -2377,7 +2376,7 @@ static int qemuSetupCgroup(virConnectPtr conn, rc = virCgroupAllowDeviceMajor(cgroup, 'c', DEVICE_PTY_MAJOR); if (rc != 0) { - virReportSystemError(conn, -rc, "%s", + virReportSystemError(-rc, "%s", _("unable to allow /dev/pts/ devices")); goto cleanup; } @@ -2385,7 +2384,7 @@ static int qemuSetupCgroup(virConnectPtr conn, if (vm->def->nsounds) { rc = virCgroupAllowDeviceMajor(cgroup, 'c', DEVICE_SND_MAJOR); if (rc != 0) { - virReportSystemError(conn, -rc, "%s", + virReportSystemError(-rc, "%s", _("unable to allow /dev/snd/ devices")); goto cleanup; } @@ -2396,7 +2395,7 @@ static int qemuSetupCgroup(virConnectPtr conn, deviceACL[i]); if (rc < 0 && rc != -ENOENT) { - virReportSystemError(conn, -rc, + virReportSystemError(-rc, _("unable to allow device %s"), deviceACL[i]); goto cleanup; @@ -2454,7 +2453,7 @@ static int qemuAddToCgroup(struct qemud_driver *driver, rc = virCgroupForDomain(driver->cgroup, def->name, &cgroup, 0); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("unable to find cgroup for domain %s"), def->name); goto cleanup; @@ -2462,7 +2461,7 @@ static int qemuAddToCgroup(struct qemud_driver *driver, rc = virCgroupAddTask(cgroup, getpid()); if (rc != 0) { - virReportSystemError(NULL, -rc, + virReportSystemError(-rc, _("unable to add domain %s task %d to cgroup"), def->name, getpid()); goto cleanup; @@ -2582,13 +2581,13 @@ static int qemudStartVMDaemon(virConnectPtr conn, } if (virFileMakePath(driver->logDir) != 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot create log directory %s"), driver->logDir); goto cleanup; } - if ((logfile = qemudLogFD(conn, driver, vm->def->name)) < 0) + if ((logfile = qemudLogFD(driver, vm->def->name)) < 0) goto cleanup; emulator = vm->def->emulator; @@ -2598,7 +2597,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, * in a sub-process so its hard to feed back a useful error */ if (stat(emulator, &sb) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Cannot find QEMU binary %s"), emulator); goto cleanup; @@ -2609,7 +2608,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, &qemuCmdFlags) < 0) goto cleanup; - if (qemuSetupCgroup(conn, driver, vm) < 0) + if (qemuSetupCgroup(driver, vm) < 0) goto cleanup; if (qemuPrepareHostDevices(conn, driver, vm->def) < 0) @@ -2631,14 +2630,14 @@ static int qemudStartVMDaemon(virConnectPtr conn, priv->monJSON = 0; if ((ret = virFileDeletePid(driver->stateDir, vm->def->name)) != 0) { - virReportSystemError(conn, ret, + virReportSystemError(ret, _("Cannot remove stale PID file for %s"), vm->def->name); goto cleanup; } if (!(pidfile = virFilePid(driver->stateDir, vm->def->name))) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("Failed to build pidfile path.")); goto cleanup; } @@ -2839,9 +2838,9 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, virDomainNetDefPtr net = def->nets[i]; if (net->ifname == NULL) continue; - if ((errno = networkDisallowMacOnPort(conn, driver, net->ifname, + if ((errno = networkDisallowMacOnPort(driver, net->ifname, net->mac))) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to remove ebtables rule to allow MAC address on '%s'"), net->ifname); } @@ -2850,7 +2849,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, if (virKillProcess(vm->pid, 0) == 0 && virKillProcess(vm->pid, SIGTERM) < 0) - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to send SIGTERM to %s (%d)"), vm->def->name, vm->pid); @@ -3036,7 +3035,7 @@ static int kvmGetMaxVCPUs(void) { fd = open(KVM_DEVICE, O_RDONLY); if (fd < 0) { - virReportSystemError(NULL, errno, _("Unable to open %s"), KVM_DEVICE); + virReportSystemError(errno, _("Unable to open %s"), KVM_DEVICE); return -1; } @@ -3282,7 +3281,7 @@ static int qemudGetVersion(virConnectPtr conn, unsigned long *version) { int ret = -1; qemuDriverLock(driver); - if (qemudExtractVersion(conn, driver) < 0) + if (qemudExtractVersion(driver) < 0) goto cleanup; *version = qemu_driver->qemuVersion; @@ -3925,7 +3924,7 @@ static int qemudDomainSave(virDomainPtr dom, } if (close(fd) < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("unable to save file %s"), path); goto endjob; @@ -4040,7 +4039,7 @@ static int qemudDomainCoreDump(virDomainPtr dom, } if (close(fd) < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("unable to save file %s"), path); goto endjob; @@ -4302,7 +4301,7 @@ qemudDomainGetVcpus(virDomainPtr dom, &(info[i].cpu), vm->pid, priv->vcpupids[i]) < 0) { - virReportSystemError(dom->conn, errno, "%s", + virReportSystemError(errno, "%s", _("cannot get vCPU placement & pCPU time")); goto cleanup; } @@ -4780,7 +4779,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, * in a sub-process so its hard to feed back a useful error */ if (stat(emulator, &sb) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Cannot find QEMU binary %s"), emulator); goto cleanup; @@ -6239,11 +6238,10 @@ qemudDomainDetachNetDevice(virConnectPtr conn, qemuDomainObjExitMonitorWithDriver(driver, vm); if ((driver->macFilter) && (detach->ifname != NULL)) { - if ((errno = networkDisallowMacOnPort(conn, - driver, + if ((errno = networkDisallowMacOnPort(driver, detach->ifname, detach->mac))) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to remove ebtables rule on '%s'"), detach->ifname); } @@ -6523,21 +6521,21 @@ static int qemudDomainSetAutostart(virDomainPtr dom, int err; if ((err = virFileMakePath(driver->autostartDir))) { - virReportSystemError(dom->conn, err, + virReportSystemError(err, _("cannot create autostart directory %s"), driver->autostartDir); goto cleanup; } if (symlink(configFile, autostartLink) < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Failed to create symlink '%s to '%s'"), autostartLink, configFile); goto cleanup; } } else { if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Failed to delete symlink '%s'"), autostartLink); goto cleanup; @@ -6627,7 +6625,7 @@ static int qemuSetSchedulerParameters(virDomainPtr dom, rc = virCgroupSetCpuShares(group, params[i].value.ul); if (rc != 0) { - virReportSystemError(dom->conn, -rc, "%s", + virReportSystemError(-rc, "%s", _("unable to set cpu shares tunable")); goto cleanup; } @@ -6687,7 +6685,7 @@ static int qemuGetSchedulerParameters(virDomainPtr dom, rc = virCgroupGetCpuShares(group, &val); if (rc != 0) { - virReportSystemError(dom->conn, -rc, "%s", + virReportSystemError(-rc, "%s", _("unable to get cpu shares tunable")); goto cleanup; } @@ -6924,8 +6922,8 @@ qemudDomainBlockPeek (virDomainPtr dom, /* The path is correct, now try to open it and get its size. */ fd = open (path, O_RDONLY); if (fd == -1) { - virReportSystemError (dom->conn, errno, - _("%s: failed to open"), path); + virReportSystemError(errno, + _("%s: failed to open"), path); goto cleanup; } @@ -6935,8 +6933,8 @@ qemudDomainBlockPeek (virDomainPtr dom, */ if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || saferead (fd, buffer, size) == (ssize_t) -1) { - virReportSystemError (dom->conn, errno, - _("%s: failed to seek or read"), path); + virReportSystemError(errno, + _("%s: failed to seek or read"), path); goto cleanup; } @@ -6999,8 +6997,8 @@ qemudDomainMemoryPeek (virDomainPtr dom, /* Create a temporary filename. */ if ((fd = mkstemp (tmp)) == -1) { - virReportSystemError (dom->conn, errno, - _("mkstemp(\"%s\") failed"), tmp); + virReportSystemError(errno, + _("mkstemp(\"%s\") failed"), tmp); goto endjob; } @@ -7021,9 +7019,9 @@ qemudDomainMemoryPeek (virDomainPtr dom, /* Read the memory file into buffer. */ if (saferead (fd, buffer, size) == (ssize_t) -1) { - virReportSystemError (dom->conn, errno, - _("failed to read temporary file " - "created with template %s"), tmp); + virReportSystemError(errno, + _("failed to read temporary file " + "created with template %s"), tmp); goto endjob; } @@ -7389,7 +7387,7 @@ retry: goto retry; } else { ret = -1; - virReportSystemError(st->conn, errno, "%s", + virReportSystemError(errno, "%s", _("cannot write to stream")); } } @@ -7529,7 +7527,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, virDomainRemoveInactive(&driver->domains, vm); vm = NULL; } - virReportSystemError(dconn, errno, + virReportSystemError(errno, _("cannot open unix socket '%s' for tunnelled migration"), unixfile); goto endjob; @@ -7833,7 +7831,7 @@ static int doTunnelSendAll(virDomainPtr dom, nbytes = saferead(sock, buffer, nbytes); if (nbytes < 0) { virStreamAbort(st); - virReportSystemError(dom->conn, errno, "%s", + virReportSystemError(errno, "%s", _("tunnelled migration failed to read from qemu")); return -1; } @@ -7900,7 +7898,7 @@ static int doTunnelMigrate(virDomainPtr dom, qemu_sock = socket(AF_UNIX, SOCK_STREAM, 0); if (qemu_sock < 0) { - virReportSystemError(dom->conn, errno, "%s", + virReportSystemError(errno, "%s", _("cannot open tunnelled migration socket")); goto cleanup; } @@ -7915,13 +7913,13 @@ static int doTunnelMigrate(virDomainPtr dom, } unlink(unixfile); if (bind(qemu_sock, (struct sockaddr *)&sa_qemu, sizeof(sa_qemu)) < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Cannot bind to unix socket '%s' for tunnelled migration"), unixfile); goto cleanup; } if (listen(qemu_sock, 1) < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Cannot listen on unix socket '%s' for tunnelled migration"), unixfile); goto cleanup; @@ -8005,7 +8003,7 @@ static int doTunnelMigrate(virDomainPtr dom, while ((client_sock = accept(qemu_sock, (struct sockaddr *)&sa_client, &addrlen)) < 0) { if (errno == EAGAIN || errno == EINTR) continue; - virReportSystemError(dom->conn, errno, "%s", + virReportSystemError(errno, "%s", _("tunnelled migration failed to accept from qemu")); goto cancel; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c1db64c..b702a81 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -232,7 +232,7 @@ qemuMonitorOpenUnix(const char *monitor) int ret, i = 0; if ((monfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, "%s", _("failed to create socket")); return -1; } @@ -257,14 +257,14 @@ qemuMonitorOpenUnix(const char *monitor) continue; } - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("failed to connect to monitor socket")); goto error; } while ((++i <= timeout*5) && (usleep(.2 * 1000000) <= 0)); if (ret != 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("monitor socket did not show up.")); goto error; } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 6ced8cd..25ddfa9 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -222,7 +222,7 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon, } if (ret < 0) - virReportSystemError(NULL, msg.lastErrno, + virReportSystemError(msg.lastErrno, _("cannot send monitor command '%s'"), cmdstr); cleanup: @@ -331,7 +331,7 @@ qemuMonitorJSONCommandAddTimestamp(virJSONValuePtr obj) virJSONValuePtr timestamp = NULL; if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(NULL, errno, "%s", + virReportSystemError(errno, "%s", _("cannot query time of day")); return -1; } diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index ce325f5..b8fa64f 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -250,7 +250,7 @@ qemuMonitorCommandWithHandler(qemuMonitorPtr mon, } if (ret < 0) { - virReportSystemError(NULL, msg.lastErrno, + virReportSystemError(msg.lastErrno, _("cannot send monitor command '%s'"), cmd); VIR_FREE(*reply); } diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c index ea7f904..e6ada9a 100644 --- a/src/qemu/qemu_security_dac.c +++ b/src/qemu/qemu_security_dac.c @@ -35,7 +35,7 @@ void qemuSecurityDACSetDriver(struct qemud_driver *newdriver) static int -qemuSecurityDACSetOwnership(virConnectPtr conn, const char *path, int uid, int gid) +qemuSecurityDACSetOwnership(const char *path, int uid, int gid) { VIR_INFO("Setting DAC context on '%s' to '%d:%d'", path, uid, gid); @@ -67,7 +67,7 @@ qemuSecurityDACSetOwnership(virConnectPtr conn, const char *path, int uid, int g VIR_INFO("Setting security context '%d:%d' on '%s' not possible on readonly filesystem", uid, gid, path); } else { - virReportSystemError(conn, chown_errno, + virReportSystemError(chown_errno, _("unable to set security context '%d:%d' on '%s'"), uid, gid, path); return -1; @@ -77,8 +77,7 @@ qemuSecurityDACSetOwnership(virConnectPtr conn, const char *path, int uid, int g } static int -qemuSecurityDACRestoreSecurityFileLabel(virConnectPtr conn, - const char *path) +qemuSecurityDACRestoreSecurityFileLabel(const char *path) { struct stat buf; int rc = -1; @@ -88,7 +87,7 @@ qemuSecurityDACRestoreSecurityFileLabel(virConnectPtr conn, VIR_INFO("Restoring DAC context on '%s'", path); if ((err = virFileResolveLink(path, &newpath)) < 0) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot resolve symlink %s"), path); goto err; } @@ -97,7 +96,7 @@ qemuSecurityDACRestoreSecurityFileLabel(virConnectPtr conn, goto err; /* XXX record previous ownership */ - rc = qemuSecurityDACSetOwnership(conn, newpath, 0, 0); + rc = qemuSecurityDACSetOwnership(newpath, 0, 0); err: VIR_FREE(newpath); @@ -136,8 +135,8 @@ qemuSecurityDACSetSecurityImageLabel(virConnectPtr conn, return -1; if (meta.backingStore != NULL && - qemuSecurityDACSetOwnership(conn, meta.backingStore, - driver->user, driver->group) < 0) { + qemuSecurityDACSetOwnership(meta.backingStore, + driver->user, driver->group) < 0) { VIR_FREE(meta.backingStore); return -1; } @@ -145,12 +144,12 @@ qemuSecurityDACSetSecurityImageLabel(virConnectPtr conn, path = meta.backingStore; } while (path != NULL); - return qemuSecurityDACSetOwnership(conn, disk->src, driver->user, driver->group); + return qemuSecurityDACSetOwnership(disk->src, driver->user, driver->group); } static int -qemuSecurityDACRestoreSecurityImageLabel(virConnectPtr conn, +qemuSecurityDACRestoreSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm ATTRIBUTE_UNUSED, virDomainDiskDefPtr disk) { @@ -171,27 +170,27 @@ qemuSecurityDACRestoreSecurityImageLabel(virConnectPtr conn, if (!disk->src) return 0; - return qemuSecurityDACRestoreSecurityFileLabel(conn, disk->src); + return qemuSecurityDACRestoreSecurityFileLabel(disk->src); } static int -qemuSecurityDACSetSecurityPCILabel(virConnectPtr conn, +qemuSecurityDACSetSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque ATTRIBUTE_UNUSED) { - return qemuSecurityDACSetOwnership(conn, file, driver->user, driver->group); + return qemuSecurityDACSetOwnership(file, driver->user, driver->group); } static int -qemuSecurityDACSetSecurityUSBLabel(virConnectPtr conn, +qemuSecurityDACSetSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, usbDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque ATTRIBUTE_UNUSED) { - return qemuSecurityDACSetOwnership(conn, file, driver->user, driver->group); + return qemuSecurityDACSetOwnership(file, driver->user, driver->group); } @@ -252,22 +251,22 @@ done: static int -qemuSecurityDACRestoreSecurityPCILabel(virConnectPtr conn, +qemuSecurityDACRestoreSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque ATTRIBUTE_UNUSED) { - return qemuSecurityDACRestoreSecurityFileLabel(conn, file); + return qemuSecurityDACRestoreSecurityFileLabel(file); } static int -qemuSecurityDACRestoreSecurityUSBLabel(virConnectPtr conn, +qemuSecurityDACRestoreSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, usbDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque ATTRIBUTE_UNUSED) { - return qemuSecurityDACRestoreSecurityFileLabel(conn, file); + return qemuSecurityDACRestoreSecurityFileLabel(file); } @@ -380,26 +379,26 @@ qemuSecurityDACSetSecurityAllLabel(virConnectPtr conn, static int -qemuSecurityDACSetSavedStateLabel(virConnectPtr conn, +qemuSecurityDACSetSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm ATTRIBUTE_UNUSED, const char *savefile) { if (!driver->privileged || !driver->dynamicOwnership) return 0; - return qemuSecurityDACSetOwnership(conn, savefile, driver->user, driver->group); + return qemuSecurityDACSetOwnership(savefile, driver->user, driver->group); } static int -qemuSecurityDACRestoreSavedStateLabel(virConnectPtr conn, +qemuSecurityDACRestoreSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm ATTRIBUTE_UNUSED, const char *savefile) { if (!driver->privileged || !driver->dynamicOwnership) return 0; - return qemuSecurityDACRestoreSecurityFileLabel(conn, savefile); + return qemuSecurityDACRestoreSecurityFileLabel(savefile); } @@ -415,7 +414,7 @@ qemuSecurityDACSetProcessLabel(virConnectPtr conn ATTRIBUTE_UNUSED, if (driver->group) { if (setregid(driver->group, driver->group) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot change to '%d' group"), driver->group); return -1; @@ -423,7 +422,7 @@ qemuSecurityDACSetProcessLabel(virConnectPtr conn ATTRIBUTE_UNUSED, } if (driver->user) { if (setreuid(driver->user, driver->user) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot change to '%d' user"), driver->user); return -1; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 809d386..c5ed859 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -639,7 +639,7 @@ doRemoteOpen (virConnectPtr conn, } freeaddrinfo (res); - virReportSystemError(conn, saved_errno, + virReportSystemError(saved_errno, _("unable to connect to libvirtd at '%s'"), priv->hostname); goto failed; @@ -696,7 +696,7 @@ doRemoteOpen (virConnectPtr conn, priv->is_secure = 1; priv->sock = socket (AF_UNIX, SOCK_STREAM, 0); if (priv->sock == -1) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("unable to create socket")); goto failed; } @@ -720,7 +720,7 @@ doRemoteOpen (virConnectPtr conn, goto autostart_retry; } } - virReportSystemError(conn, errno, + virReportSystemError(errno, _("unable to connect to '%s'"), sockname); goto failed; @@ -788,7 +788,7 @@ doRemoteOpen (virConnectPtr conn, * to faff around with two file descriptors (a la 'pipe(2)'). */ if (socketpair (PF_UNIX, SOCK_STREAM, 0, sv) == -1) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("unable to create socket pair")); goto failed; } @@ -821,13 +821,13 @@ doRemoteOpen (virConnectPtr conn, } /* switch (transport) */ if (virSetNonBlock(priv->sock) < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("unable to make socket non-blocking")); goto failed; } if (pipe(wakeupFD) < 0) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("unable to make pipe")); goto failed; } @@ -1099,11 +1099,11 @@ static gnutls_certificate_credentials_t x509_cred; static int -check_cert_file (virConnectPtr conn, const char *type, const char *file) +check_cert_file(const char *type, const char *file) { struct stat sb; if (stat(file, &sb) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Cannot access %s '%s'"), type, file); return -1; @@ -1132,11 +1132,11 @@ initialise_gnutls (virConnectPtr conn) } - if (check_cert_file(conn, "CA certificate", LIBVIRT_CACERT) < 0) + if (check_cert_file("CA certificate", LIBVIRT_CACERT) < 0) return -1; - if (check_cert_file(conn, "client key", LIBVIRT_CLIENTKEY) < 0) + if (check_cert_file("client key", LIBVIRT_CLIENTKEY) < 0) return -1; - if (check_cert_file(conn, "client certificate", LIBVIRT_CLIENTCERT) < 0) + if (check_cert_file("client certificate", LIBVIRT_CLIENTCERT) < 0) return -1; /* Set the trusted CA cert. */ @@ -1292,7 +1292,7 @@ verify_certificate (virConnectPtr conn ATTRIBUTE_UNUSED, } if ((now = time(NULL)) == ((time_t)-1)) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("cannot get current time")); return -1; } @@ -6325,7 +6325,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, /* Get local address in form IPADDR:PORT */ salen = sizeof(sa); if (getsockname(priv->sock, (struct sockaddr*)&sa, &salen) < 0) { - virReportSystemError(in_open ? NULL : conn, errno, "%s", + virReportSystemError(errno, "%s", _("failed to get sock address")); goto cleanup; } @@ -6335,7 +6335,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, /* Get remote address in form IPADDR:PORT */ salen = sizeof(sa); if (getpeername(priv->sock, (struct sockaddr*)&sa, &salen) < 0) { - virReportSystemError(in_open ? NULL : conn, errno, "%s", + virReportSystemError(errno, "%s", _("failed to get peer address")); goto cleanup; } @@ -7649,7 +7649,7 @@ remoteIOWriteBuffer(virConnectPtr conn, if (errno == EWOULDBLOCK) return 0; - virReportSystemError(in_open ? NULL : conn, errno, + virReportSystemError(errno, "%s", _("cannot send data")); return -1; @@ -7699,7 +7699,7 @@ remoteIOReadBuffer(virConnectPtr conn, if (errno == EWOULDBLOCK) return 0; - virReportSystemError(in_open ? NULL : conn, errno, + virReportSystemError(errno, "%s", _("cannot recv data")); } else { errorf (in_open ? NULL : conn, @@ -8303,7 +8303,7 @@ remoteIOEventLoop(virConnectPtr conn, if (ret < 0) { if (errno == EWOULDBLOCK) continue; - virReportSystemError(in_open ? NULL : conn, errno, + virReportSystemError(errno, "%s", _("poll on socket failed")); goto error; } diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 2b72a28..f4c8aef 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -156,7 +156,7 @@ secretFindByUsage(virSecretDriverStatePtr driver, int usageType, const char *usa "$basename.base64". "$basename" is in both cases the base64-encoded UUID. */ static int -replaceFile(virConnectPtr conn, const char *filename, void *data, size_t size) +replaceFile(const char *filename, void *data, size_t size) { char *tmp_path = NULL; int fd = -1, ret = -1; @@ -167,28 +167,28 @@ replaceFile(virConnectPtr conn, const char *filename, void *data, size_t size) } fd = mkstemp (tmp_path); if (fd == -1) { - virReportSystemError(conn, errno, _("mkstemp('%s') failed"), tmp_path); + virReportSystemError(errno, _("mkstemp('%s') failed"), tmp_path); goto cleanup; } if (fchmod(fd, S_IRUSR | S_IWUSR) != 0) { - virReportSystemError(conn, errno, _("fchmod('%s') failed"), tmp_path); + virReportSystemError(errno, _("fchmod('%s') failed"), tmp_path); goto cleanup; } ret = safewrite(fd, data, size); if (ret < 0) { - virReportSystemError(conn, errno, _("error writing to '%s'"), + virReportSystemError(errno, _("error writing to '%s'"), tmp_path); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(conn, errno, _("error closing '%s'"), tmp_path); + virReportSystemError(errno, _("error closing '%s'"), tmp_path); goto cleanup; } fd = -1; if (rename(tmp_path, filename) < 0) { - virReportSystemError(conn, errno, _("rename(%s, %s) failed"), tmp_path, + virReportSystemError(errno, _("rename(%s, %s) failed"), tmp_path, filename); goto cleanup; } @@ -238,10 +238,10 @@ secretBase64Path(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, } static int -secretEnsureDirectory(virConnectPtr conn, virSecretDriverStatePtr driver) +secretEnsureDirectory(virSecretDriverStatePtr driver) { if (mkdir(driver->directory, S_IRWXU) < 0 && errno != EEXIST) { - virReportSystemError(conn, errno, _("cannot create '%s'"), + virReportSystemError(errno, _("cannot create '%s'"), driver->directory); return -1; } @@ -255,7 +255,7 @@ secretSaveDef(virConnectPtr conn, virSecretDriverStatePtr driver, char *filename = NULL, *xml = NULL; int ret = -1; - if (secretEnsureDirectory(conn, driver) < 0) + if (secretEnsureDirectory(driver) < 0) goto cleanup; filename = secretXMLPath(conn, driver, secret); @@ -265,7 +265,7 @@ secretSaveDef(virConnectPtr conn, virSecretDriverStatePtr driver, if (xml == NULL) goto cleanup; - if (replaceFile(conn, filename, xml, strlen(xml)) < 0) + if (replaceFile(filename, xml, strlen(xml)) < 0) goto cleanup; ret = 0; @@ -286,7 +286,7 @@ secretSaveValue(virConnectPtr conn, virSecretDriverStatePtr driver, if (secret->value == NULL) return 0; - if (secretEnsureDirectory(conn, driver) < 0) + if (secretEnsureDirectory(driver) < 0) goto cleanup; filename = secretBase64Path(conn, driver, secret); @@ -299,7 +299,7 @@ secretSaveValue(virConnectPtr conn, virSecretDriverStatePtr driver, goto cleanup; } - if (replaceFile(conn, filename, base64, strlen(base64)) < 0) + if (replaceFile(filename, base64, strlen(base64)) < 0) goto cleanup; ret = 0; @@ -375,11 +375,11 @@ secretLoadValue(virConnectPtr conn, virSecretDriverStatePtr driver, ret = 0; goto cleanup; } - virReportSystemError (conn, errno, _("cannot open '%s'"), filename); + virReportSystemError(errno, _("cannot open '%s'"), filename); goto cleanup; } if (fstat(fd, &st) < 0) { - virReportSystemError (conn, errno, _("cannot stat '%s'"), filename); + virReportSystemError(errno, _("cannot stat '%s'"), filename); goto cleanup; } if ((size_t)st.st_size != st.st_size) { @@ -393,7 +393,7 @@ secretLoadValue(virConnectPtr conn, virSecretDriverStatePtr driver, goto cleanup; } if (saferead(fd, contents, st.st_size) != st.st_size) { - virReportSystemError (conn, errno, _("cannot read '%s'"), filename); + virReportSystemError(errno, _("cannot read '%s'"), filename); goto cleanup; } close(fd); @@ -484,7 +484,7 @@ loadSecrets(virConnectPtr conn, virSecretDriverStatePtr driver, if (dir == NULL) { if (errno == ENOENT) return 0; - virReportSystemError(conn, errno, _("cannot open '%s'"), + virReportSystemError(errno, _("cannot open '%s'"), driver->directory); goto cleanup; } diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index 15a9d59..b67df3f 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -71,7 +71,7 @@ profile_status(const char *str, const int check_enforcing) } if (virFileReadAll(APPARMOR_PROFILES_PATH, MAX_FILE_LEN, &content) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to read AppArmor profiles list " "\'%s\'"), APPARMOR_PROFILES_PATH); goto clean; @@ -120,7 +120,7 @@ profile_status_file(const char *str) goto failed; if ((len = virFileReadAll(profile, MAX_FILE_LEN, &content)) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Failed to read \'%s\'"), profile); goto failed; } @@ -158,7 +158,7 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, pid_t child; if (pipe(pipefd) < -1) { - virReportSystemError(conn, errno, "%s", _("unable to create pipe")); + virReportSystemError(errno, "%s", _("unable to create pipe")); return rc; } @@ -193,7 +193,7 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, /* parent continues here */ if (safewrite(pipefd[1], xml, strlen(xml)) < 0) { - virReportSystemError(conn, errno, "%s", _("unable to write to pipe")); + virReportSystemError(errno, "%s", _("unable to write to pipe")); goto clean; } close(pipefd[1]); diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 67687c6..1b7f995 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -103,21 +103,21 @@ err: } static int -SELinuxInitialize(virConnectPtr conn) +SELinuxInitialize(void) { char *ptr = NULL; int fd = 0; fd = open(selinux_virtual_domain_context_path(), O_RDONLY); if (fd < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open SELinux virtual domain context file '%s'"), selinux_virtual_domain_context_path()); return -1; } if (saferead(fd, default_domain_context, sizeof(default_domain_context)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read SELinux virtual domain context file %s"), selinux_virtual_domain_context_path()); close(fd); @@ -129,14 +129,14 @@ SELinuxInitialize(virConnectPtr conn) *ptr = '\0'; if ((fd = open(selinux_virtual_image_context_path(), O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open SELinux virtual image context file %s"), selinux_virtual_image_context_path()); return -1; } if (saferead(fd, default_image_context, sizeof(default_image_context)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read SELinux virtual image context file %s"), selinux_virtual_image_context_path()); close(fd); @@ -221,7 +221,7 @@ done: } static int -SELinuxReserveSecurityLabel(virConnectPtr conn, +SELinuxReserveSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm) { security_context_t pctx; @@ -232,7 +232,7 @@ SELinuxReserveSecurityLabel(virConnectPtr conn, return 0; if (getpidcon(vm->pid, &pctx) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("unable to get PID %d security context"), vm->pid); return -1; } @@ -273,7 +273,7 @@ SELinuxSecurityDriverOpen(virConnectPtr conn, virSecurityDriverPtr drv) * configuration? For the moment, we'll just set it to "0". */ virSecurityDriverSetDOI(conn, drv, SECURITY_SELINUX_VOID_DOI); - return SELinuxInitialize(conn); + return SELinuxInitialize(); } static int @@ -284,7 +284,7 @@ SELinuxGetSecurityProcessLabel(virConnectPtr conn, security_context_t ctx; if (getpidcon(vm->pid, &ctx) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("unable to get PID %d security context"), vm->pid); return -1; @@ -303,7 +303,7 @@ SELinuxGetSecurityProcessLabel(virConnectPtr conn, sec->enforcing = security_getenforce(); if (sec->enforcing == -1) { - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("error calling security_getenforce()")); return -1; } @@ -312,7 +312,7 @@ SELinuxGetSecurityProcessLabel(virConnectPtr conn, } static int -SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon) +SELinuxSetFilecon(const char *path, char *tcon) { security_context_t econ; @@ -337,7 +337,7 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon) * virt_use_{nfs,usb,pci} boolean tunables to allow it... */ if (setfilecon_errno != EOPNOTSUPP) { - virReportSystemError(conn, setfilecon_errno, + virReportSystemError(setfilecon_errno, _("unable to set security context '%s' on '%s'"), tcon, path); if (security_getenforce() == 1) @@ -351,8 +351,7 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon) } static int -SELinuxRestoreSecurityFileLabel(virConnectPtr conn, - const char *path) +SELinuxRestoreSecurityFileLabel(const char *path) { struct stat buf; security_context_t fcon = NULL; @@ -363,7 +362,7 @@ SELinuxRestoreSecurityFileLabel(virConnectPtr conn, VIR_INFO("Restoring SELinux context on '%s'", path); if ((err = virFileResolveLink(path, &newpath)) < 0) { - virReportSystemError(conn, err, + virReportSystemError(err, _("cannot resolve symlink %s"), path); goto err; } @@ -372,7 +371,7 @@ SELinuxRestoreSecurityFileLabel(virConnectPtr conn, goto err; if (matchpathcon(newpath, buf.st_mode, &fcon) == 0) { - rc = SELinuxSetFilecon(conn, newpath, fcon); + rc = SELinuxSetFilecon(newpath, fcon); } err: VIR_FREE(fcon); @@ -381,7 +380,7 @@ err: } static int -SELinuxRestoreSecurityImageLabel(virConnectPtr conn, +SELinuxRestoreSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm, virDomainDiskDefPtr disk) { @@ -404,7 +403,7 @@ SELinuxRestoreSecurityImageLabel(virConnectPtr conn, if (!disk->src) return 0; - return SELinuxRestoreSecurityFileLabel(conn, disk->src); + return SELinuxRestoreSecurityFileLabel(disk->src); } static int @@ -439,7 +438,7 @@ SELinuxSetSecurityImageLabel(virConnectPtr conn, return -1; if (meta.backingStore != NULL && - SELinuxSetFilecon(conn, meta.backingStore, + SELinuxSetFilecon(meta.backingStore, default_content_context) < 0) { VIR_FREE(meta.backingStore); return -1; @@ -449,11 +448,11 @@ SELinuxSetSecurityImageLabel(virConnectPtr conn, } while (path != NULL); if (disk->shared) { - return SELinuxSetFilecon(conn, disk->src, default_image_context); + return SELinuxSetFilecon(disk->src, default_image_context); } else if (disk->readonly) { - return SELinuxSetFilecon(conn, disk->src, default_content_context); + return SELinuxSetFilecon(disk->src, default_content_context); } else if (secdef->imagelabel) { - return SELinuxSetFilecon(conn, disk->src, secdef->imagelabel); + return SELinuxSetFilecon(disk->src, secdef->imagelabel); } return 0; @@ -461,25 +460,25 @@ SELinuxSetSecurityImageLabel(virConnectPtr conn, static int -SELinuxSetSecurityPCILabel(virConnectPtr conn, +SELinuxSetSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque) { virDomainObjPtr vm = opaque; const virSecurityLabelDefPtr secdef = &vm->def->seclabel; - return SELinuxSetFilecon(conn, file, secdef->imagelabel); + return SELinuxSetFilecon(file, secdef->imagelabel); } static int -SELinuxSetSecurityUSBLabel(virConnectPtr conn, +SELinuxSetSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, usbDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque) { virDomainObjPtr vm = opaque; const virSecurityLabelDefPtr secdef = &vm->def->seclabel; - return SELinuxSetFilecon(conn, file, secdef->imagelabel); + return SELinuxSetFilecon(file, secdef->imagelabel); } static int @@ -540,21 +539,21 @@ done: static int -SELinuxRestoreSecurityPCILabel(virConnectPtr conn, +SELinuxRestoreSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque ATTRIBUTE_UNUSED) { - return SELinuxRestoreSecurityFileLabel(conn, file); + return SELinuxRestoreSecurityFileLabel(file); } static int -SELinuxRestoreSecurityUSBLabel(virConnectPtr conn, +SELinuxRestoreSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED, usbDevice *dev ATTRIBUTE_UNUSED, const char *file, void *opaque ATTRIBUTE_UNUSED) { - return SELinuxRestoreSecurityFileLabel(conn, file); + return SELinuxRestoreSecurityFileLabel(file); } static int @@ -664,7 +663,7 @@ SELinuxReleaseSecurityLabel(virConnectPtr conn ATTRIBUTE_UNUSED, static int -SELinuxSetSavedStateLabel(virConnectPtr conn, +SELinuxSetSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm, const char *savefile) { @@ -673,12 +672,12 @@ SELinuxSetSavedStateLabel(virConnectPtr conn, if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC) return 0; - return SELinuxSetFilecon(conn, savefile, secdef->imagelabel); + return SELinuxSetFilecon(savefile, secdef->imagelabel); } static int -SELinuxRestoreSavedStateLabel(virConnectPtr conn, +SELinuxRestoreSavedStateLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm, const char *savefile) { @@ -687,7 +686,7 @@ SELinuxRestoreSavedStateLabel(virConnectPtr conn, if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC) return 0; - return SELinuxRestoreSecurityFileLabel(conn, savefile); + return SELinuxRestoreSecurityFileLabel(savefile); } @@ -727,7 +726,7 @@ SELinuxSetSecurityProcessLabel(virConnectPtr conn, } if (setexeccon(secdef->label) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("unable to set security context '%s'"), secdef->label); if (security_getenforce() == 1) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index b22c031..2e78168 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -113,9 +113,8 @@ enum { TOOL_QCOW_CREATE, }; -static int ATTRIBUTE_NONNULL (3) -virStorageBackendCopyToFD(virConnectPtr conn, - virStorageVolDefPtr vol, +static int ATTRIBUTE_NONNULL (2) +virStorageBackendCopyToFD(virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, int fd, unsigned long long *total, @@ -130,7 +129,7 @@ virStorageBackendCopyToFD(virConnectPtr conn, char *buf = NULL; if ((inputfd = open(inputvol->target.path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("could not open input path '%s'"), inputvol->target.path); goto cleanup; @@ -152,7 +151,7 @@ virStorageBackendCopyToFD(virConnectPtr conn, bytes = remain; if ((amtread = saferead(inputfd, buf, bytes)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed reading from file '%s'"), inputvol->target.path); goto cleanup; @@ -168,13 +167,13 @@ virStorageBackendCopyToFD(virConnectPtr conn, if (is_dest_file && memcmp(buf+offset, zerobuf, interval) == 0) { if (lseek(fd, interval, SEEK_CUR) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot extend file '%s'"), vol->target.path); goto cleanup; } } else if (safewrite(fd, buf+offset, interval) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed writing to file '%s'"), vol->target.path); goto cleanup; @@ -184,7 +183,7 @@ virStorageBackendCopyToFD(virConnectPtr conn, } if (inputfd != -1 && close(inputfd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot close file '%s'"), inputvol->target.path); goto cleanup; @@ -204,7 +203,7 @@ cleanup: } static int -virStorageBackendCreateBlockFrom(virConnectPtr conn, +virStorageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, @@ -218,7 +217,7 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn, uid_t uid; if ((fd = open(vol->target.path, O_RDWR)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot create path '%s'"), vol->target.path); goto cleanup; @@ -227,7 +226,7 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn, remain = vol->allocation; if (inputvol) { - int res = virStorageBackendCopyToFD(conn, vol, inputvol, + int res = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, 0); if (res < 0) goto cleanup; @@ -235,7 +234,7 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn, if (fstat(fd, &st) == -1) { ret = errno; - virReportSystemError(conn, errno, _("stat of '%s' failed"), + virReportSystemError(errno, _("stat of '%s' failed"), vol->target.path); goto cleanup; } @@ -243,20 +242,20 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn, gid = (vol->target.perms.gid != st.st_gid) ? vol->target.perms.gid : -1; if (((uid != -1) || (gid != -1)) && (fchown(fd, vol->target.perms.uid, vol->target.perms.gid) < 0)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"), vol->target.path, vol->target.perms.uid, vol->target.perms.gid); goto cleanup; } if (fchmod(fd, vol->target.perms.mode) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot set mode of '%s' to %04o"), vol->target.path, vol->target.perms.mode); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot close file '%s'"), vol->target.path); goto cleanup; @@ -295,14 +294,14 @@ virStorageBackendCreateRaw(virConnectPtr conn, vol->target.perms.uid, vol->target.perms.gid, (pool->def->type == VIR_STORAGE_POOL_NETFS ? VIR_FILE_CREATE_AS_UID : 0))) < 0) { - virReportSystemError(conn, createstat, + virReportSystemError(createstat, _("cannot create path '%s'"), vol->target.path); goto cleanup; } if ((fd = open(vol->target.path, O_RDWR | O_EXCL)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open new path '%s'"), vol->target.path); goto cleanup; @@ -311,7 +310,7 @@ virStorageBackendCreateRaw(virConnectPtr conn, /* Seek to the final size, so the capacity is available upfront * for progress reporting */ if (ftruncate(fd, vol->capacity) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot extend file '%s'"), vol->target.path); goto cleanup; @@ -320,7 +319,7 @@ virStorageBackendCreateRaw(virConnectPtr conn, remain = vol->allocation; if (inputvol) { - int res = virStorageBackendCopyToFD(conn, vol, inputvol, + int res = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, 1); if (res < 0) goto cleanup; @@ -341,7 +340,7 @@ virStorageBackendCreateRaw(virConnectPtr conn, bytes = remain; if ((r = safezero(fd, 0, vol->allocation - remain, bytes)) != 0) { - virReportSystemError(conn, r, + virReportSystemError(r, _("cannot fill file '%s'"), vol->target.path); goto cleanup; @@ -352,7 +351,7 @@ virStorageBackendCreateRaw(virConnectPtr conn, int r; if ((r = safezero(fd, 0, 0, remain)) != 0) { - virReportSystemError(conn, r, + virReportSystemError(r, _("cannot fill file '%s'"), vol->target.path); goto cleanup; @@ -361,7 +360,7 @@ virStorageBackendCreateRaw(virConnectPtr conn, } if (close(fd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot close file '%s'"), vol->target.path); goto cleanup; @@ -495,14 +494,14 @@ static int virStorageBuildSetUIDHook(void *data) { if ((vol->target.perms.gid != 0) && (setgid(vol->target.perms.gid) != 0)) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Cannot set gid to %u before creating %s"), vol->target.perms.gid, vol->target.path); return -1; } if ((vol->target.perms.uid != 0) && (setuid(vol->target.perms.uid) != 0)) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("Cannot set uid to %u before creating %s"), vol->target.perms.uid, vol->target.path); return -1; @@ -531,13 +530,13 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn, } if (!filecreated) { if (virRun(conn, cmdargv, NULL) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Cannot run %s to create %s"), cmdargv[0], vol->target.path); return -1; } if (stat(vol->target.path, &st) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("%s failed to create %s"), cmdargv[0], vol->target.path); return -1; @@ -548,14 +547,14 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn, gid = (vol->target.perms.gid != st.st_gid) ? vol->target.perms.gid : -1; if (((uid != -1) || (gid != -1)) && (chown(vol->target.path, uid, gid) < 0)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot chown %s to (%u, %u)"), vol->target.path, vol->target.perms.uid, vol->target.perms.gid); return -1; } if (chmod(vol->target.path, vol->target.perms.mode) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot set mode of '%s' to %04o"), vol->target.path, vol->target.perms.mode); return -1; @@ -655,7 +654,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, return -1; } if (access(vol->backingStore.path, R_OK) != 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("inaccessible backing store volume %s"), vol->backingStore.path); return -1; @@ -877,22 +876,20 @@ virStorageBackendForType(int type) { int -virStorageBackendUpdateVolTargetInfo(virConnectPtr conn, - virStorageVolTargetPtr target, +virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target, unsigned long long *allocation, unsigned long long *capacity) { int ret, fd; if ((fd = open(target->path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open volume '%s'"), target->path); return -1; } - ret = virStorageBackendUpdateVolTargetInfoFD(conn, - target, + ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, allocation, capacity); @@ -903,21 +900,18 @@ virStorageBackendUpdateVolTargetInfo(virConnectPtr conn, } int -virStorageBackendUpdateVolInfo(virConnectPtr conn, - virStorageVolDefPtr vol, +virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol, int withCapacity) { int ret; - if ((ret = virStorageBackendUpdateVolTargetInfo(conn, - &vol->target, + if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target, &vol->allocation, withCapacity ? &vol->capacity : NULL)) < 0) return ret; if (vol->backingStore.path && - (ret = virStorageBackendUpdateVolTargetInfo(conn, - &vol->backingStore, + (ret = virStorageBackendUpdateVolTargetInfo(&vol->backingStore, NULL, NULL)) < 0) return ret; @@ -936,8 +930,7 @@ virStorageBackendUpdateVolInfo(virConnectPtr conn, * -2 if passed FD isn't a regular, char, or block file. */ int -virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn, - virStorageVolTargetPtr target, +virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target, int fd, unsigned long long *allocation, unsigned long long *capacity) @@ -948,7 +941,7 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn, #endif if (fstat(fd, &sb) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot stat file '%s'"), target->path); return -1; @@ -981,7 +974,7 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn, */ end = lseek(fd, 0, SEEK_END); if (end == (off_t)-1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot seek to end of file '%s'"), target->path); return -1; @@ -1002,7 +995,7 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn, /* XXX: make this a security driver call */ if (fgetfilecon(fd, &filecon) == -1) { if (errno != ENODATA && errno != ENOTSUP) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot get file context of '%s'"), target->path); return -1; @@ -1059,8 +1052,7 @@ static struct diskType const disk_types[] = { int -virStorageBackendUpdateVolTargetFormatFD(virConnectPtr conn, - virStorageVolTargetPtr target, +virStorageBackendUpdateVolTargetFormatFD(virStorageVolTargetPtr target, int fd) { int i; @@ -1073,14 +1065,14 @@ virStorageBackendUpdateVolTargetFormatFD(virConnectPtr conn, start = lseek(fd, 0, SEEK_SET); if (start < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot seek to beginning of file '%s'"), target->path); return -1; } bytes = saferead(fd, buffer, sizeof(buffer)); if (bytes < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read beginning of file '%s'"), target->path); return -1; @@ -1114,8 +1106,7 @@ virStorageBackendUpdateVolTargetFormatFD(virConnectPtr conn, * with stable paths. */ char * -virStorageBackendStablePath(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendStablePath(virStoragePoolObjPtr pool, const char *devpath) { DIR *dh; @@ -1146,7 +1137,7 @@ virStorageBackendStablePath(virConnectPtr conn, usleep(100 * 1000); goto reopen; } - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read dir '%s'"), pool->def->target.path); return NULL; @@ -1338,7 +1329,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn, return -1; if (err == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to wait for command '%s'"), prog[0]); return -1; @@ -1434,7 +1425,7 @@ virStorageBackendRunProgNul(virConnectPtr conn, if (feof (fp)) err = 0; else - virReportSystemError(conn, errno, + virReportSystemError(errno, _("read error on pipe to '%s'"), prog[0]); cleanup: @@ -1455,7 +1446,7 @@ virStorageBackendRunProgNul(virConnectPtr conn, return -1; if (w_err == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to wait for command '%s'"), prog[0]); return -1; diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 988539c..a69aeee 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -83,26 +83,21 @@ struct _virStorageBackend { virStorageBackendPtr virStorageBackendForType(int type); -int virStorageBackendUpdateVolInfo(virConnectPtr conn, - virStorageVolDefPtr vol, +int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol, int withCapacity); -int virStorageBackendUpdateVolTargetInfo(virConnectPtr conn, - virStorageVolTargetPtr target, +int virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target, unsigned long long *allocation, unsigned long long *capacity); -int virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn, - virStorageVolTargetPtr target, +int virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target, int fd, unsigned long long *allocation, unsigned long long *capacity); int -virStorageBackendUpdateVolTargetFormatFD(virConnectPtr conn, - virStorageVolTargetPtr target, +virStorageBackendUpdateVolTargetFormatFD(virStorageVolTargetPtr target, int fd); -char *virStorageBackendStablePath(virConnectPtr conn, - virStoragePoolObjPtr pool, +char *virStorageBackendStablePath(virStoragePoolObjPtr pool, const char *devpath); typedef int (*virStorageBackendListVolRegexFunc)(virConnectPtr conn, diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 16eba4e..a86c193 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -82,7 +82,7 @@ virStorageBackendDiskMakeDataVol(virConnectPtr conn, * dir every time its run. Should figure out a more efficient * way of doing this... */ - vol->target.path = virStorageBackendStablePath(conn, pool, devpath); + vol->target.path = virStorageBackendStablePath(pool, devpath); VIR_FREE(devpath); if (vol->target.path == NULL) return -1; @@ -125,7 +125,7 @@ virStorageBackendDiskMakeDataVol(virConnectPtr conn, } /* Refresh allocation/capacity/perms */ - if (virStorageBackendUpdateVolInfo(conn, vol, 1) < 0) + if (virStorageBackendUpdateVolInfo(vol, 1) < 0) return -1; /* set partition type */ @@ -626,7 +626,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn, int rc = -1; if ((err = virFileResolveLink(vol->target.path, &devpath)) < 0) { - virReportSystemError(conn, err, + virReportSystemError(err, _("Couldn't read volume target path '%s'"), vol->target.path); goto cleanup; diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 47cdd6a..f1e1371 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -63,13 +63,13 @@ virStorageBackendProbeTarget(virConnectPtr conn, *encryption = NULL; if ((fd = open(target->path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open volume '%s'"), target->path); return -1; } - if ((ret = virStorageBackendUpdateVolTargetInfoFD(conn, target, fd, + if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, allocation, capacity)) < 0) { close(fd); @@ -254,14 +254,13 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn, * Return 0 if not mounted, 1 if mounted, -1 on error */ static int -virStorageBackendFileSystemIsMounted(virConnectPtr conn, - virStoragePoolObjPtr pool) { +virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool) { FILE *mtab; struct mntent ent; char buf[1024]; if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read mount list '%s'"), _PATH_MOUNTED); return -1; @@ -371,7 +370,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn, } /* Short-circuit if already mounted */ - if ((ret = virStorageBackendFileSystemIsMounted(conn, pool)) != 0) { + if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 0) { if (ret < 0) return -1; else @@ -447,7 +446,7 @@ virStorageBackendFileSystemUnmount(virConnectPtr conn, } /* Short-circuit if already unmounted */ - if ((ret = virStorageBackendFileSystemIsMounted(conn, pool)) != 1) { + if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 1) { if (ret < 0) return -1; else @@ -525,7 +524,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn, * exist, with default uid/gid/mode. */ *p = '\0'; if ((err = virFileMakePath(parent)) != 0) { - virReportSystemError(conn, err, _("cannot create path '%s'"), + virReportSystemError(err, _("cannot create path '%s'"), parent); goto error; } @@ -541,7 +540,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn, VIR_FILE_CREATE_ALLOW_EXIST | (pool->def->type == VIR_STORAGE_POOL_NETFS ? VIR_FILE_CREATE_AS_UID : 0)) != 0)) { - virReportSystemError(conn, err, _("cannot create path '%s'"), + virReportSystemError(err, _("cannot create path '%s'"), pool->def->target.path); goto error; } @@ -566,7 +565,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn, virStorageVolDefPtr vol = NULL; if (!(dir = opendir(pool->def->target.path))) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open path '%s'"), pool->def->target.path); goto cleanup; @@ -625,8 +624,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn, memmove(backingStore, path, strlen(path) + 1); vol->backingStore.path = backingStore; - if (virStorageBackendUpdateVolTargetInfo(conn, - &vol->backingStore, + if (virStorageBackendUpdateVolTargetInfo(&vol->backingStore, NULL, NULL) < 0) VIR_FREE(vol->backingStore); @@ -662,7 +660,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn, if (statvfs(pool->def->target.path, &sb) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot statvfs path '%s'"), pool->def->target.path); return -1; @@ -722,14 +720,14 @@ virStorageBackendFileSystemStop(virConnectPtr conn, * Returns 0 on success, -1 on error */ static int -virStorageBackendFileSystemDelete(virConnectPtr conn, +virStorageBackendFileSystemDelete(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { /* XXX delete all vols first ? */ if (rmdir(pool->def->target.path) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to remove pool '%s'"), pool->def->target.path); return -1; @@ -789,7 +787,7 @@ static int createFileDir(virConnectPtr conn, vol->target.perms.uid, vol->target.perms.gid, (pool->def->type == VIR_STORAGE_POOL_NETFS ? VIR_FILE_CREATE_AS_UID : 0))) != 0) { - virReportSystemError(conn, err, _("cannot create path '%s'"), + virReportSystemError(err, _("cannot create path '%s'"), vol->target.path); return -1; } @@ -867,7 +865,7 @@ virStorageBackendFileSystemVolBuildFrom(virConnectPtr conn, * Remove a volume - just unlinks for now */ static int -virStorageBackendFileSystemVolDelete(virConnectPtr conn, +virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned int flags ATTRIBUTE_UNUSED) @@ -875,7 +873,7 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn, if (unlink(vol->target.path) < 0) { /* Silently ignore failures where the vol has already gone away */ if (errno != ENOENT) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot unlink file '%s'"), vol->target.path); return -1; @@ -896,7 +894,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn, int ret; /* Refresh allocation / permissions info in case its changed */ - ret = virStorageBackendUpdateVolInfo(conn, vol, 0); + ret = virStorageBackendUpdateVolInfo(vol, 0); if (ret < 0) return ret; diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 74e63f3..8a93edc 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -418,7 +418,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn, "/sys/class/iscsi_session/session%s/device", session); if (virStorageBackendSCSIGetHostNumber(conn, sysfs_path, &host) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to get host number for iSCSI session " "with path '%s'"), sysfs_path); @@ -426,7 +426,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn, } if (virStorageBackendSCSIFindLUs(conn, pool, host) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to find LUs on host %u"), host); retval = -1; } diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 8caf8cb..06ae865 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -132,7 +132,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn, return -1; } - if (virStorageBackendUpdateVolInfo(conn, vol, 1) < 0) + if (virStorageBackendUpdateVolInfo(vol, 1) < 0) return -1; @@ -406,20 +406,20 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn, * rather than trying to figure out if we're a disk or partition */ if ((fd = open(pool->def->source.devices[i].path, O_WRONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open device '%s'"), pool->def->source.devices[i].path); goto cleanup; } if (safewrite(fd, zeros, sizeof(zeros)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot clear device header of '%s'"), pool->def->source.devices[i].path); close(fd); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot close device '%s'"), pool->def->source.devices[i].path); goto cleanup; @@ -544,7 +544,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn, pvargv[1] = pool->def->source.devices[i].path; if (virRun(conn, pvargv, NULL) < 0) { error = -1; - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot remove PV device '%s'"), pool->def->source.devices[i].path); break; @@ -611,7 +611,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, return -1; if ((fd = open(vol->target.path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read path '%s'"), vol->target.path); goto cleanup; @@ -620,21 +620,21 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, /* We can only chown/grp if root */ if (getuid() == 0) { if (fchown(fd, vol->target.perms.uid, vol->target.perms.gid) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot set file owner '%s'"), vol->target.path); goto cleanup; } } if (fchmod(fd, vol->target.perms.mode) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot set file mode '%s'"), vol->target.path); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot close file '%s'"), vol->target.path); goto cleanup; @@ -643,7 +643,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, /* Fill in data about this new vol */ if (virStorageBackendLogicalFindLVs(conn, pool, vol) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot find newly created volume '%s'"), vol->target.path); goto cleanup; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index 029ff3b..87e0fc8 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -48,15 +48,14 @@ virStorageBackendMpathUpdateVolTargetInfo(virConnectPtr conn, int fd = -1; if ((fd = open(target->path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open volume '%s'"), target->path); ret = -1; goto out; } - if (virStorageBackendUpdateVolTargetInfoFD(conn, - target, + if (virStorageBackendUpdateVolTargetInfoFD(target, fd, allocation, capacity) < 0) { @@ -69,9 +68,7 @@ virStorageBackendMpathUpdateVolTargetInfo(virConnectPtr conn, goto out; } - if (virStorageBackendUpdateVolTargetFormatFD(conn, - target, - fd) < 0) { + if (virStorageBackendUpdateVolTargetFormatFD(target, fd) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to update volume target format for '%s'"), target->path); diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 1405f10..505175d 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -61,7 +61,7 @@ getDeviceType(virConnectPtr conn, typefile = fopen(type_path, "r"); if (typefile == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Could not find typefile '%s'"), type_path); /* there was no type file; that doesn't seem right */ @@ -73,7 +73,7 @@ getDeviceType(virConnectPtr conn, fclose(typefile); if (gottype == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Could not read typefile '%s'"), type_path); /* we couldn't read the type file; have to give up */ @@ -132,8 +132,7 @@ static struct diskType const disk_types[] = { }; static int -virStorageBackendSCSIUpdateVolTargetInfo(virConnectPtr conn, - virStorageVolTargetPtr target, +virStorageBackendSCSIUpdateVolTargetInfo(virStorageVolTargetPtr target, unsigned long long *allocation, unsigned long long *capacity) { @@ -143,14 +142,13 @@ virStorageBackendSCSIUpdateVolTargetInfo(virConnectPtr conn, ssize_t bytes; if ((fd = open(target->path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open volume '%s'"), target->path); return -1; } - if (virStorageBackendUpdateVolTargetInfoFD(conn, - target, + if (virStorageBackendUpdateVolTargetInfoFD(target, fd, allocation, capacity) < 0) @@ -161,14 +159,14 @@ virStorageBackendSCSIUpdateVolTargetInfo(virConnectPtr conn, start = lseek(fd, 0, SEEK_SET); if (start < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot seek to beginning of file '%s'"), target->path); goto cleanup; } bytes = saferead(fd, buffer, sizeof(buffer)); if (bytes < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read beginning of file '%s'"), target->path); goto cleanup; @@ -233,8 +231,7 @@ virStorageBackendSCSINewLun(virConnectPtr conn, * dir every time its run. Should figure out a more efficient * way of doing this... */ - if ((vol->target.path = virStorageBackendStablePath(conn, - pool, + if ((vol->target.path = virStorageBackendStablePath(pool, devpath)) == NULL) { retval = -1; goto free_vol; @@ -251,8 +248,7 @@ virStorageBackendSCSINewLun(virConnectPtr conn, goto free_vol; } - if (virStorageBackendSCSIUpdateVolTargetInfo(conn, - &vol->target, + if (virStorageBackendSCSIUpdateVolTargetInfo(&vol->target, &vol->allocation, &vol->capacity) < 0) { @@ -293,7 +289,7 @@ out: static int -getNewStyleBlockDevice(virConnectPtr conn, +getNewStyleBlockDevice(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, const char *lun_path, const char *block_name ATTRIBUTE_UNUSED, char **block_device) @@ -312,7 +308,7 @@ getNewStyleBlockDevice(virConnectPtr conn, block_dir = opendir(block_path); if (block_dir == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to opendir sysfs path '%s'"), block_path); retval = -1; @@ -403,7 +399,7 @@ getBlockDevice(virConnectPtr conn, lun_dir = opendir(lun_path); if (lun_dir == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to opendir sysfs path '%s'"), lun_path); retval = -1; @@ -519,7 +515,7 @@ virStorageBackendSCSIFindLUs(virConnectPtr conn, devicedir = opendir(device_path); if (devicedir == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to opendir path '%s'"), device_path); retval = -1; goto out; @@ -562,7 +558,7 @@ virStorageBackendSCSIGetHostNumber(virConnectPtr conn, sysdir = opendir(sysfs_path); if (sysdir == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to opendir path '%s'"), sysfs_path); retval = -1; goto out; @@ -586,8 +582,7 @@ out: static int -virStorageBackendSCSITriggerRescan(virConnectPtr conn, - uint32_t host) +virStorageBackendSCSITriggerRescan(uint32_t host) { int fd = -1; int retval = 0; @@ -606,7 +601,7 @@ virStorageBackendSCSITriggerRescan(virConnectPtr conn, fd = open(path, O_WRONLY); if (fd < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Could not open '%s' to trigger host scan"), path); retval = -1; @@ -617,7 +612,7 @@ virStorageBackendSCSITriggerRescan(virConnectPtr conn, LINUX_SYSFS_SCSI_HOST_SCAN_STRING, sizeof(LINUX_SYSFS_SCSI_HOST_SCAN_STRING)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Write to '%s' to trigger host scan failed"), path); retval = -1; @@ -650,7 +645,7 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn, VIR_DEBUG(_("Scanning host%u"), host); - if (virStorageBackendSCSITriggerRescan(conn, host) < 0) { + if (virStorageBackendSCSITriggerRescan(host) < 0) { retval = -1; goto out; } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 0c805da..09153a2 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1014,14 +1014,14 @@ storagePoolSetAutostart(virStoragePoolPtr obj, int err; if ((err = virFileMakePath(driver->autostartDir))) { - virReportSystemError(obj->conn, err, + virReportSystemError(err, _("cannot create autostart directory %s"), driver->autostartDir); goto cleanup; } if (symlink(pool->configFile, pool->autostartLink) < 0) { - virReportSystemError(obj->conn, errno, + virReportSystemError(errno, _("Failed to create symlink '%s' to '%s'"), pool->autostartLink, pool->configFile); goto cleanup; @@ -1029,7 +1029,7 @@ storagePoolSetAutostart(virStoragePoolPtr obj, } else { if (unlink(pool->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { - virReportSystemError(obj->conn, errno, + virReportSystemError(errno, _("Failed to delete symlink '%s'"), pool->autostartLink); goto cleanup; @@ -1210,8 +1210,7 @@ storageVolumeLookupByPath(virConnectPtr conn, virStorageVolDefPtr vol; const char *stable_path; - stable_path = virStorageBackendStablePath(conn, - driver->pools.objs[i], + stable_path = virStorageBackendStablePath(driver->pools.objs[i], path); /* * virStorageBackendStablePath already does diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 52e8eec..14b467b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -514,7 +514,7 @@ static int testOpenDefault(virConnectPtr conn) { conn->privateData = privconn; if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("getting time of day")); goto error; } @@ -765,7 +765,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; if ((fd = open(file, O_RDONLY)) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("loading host definition file '%s'"), file); goto error; @@ -1712,40 +1712,40 @@ static int testDomainSave(virDomainPtr domain, VIR_DOMAIN_XML_SECURE); if (xml == NULL) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("saving domain '%s' failed to allocate space for metadata"), domain->name); goto cleanup; } if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("saving domain '%s' to '%s': open failed"), domain->name, path); goto cleanup; } len = strlen(xml); if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), domain->name, path); goto cleanup; } if (safewrite(fd, (char*)&len, sizeof(len)) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), domain->name, path); goto cleanup; } if (safewrite(fd, xml, len) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), domain->name, path); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("saving domain '%s' to '%s': write failed"), domain->name, path); goto cleanup; @@ -1797,13 +1797,13 @@ static int testDomainRestore(virConnectPtr conn, int ret = -1; if ((fd = open(path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read domain image '%s'"), path); goto cleanup; } if (saferead(fd, magic, sizeof(magic)) != sizeof(magic)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("incomplete save header in '%s'"), path); goto cleanup; @@ -1814,7 +1814,7 @@ static int testDomainRestore(virConnectPtr conn, goto cleanup; } if (saferead(fd, (char*)&len, sizeof(len)) != sizeof(len)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to read metadata length in '%s'"), path); goto cleanup; @@ -1829,7 +1829,7 @@ static int testDomainRestore(virConnectPtr conn, goto cleanup; } if (saferead(fd, xml, len) != len) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("incomplete metdata in '%s'"), path); goto cleanup; } @@ -1892,19 +1892,19 @@ static int testDomainCoreDump(virDomainPtr domain, } if ((fd = open(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("domain '%s' coredump: failed to open %s"), domain->name, to); goto cleanup; } if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("domain '%s' coredump: failed to write header to %s"), domain->name, to); goto cleanup; } if (close(fd) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("domain '%s' coredump: write failed: %s"), domain->name, to); goto cleanup; @@ -2108,7 +2108,7 @@ static int testDomainGetVcpus(virDomainPtr domain, privdomdata = privdom->privateData; if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, "%s", _("getting time of day")); goto cleanup; } @@ -2603,7 +2603,7 @@ static int testDomainBlockStats(virDomainPtr domain, } if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, "%s", _("getting time of day")); goto error; } @@ -2658,7 +2658,7 @@ static int testDomainInterfaceStats(virDomainPtr domain, } if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, "%s", _("getting time of day")); goto error; } diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index d0aa219..6e7bc59 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -110,7 +110,7 @@ umlConnectTapDevice(virConnectPtr conn, int err; if ((err = brInit(&brctl))) { - virReportSystemError(conn, err, "%s", + virReportSystemError(err, "%s", _("cannot initialize bridge support")); goto error; } @@ -133,11 +133,11 @@ umlConnectTapDevice(virConnectPtr conn, _("Failed to add tap interface to bridge. " "%s is not a bridge device"), bridge); } else if (template_ifname) { - virReportSystemError(conn, err, + virReportSystemError(err, _("Failed to add tap interface to bridge '%s'"), bridge); } else { - virReportSystemError(conn, err, + virReportSystemError(err, _("Failed to add tap interface '%s' to bridge '%s'"), net->ifname, bridge); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2152dbf..732c3d4 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -109,8 +109,7 @@ static void umlDriverUnlock(struct uml_driver *driver) static int umlOpenMonitor(virConnectPtr conn, struct uml_driver *driver, virDomainObjPtr vm); -static int umlReadPidFile(virConnectPtr conn, - struct uml_driver *driver, +static int umlReadPidFile(struct uml_driver *driver, virDomainObjPtr vm); static int umlSetCloseExec(int fd) { @@ -313,7 +312,7 @@ reread: continue; } - if (umlReadPidFile(NULL, driver, dom) < 0) { + if (umlReadPidFile(driver, dom) < 0) { virDomainObjUnlock(dom); continue; } @@ -559,8 +558,7 @@ umlShutdown(void) { } -static int umlReadPidFile(virConnectPtr conn, - struct uml_driver *driver, +static int umlReadPidFile(struct uml_driver *driver, virDomainObjPtr vm) { int rc = -1; @@ -598,7 +596,7 @@ reopen: cleanup: if (rc != 0) - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to read pid: %s"), pidfile); VIR_FREE(pidfile); @@ -652,7 +650,7 @@ restat: } if ((priv->monitor = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot open socket")); return -1; } @@ -661,7 +659,7 @@ restat: sprintf(addr.sun_path + 1, "libvirt-uml-%u", vm->pid); VIR_DEBUG("Reply address for monitor is '%s'", addr.sun_path+1); if (bind(priv->monitor, (struct sockaddr *)&addr, sizeof addr) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot bind socket")); close(priv->monitor); priv->monitor = -1; @@ -717,7 +715,7 @@ static int umlMonitorCommand(virConnectPtr conn, req.version = MONITOR_VERSION; req.length = strlen(cmd); if (req.length > (MONITOR_BUFLEN-1)) { - virReportSystemError(conn, EINVAL, + virReportSystemError(EINVAL, _("cannot send too long command %s (%d bytes)"), cmd, req.length); return -1; @@ -730,7 +728,7 @@ static int umlMonitorCommand(virConnectPtr conn, if (sendto(priv->monitor, &req, sizeof req, 0, (struct sockaddr *)&addr, sizeof addr) != (sizeof req)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot send command %s"), cmd); return -1; @@ -740,7 +738,7 @@ static int umlMonitorCommand(virConnectPtr conn, addrlen = sizeof(addr); if (recvfrom(priv->monitor, &res, sizeof res, 0, (struct sockaddr *)&addr, &addrlen) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read reply %s"), cmd); goto error; @@ -832,14 +830,14 @@ static int umlStartVMDaemon(virConnectPtr conn, * in a sub-process so its hard to feed back a useful error */ if (stat(vm->def->os.kernel, &sb) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Cannot find UML kernel %s"), vm->def->os.kernel); return -1; } if (virFileMakePath(driver->logDir) != 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot create log directory %s"), driver->logDir); return -1; @@ -853,7 +851,7 @@ static int umlStartVMDaemon(virConnectPtr conn, if ((logfd = open(logfile, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("failed to create logfile %s"), logfile); VIR_FREE(logfile); @@ -862,7 +860,7 @@ static int umlStartVMDaemon(virConnectPtr conn, VIR_FREE(logfile); if (umlSetCloseExec(logfd) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("Unable to set VM logfile close-on-exec flag")); close(logfd); return -1; @@ -1739,21 +1737,21 @@ static int umlDomainSetAutostart(virDomainPtr dom, int err; if ((err = virFileMakePath(driver->autostartDir))) { - virReportSystemError(dom->conn, err, + virReportSystemError(err, _("cannot create autostart directory %s"), driver->autostartDir); goto cleanup; } if (symlink(configFile, autostartLink) < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Failed to create symlink '%s to '%s'"), autostartLink, configFile); goto cleanup; } } else { if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("Failed to delete symlink '%s'"), autostartLink); goto cleanup; @@ -1815,7 +1813,7 @@ umlDomainBlockPeek (virDomainPtr dom, /* The path is correct, now try to open it and get its size. */ fd = open (path, O_RDONLY); if (fd == -1) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("cannot open %s"), path); goto cleanup; } @@ -1826,7 +1824,7 @@ umlDomainBlockPeek (virDomainPtr dom, */ if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || saferead (fd, buffer, size) == (ssize_t) -1) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("cannot read %s"), path); goto cleanup; } diff --git a/src/util/hostusb.c b/src/util/hostusb.c index 11a0426..96ece38 100644 --- a/src/util/hostusb.c +++ b/src/util/hostusb.c @@ -100,7 +100,7 @@ static int usbFindBusByVendor(virConnectPtr conn, dir = opendir(USB_SYSFS "/devices"); if (!dir) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Could not open directory %s"), USB_SYSFS "/devices"); goto cleanup; diff --git a/src/util/pci.c b/src/util/pci.c index 12e6e91..bbaf235 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -617,10 +617,10 @@ pciTryPowerManagementReset(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev) } static int -pciInitDevice(virConnectPtr conn, pciDevice *dev) +pciInitDevice(pciDevice *dev) { if (pciOpenConfig(dev) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to open config space file '%s'"), dev->path); return -1; @@ -647,7 +647,7 @@ pciResetDevice(virConnectPtr conn, return -1; } - if (!dev->initted && pciInitDevice(conn, dev) < 0) + if (!dev->initted && pciInitDevice(dev) < 0) return -1; /* KVM will perform FLR when starting and stopping @@ -739,7 +739,7 @@ recheck: static int -pciBindDeviceToStub(virConnectPtr conn, pciDevice *dev, const char *driver) +pciBindDeviceToStub(pciDevice *dev, const char *driver) { char drvdir[PATH_MAX]; char path[PATH_MAX]; @@ -754,7 +754,7 @@ pciBindDeviceToStub(virConnectPtr conn, pciDevice *dev, const char *driver) */ pciDriverFile(path, sizeof(path), driver, "new_id"); if (virFileWriteStr(path, dev->id) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to add PCI device ID '%s' to %s"), dev->id, driver); return -1; @@ -767,7 +767,7 @@ pciBindDeviceToStub(virConnectPtr conn, pciDevice *dev, const char *driver) */ pciDeviceFile(path, sizeof(path), dev->name, "driver/unbind"); if (virFileExists(path) && virFileWriteStr(path, dev->name) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to unbind PCI device '%s'"), dev->name); return -1; } @@ -780,7 +780,7 @@ pciBindDeviceToStub(virConnectPtr conn, pciDevice *dev, const char *driver) /* Xen's pciback.ko wants you to use new_slot first */ pciDriverFile(path, sizeof(path), driver, "new_slot"); if (virFileExists(path) && virFileWriteStr(path, dev->name) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to add slot for PCI device '%s' to %s"), dev->name, driver); return -1; @@ -788,7 +788,7 @@ pciBindDeviceToStub(virConnectPtr conn, pciDevice *dev, const char *driver) pciDriverFile(path, sizeof(path), driver, "bind"); if (virFileWriteStr(path, dev->name) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to bind PCI device '%s' to %s"), dev->name, driver); return -1; @@ -800,7 +800,7 @@ pciBindDeviceToStub(virConnectPtr conn, pciDevice *dev, const char *driver) */ pciDriverFile(path, sizeof(path), driver, "remove_id"); if (virFileExists(path) && virFileWriteStr(path, dev->id) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to remove PCI ID '%s' from %s"), dev->id, driver); return -1; @@ -819,11 +819,11 @@ pciDettachDevice(virConnectPtr conn, pciDevice *dev) return -1; } - return pciBindDeviceToStub(conn, dev, driver); + return pciBindDeviceToStub(dev, driver); } static int -pciUnBindDeviceFromStub(virConnectPtr conn, pciDevice *dev, const char *driver) +pciUnBindDeviceFromStub(pciDevice *dev, const char *driver) { char drvdir[PATH_MAX]; char path[PATH_MAX]; @@ -835,7 +835,7 @@ pciUnBindDeviceFromStub(virConnectPtr conn, pciDevice *dev, const char *driver) if (virFileExists(drvdir) && virFileLinkPointsTo(path, drvdir)) { pciDriverFile(path, sizeof(path), driver, "unbind"); if (virFileWriteStr(path, dev->name) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to bind PCI device '%s' to %s"), dev->name, driver); return -1; @@ -845,7 +845,7 @@ pciUnBindDeviceFromStub(virConnectPtr conn, pciDevice *dev, const char *driver) /* Xen's pciback.ko wants you to use remove_slot on the specific device */ pciDriverFile(path, sizeof(path), driver, "remove_slot"); if (virFileExists(path) && virFileWriteStr(path, dev->name) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to remove slot for PCI device '%s' to %s"), dev->name, driver); return -1; @@ -860,7 +860,7 @@ pciUnBindDeviceFromStub(virConnectPtr conn, pciDevice *dev, const char *driver) pciDriverFile(path, sizeof(path), driver, "remove_id"); if (!virFileExists(drvdir) || virFileExists(path)) { if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to trigger a re-probe for PCI device '%s'"), dev->name); return -1; @@ -880,7 +880,7 @@ pciReAttachDevice(virConnectPtr conn, pciDevice *dev) return -1; } - return pciUnBindDeviceFromStub(conn, dev, driver); + return pciUnBindDeviceFromStub(dev, driver); } /* Certain hypervisors (like qemu/kvm) map the PCI bar(s) on @@ -1221,7 +1221,7 @@ int pciDeviceFileIterate(virConnectPtr conn, } if (!(dir = opendir(pcidir))) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open %s"), pcidir); goto cleanup; } @@ -1255,14 +1255,13 @@ cleanup: } static int -pciDeviceDownstreamLacksACS(virConnectPtr conn, - pciDevice *dev) +pciDeviceDownstreamLacksACS(pciDevice *dev) { uint16_t flags; uint16_t ctrl; unsigned int pos; - if (!dev->initted && pciInitDevice(conn, dev) < 0) + if (!dev->initted && pciInitDevice(dev) < 0) return -1; pos = dev->pcie_cap_pos; @@ -1319,7 +1318,7 @@ pciDeviceIsBehindSwitchLackingACS(virConnectPtr conn, pciDevice *tmp; int acs; - acs = pciDeviceDownstreamLacksACS(conn, parent); + acs = pciDeviceDownstreamLacksACS(parent); if (acs) { pciFreeDevice(conn, parent); diff --git a/src/util/processinfo.c b/src/util/processinfo.c index 66efa8b..5ae19f8 100644 --- a/src/util/processinfo.c +++ b/src/util/processinfo.c @@ -73,7 +73,7 @@ realloc: numcpus = numcpus << 2; goto realloc; } - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set CPU affinity on process %d"), pid); return -1; } @@ -89,7 +89,7 @@ realloc: } if (sched_setaffinity(pid, sizeof(mask), &mask) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set CPU affinity on process %d"), pid); return -1; } @@ -134,7 +134,7 @@ realloc: numcpus = numcpus << 2; goto realloc; } - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set CPU affinity on process %d"), pid); return -1; } @@ -148,7 +148,7 @@ realloc: CPU_ZERO(&mask); if (sched_getaffinity(pid, sizeof(mask), &mask) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set CPU affinity on process %d"), pid); return -1; } @@ -168,7 +168,7 @@ int virProcessInfoSetAffinity(pid_t pid ATTRIBUTE_UNUSED, size_t maplen ATTRIBUTE_UNUSED, int maxcpu ATTRIBUTE_UNUSED) { - virReportSystemError(NULL, ENOSYS, "%s", + virReportSystemError(ENOSYS, "%s", _("Process CPU affinity is not supported on this platform")); return -1; } @@ -178,7 +178,7 @@ int virProcessInfoGetAffinity(pid_t pid ATTRIBUTE_UNUSED, size_t maplen ATTRIBUTE_UNUSED, int maxcpu ATTRIBUTE_UNUSED) { - virReportSystemError(NULL, ENOSYS, "%s", + virReportSystemError(ENOSYS, "%s", _("Process CPU affinity is not supported on this platform")); return -1; } diff --git a/src/util/storage_file.c b/src/util/storage_file.c index 1a490ba..d78e236 100644 --- a/src/util/storage_file.c +++ b/src/util/storage_file.c @@ -286,7 +286,7 @@ virStorageFileGetMetadataFromFD(virConnectPtr conn, meta->format = VIR_STORAGE_FILE_RAW; if ((len = read(fd, head, sizeof(head))) < 0) { - virReportSystemError(conn, errno, _("cannot read header '%s'"), path); + virReportSystemError(errno, _("cannot read header '%s'"), path); return -1; } @@ -412,7 +412,7 @@ virStorageFileGetMetadata(virConnectPtr conn, int fd, ret; if ((fd = open(path, O_RDONLY)) < 0) { - virReportSystemError(conn, errno, _("cannot open file '%s'"), path); + virReportSystemError(errno, _("cannot open file '%s'"), path); return -1; } diff --git a/src/util/util.c b/src/util/util.c index d40a790..92b2958 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -345,13 +345,13 @@ __virExec(virConnectPtr conn, */ sigfillset(&newmask); if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot block signals")); return -1; } if ((null = open("/dev/null", O_RDONLY)) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot open %s"), "/dev/null"); goto cleanup; @@ -360,20 +360,20 @@ __virExec(virConnectPtr conn, if (outfd != NULL) { if (*outfd == -1) { if (pipe(pipeout) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot create pipe")); goto cleanup; } if ((flags & VIR_EXEC_NONBLOCK) && virSetNonBlock(pipeout[0]) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("Failed to set non-blocking file descriptor flag")); goto cleanup; } if (virSetCloseExec(pipeout[0]) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("Failed to set close-on-exec file descriptor flag")); goto cleanup; } @@ -389,20 +389,20 @@ __virExec(virConnectPtr conn, if (errfd != NULL) { if (*errfd == -1) { if (pipe(pipeerr) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("Failed to create pipe")); goto cleanup; } if ((flags & VIR_EXEC_NONBLOCK) && virSetNonBlock(pipeerr[0]) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("Failed to set non-blocking file descriptor flag")); goto cleanup; } if (virSetCloseExec(pipeerr[0]) == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("Failed to set close-on-exec file descriptor flag")); goto cleanup; } @@ -424,7 +424,7 @@ __virExec(virConnectPtr conn, virLogUnlock(); if (pid < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot fork child process")); goto cleanup; } @@ -443,7 +443,7 @@ __virExec(virConnectPtr conn, /* Restore our original signal mask now child is safely running */ if (pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot unblock signals")); return -1; } @@ -487,7 +487,7 @@ __virExec(virConnectPtr conn, and don't want to propagate that to children */ sigemptyset(&newmask); if (pthread_sigmask(SIG_SETMASK, &newmask, NULL) != 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot unblock signals")); _exit(1); } @@ -503,19 +503,19 @@ __virExec(virConnectPtr conn, close(i); if (dup2(infd >= 0 ? infd : null, STDIN_FILENO) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("failed to setup stdin file handle")); _exit(1); } if (childout > 0 && dup2(childout, STDOUT_FILENO) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("failed to setup stdout file handle")); _exit(1); } if (childerr > 0 && dup2(childerr, STDERR_FILENO) < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("failed to setup stderr file handle")); _exit(1); } @@ -533,20 +533,20 @@ __virExec(virConnectPtr conn, * the above errors with wait* */ if (flags & VIR_EXEC_DAEMON) { if (setsid() < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot become session leader")); _exit(1); } if (chdir("/") < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot change to root directory: %s")); _exit(1); } pid = fork(); if (pid < 0) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot fork child process")); _exit(1); } @@ -556,7 +556,7 @@ __virExec(virConnectPtr conn, kill(pid, SIGTERM); usleep(500*1000); kill(pid, SIGTERM); - virReportSystemError(conn, errno, + virReportSystemError(errno, _("could not write pidfile %s for %d"), pidfile, pid); _exit(1); @@ -583,7 +583,7 @@ __virExec(virConnectPtr conn, else execvp(argv[0], (char **) argv); - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot execute binary %s"), argv[0]); @@ -783,7 +783,7 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd, continue; pollerr: - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("poll error")); goto error; } @@ -852,7 +852,7 @@ virRunWithHook(virConnectPtr conn, while ((waitret = waitpid(childpid, &exitstatus, 0) == -1) && errno == EINTR); if (waitret == -1) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot wait for '%s'"), argv[0]); goto error; @@ -996,14 +996,14 @@ int virFileReadAll(const char *path, int maxlen, char **buf) { int fd = open(path, O_RDONLY); if (fd < 0) { - virReportSystemError(NULL, errno, _("Failed to open file '%s'"), path); + virReportSystemError(errno, _("Failed to open file '%s'"), path); return -1; } int len = virFileReadLimFD(fd, maxlen, buf); close(fd); if (len < 0) { - virReportSystemError(NULL, errno, _("Failed to read file '%s'"), path); + virReportSystemError(errno, _("Failed to read file '%s'"), path); return -1; } @@ -1170,32 +1170,32 @@ static int virFileCreateSimple(const char *path, mode_t mode, uid_t uid, gid_t g if ((fd = open(path, open_flags, mode)) < 0) { ret = errno; - virReportSystemError(NULL, errno, _("failed to create file '%s'"), + virReportSystemError(errno, _("failed to create file '%s'"), path); goto error; } if (fstat(fd, &st) == -1) { ret = errno; - virReportSystemError(NULL, errno, _("stat of '%s' failed"), path); + virReportSystemError(errno, _("stat of '%s' failed"), path); goto error; } if (((st.st_uid != uid) || (st.st_gid != gid)) && (fchown(fd, uid, gid) < 0)) { ret = errno; - virReportSystemError(NULL, errno, _("cannot chown '%s' to (%u, %u)"), + virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"), path, uid, gid); goto error; } if (fchmod(fd, mode) < 0) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set mode of '%s' to %04o"), path, mode); goto error; } if (close(fd) < 0) { ret = errno; - virReportSystemError(NULL, errno, _("failed to close new file '%s'"), + virReportSystemError(errno, _("failed to close new file '%s'"), path); fd = -1; goto error; @@ -1216,26 +1216,26 @@ static int virDirCreateSimple(const char *path, mode_t mode, uid_t uid, gid_t gi && !((errno == EEXIST) && (flags & VIR_FILE_CREATE_ALLOW_EXIST))) { ret = errno; - virReportSystemError(NULL, errno, _("failed to create directory '%s'"), + virReportSystemError(errno, _("failed to create directory '%s'"), path); goto error; } if (stat(path, &st) == -1) { ret = errno; - virReportSystemError(NULL, errno, _("stat of '%s' failed"), path); + virReportSystemError(errno, _("stat of '%s' failed"), path); goto error; } if (((st.st_uid != uid) || (st.st_gid != gid)) && (chown(path, uid, gid) < 0)) { ret = errno; - virReportSystemError(NULL, errno, _("cannot chown '%s' to (%u, %u)"), + virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"), path, uid, gid); goto error; } if (chmod(path, mode) < 0) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set mode of '%s' to %04o"), path, mode); goto error; @@ -1270,7 +1270,7 @@ int virFileCreate(const char *path, mode_t mode, if (pid < 0) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot fork o create file '%s'"), path); return ret; } @@ -1281,7 +1281,7 @@ int virFileCreate(const char *path, mode_t mode, && (errno == EINTR)); if (waitret == -1) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("failed to wait for child creating '%s'"), path); goto parenterror; @@ -1300,21 +1300,21 @@ int virFileCreate(const char *path, mode_t mode, * setgid. If not, try doing it with chown */ if (stat(path, &st) == -1) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("stat of '%s' failed"), path); goto parenterror; } if ((st.st_gid != gid) && (chown(path, -1, gid) < 0)) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot chown '%s' to group %u"), path, gid); goto parenterror; } if (chmod(path, mode) < 0) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set mode of '%s' to %04o"), path, mode); goto parenterror; @@ -1327,14 +1327,14 @@ parenterror: if ((gid != 0) && (setgid(gid) != 0)) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set gid %u creating '%s'"), gid, path); goto childerror; } if ((uid != 0) && (setuid(uid) != 0)) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set uid %u creating '%s'"), uid, path); goto childerror; @@ -1343,7 +1343,7 @@ parenterror: ret = errno; if (ret != EACCES) { /* in case of EACCES, the parent will retry */ - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("child failed to create file '%s'"), path); } @@ -1351,7 +1351,7 @@ parenterror: } if (close(fd) < 0) { ret = errno; - virReportSystemError(NULL, errno, _("child failed to close new file '%s'"), + virReportSystemError(errno, _("child failed to close new file '%s'"), path); goto childerror; } @@ -1380,7 +1380,7 @@ int virDirCreate(const char *path, mode_t mode, if (pid < 0) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot fork to create directory '%s'"), path); return ret; @@ -1391,7 +1391,7 @@ int virDirCreate(const char *path, mode_t mode, while ((waitret = waitpid(pid, &status, 0) == -1) && (errno == EINTR)); if (waitret == -1) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("failed to wait for child creating '%s'"), path); goto parenterror; @@ -1410,20 +1410,20 @@ int virDirCreate(const char *path, mode_t mode, * setgid. If not, try doing it with chown */ if (stat(path, &st) == -1) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("stat of '%s' failed"), path); goto parenterror; } if ((st.st_gid != gid) && (chown(path, -1, gid) < 0)) { ret = errno; - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot chown '%s' to group %u"), path, gid); goto parenterror; } if (chmod(path, mode) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot set mode of '%s' to %04o"), path, mode); goto parenterror; @@ -1436,13 +1436,13 @@ parenterror: if ((gid != 0) && (setgid(gid) != 0)) { ret = errno; - virReportSystemError(NULL, errno, _("cannot set gid %u creating '%s'"), + virReportSystemError(errno, _("cannot set gid %u creating '%s'"), gid, path); goto childerror; } if ((uid != 0) && (setuid(uid) != 0)) { ret = errno; - virReportSystemError(NULL, errno, _("cannot set uid %u creating '%s'"), + virReportSystemError(errno, _("cannot set uid %u creating '%s'"), uid, path); goto childerror; } @@ -1450,7 +1450,7 @@ parenterror: ret = errno; if (ret != EACCES) { /* in case of EACCES, the parent will retry */ - virReportSystemError(NULL, errno, _("child failed to create directory '%s'"), + virReportSystemError(errno, _("child failed to create directory '%s'"), path); } goto childerror; @@ -2213,8 +2213,8 @@ char *virGetHostname(virConnectPtr conn) r = gethostname (hostname, sizeof(hostname)); if (r == -1) { - virReportSystemError (conn, errno, - "%s", _("failed to determine host name")); + virReportSystemError(errno, + "%s", _("failed to determine host name")); return NULL; } NUL_TERMINATE(hostname); @@ -2338,8 +2338,7 @@ enum { VIR_USER_ENT_NAME, }; -static char *virGetUserEnt(virConnectPtr conn, - uid_t uid, +static char *virGetUserEnt(uid_t uid, int field) { char *strbuf; @@ -2350,7 +2349,7 @@ static char *virGetUserEnt(virConnectPtr conn, size_t strbuflen = val; if (val < 0) { - virReportSystemError(conn, errno, "%s", _("sysconf failed")); + virReportSystemError(errno, "%s", _("sysconf failed")); return NULL; } @@ -2367,7 +2366,7 @@ static char *virGetUserEnt(virConnectPtr conn, * The given name or uid was not found. */ if (getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to find user record for uid '%d'"), uid); VIR_FREE(strbuf); @@ -2386,20 +2385,20 @@ static char *virGetUserEnt(virConnectPtr conn, return ret; } -char *virGetUserDirectory(virConnectPtr conn, +char *virGetUserDirectory(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, uid_t uid) { - return virGetUserEnt(conn, uid, VIR_USER_ENT_DIRECTORY); + return virGetUserEnt(uid, VIR_USER_ENT_DIRECTORY); } -char *virGetUserName(virConnectPtr conn, +char *virGetUserName(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, uid_t uid) { - return virGetUserEnt(conn, uid, VIR_USER_ENT_NAME); + return virGetUserEnt(uid, VIR_USER_ENT_NAME); } -int virGetUserID(virConnectPtr conn, +int virGetUserID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, const char *name, uid_t *uid) { @@ -2410,7 +2409,7 @@ int virGetUserID(virConnectPtr conn, size_t strbuflen = val; if (val < 0) { - virReportSystemError(conn, errno, "%s", _("sysconf failed")); + virReportSystemError(errno, "%s", _("sysconf failed")); return -1; } @@ -2427,7 +2426,7 @@ int virGetUserID(virConnectPtr conn, * The given name or uid was not found. */ if (getpwnam_r(name, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to find user record for name '%s'"), name); VIR_FREE(strbuf); @@ -2442,7 +2441,7 @@ int virGetUserID(virConnectPtr conn, } -int virGetGroupID(virConnectPtr conn, +int virGetGroupID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, const char *name, gid_t *gid) { @@ -2453,7 +2452,7 @@ int virGetGroupID(virConnectPtr conn, size_t strbuflen = val; if (val < 0) { - virReportSystemError(conn, errno, "%s", _("sysconf failed")); + virReportSystemError(errno, "%s", _("sysconf failed")); return -1; } @@ -2470,7 +2469,7 @@ int virGetGroupID(virConnectPtr conn, * The given name or uid was not found. */ if (getgrnam_r(name, &grbuf, strbuf, strbuflen, &gr) != 0 || gr == NULL) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("Failed to find group record for name '%s'"), name); VIR_FREE(strbuf); diff --git a/src/util/virterror.c b/src/util/virterror.c index 1454ea0..bbf5021 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -1197,7 +1197,6 @@ const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen) /** * virReportSystemErrorFull: - * @conn: the hyperisor connection * @domcode: the virErrorDomain indicating where it's coming from * @theerrno: an errno number * @filename: filename where error was raised @@ -1208,8 +1207,7 @@ const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen) * * Convenience internal routine called when a system error is detected. */ -void virReportSystemErrorFull(virConnectPtr conn, - int domcode, +void virReportSystemErrorFull(int domcode, int theerrno, const char *filename, const char *funcname, @@ -1243,7 +1241,7 @@ void virReportSystemErrorFull(virConnectPtr conn, if (!msgDetail) msgDetail = errnoDetail; - virRaiseErrorFull(conn, filename, funcname, linenr, + virRaiseErrorFull(NULL, filename, funcname, linenr, domcode, VIR_ERR_SYSTEM_ERROR, VIR_ERR_ERROR, msg, msgDetail, NULL, -1, -1, msg, msgDetail); } diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h index e4b644c..fba3078 100644 --- a/src/util/virterror_internal.h +++ b/src/util/virterror_internal.h @@ -63,18 +63,16 @@ void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode, const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(7, 8); -void virReportSystemErrorFull(virConnectPtr conn, - int domcode, +void virReportSystemErrorFull(int domcode, int theerrno, const char *filename, const char *funcname, size_t linenr, const char *fmt, ...) - ATTRIBUTE_FMT_PRINTF(7, 8); + ATTRIBUTE_FMT_PRINTF(6, 7); -#define virReportSystemError(conn, theerrno, fmt,...) \ - virReportSystemErrorFull((conn), \ - VIR_FROM_THIS, \ +#define virReportSystemError(theerrno, fmt,...) \ + virReportSystemErrorFull(VIR_FROM_THIS, \ (theerrno), \ __FILE__, __FUNCTION__, __LINE__, \ (fmt), __VA_ARGS__) diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c index e37bce1..300618b 100644 --- a/src/xen/proxy_internal.c +++ b/src/xen/proxy_internal.c @@ -377,7 +377,7 @@ xenProxyCommand(virConnectPtr conn, virProxyPacketPtr request, request->len); if (ret < 0) { if (!quiet) - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("failed to write proxy request")); goto error; } @@ -388,7 +388,7 @@ retry: sizeof(virProxyPacket)); if (ret < 0) { if (!quiet) - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("failed to read proxy reply")); goto error; } @@ -411,7 +411,7 @@ retry: sizeof(virProxyPacket)); if (ret < 0) { if (!quiet) - virReportSystemError(conn, errno, "%s", + virReportSystemError(errno, "%s", _("failed to read proxy reply")); goto error; } diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 13a5d3d..bdb0c3c 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2368,7 +2368,7 @@ get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode) if ((fd = open("/dev/cpu/self/cpuid", O_RDONLY)) == -1 || pread(fd, ®s, sizeof(regs), 0) != sizeof(regs)) { - virReportSystemError(conn, errno, "%s", _("could not read CPU flags")); + virReportSystemError(errno, "%s", _("could not read CPU flags")); goto out; } @@ -2649,7 +2649,7 @@ xenHypervisorMakeCapabilities(virConnectPtr conn) cpuinfo = fopen ("/proc/cpuinfo", "r"); if (cpuinfo == NULL) { if (errno != ENOENT) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read file %s"), "/proc/cpuinfo"); return NULL; @@ -2660,7 +2660,7 @@ xenHypervisorMakeCapabilities(virConnectPtr conn) if (capabilities == NULL) { if (errno != ENOENT) { fclose(cpuinfo); - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read file %s"), "/sys/hypervisor/properties/capabilities"); return NULL; diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c index 2445b58..b061439 100644 --- a/src/xen/xen_inotify.c +++ b/src/xen/xen_inotify.c @@ -403,7 +403,7 @@ xenInotifyOpen(virConnectPtr conn, /* populate initial list */ if (!(dh = opendir(priv->configDir))) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("cannot open directory: %s"), priv->configDir); return -1; @@ -431,7 +431,7 @@ xenInotifyOpen(virConnectPtr conn, } if ((priv->inotifyFD = inotify_init()) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, "%s", _("initializing inotify")); return -1; } @@ -442,7 +442,7 @@ xenInotifyOpen(virConnectPtr conn, IN_CREATE | IN_CLOSE_WRITE | IN_DELETE | IN_MOVED_TO | IN_MOVED_FROM) < 0) { - virReportSystemError(NULL, errno, + virReportSystemError(errno, _("adding watch on %s"), priv->configDir); return -1; diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 402a209..bbe2f29 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -845,7 +845,7 @@ xenDaemonOpen_tcp(virConnectPtr conn, const char *host, const char *port) if (!priv->addrlen) { /* Don't raise error when unprivileged, since proxy takes over */ if (xenHavePrivilege()) - virReportSystemError(conn, saved_errno, + virReportSystemError(saved_errno, _("unable to connect to '%s:%s'"), host, port); return -1; @@ -5106,7 +5106,7 @@ xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path, /* The path is correct, now try to open it and get its size. */ fd = open (path, O_RDONLY); if (fd == -1) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("failed to open for reading: %s"), path); goto cleanup; @@ -5118,7 +5118,7 @@ xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path, */ if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || saferead (fd, buffer, size) == (ssize_t) -1) { - virReportSystemError(domain->conn, errno, + virReportSystemError(errno, _("failed to lseek or read from file: %s"), path); goto cleanup; diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 23e11d7..1dc0f5b 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -395,7 +395,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename) /* Get modified time */ if ((stat(filename, &st) < 0)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot stat: %s"), filename); return -1; @@ -492,7 +492,7 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) { struct xenXMConfigReaperData args; if (now == ((time_t)-1)) { - virReportSystemError(conn, errno, + virReportSystemError(errno, "%s", _("cannot get time of day")); return (-1); } @@ -505,7 +505,7 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) { /* Process the files in the config dir */ if (!(dh = opendir(priv->configDir))) { - virReportSystemError(conn, errno, + virReportSystemError(errno, _("cannot read directory %s"), priv->configDir); return (-1); @@ -3143,7 +3143,7 @@ int xenXMDomainGetAutostart(virDomainPtr dom, int *autostart) *autostart = virFileLinkPointsTo(linkname, config); if (*autostart < 0) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("cannot check link %s points to config %s"), linkname, config); goto cleanup; @@ -3172,7 +3172,7 @@ int xenXMDomainSetAutostart(virDomainPtr dom, int autostart) if (autostart) { if (symlink(config, linkname) < 0 && errno != EEXIST) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("failed to create link %s to %s"), config, linkname); goto cleanup; @@ -3180,7 +3180,7 @@ int xenXMDomainSetAutostart(virDomainPtr dom, int autostart) } else { if (unlink(linkname) < 0 && errno != ENOENT) { - virReportSystemError(dom->conn, errno, + virReportSystemError(errno, _("failed to remove link %s"), linkname); goto cleanup; -- 1.6.3.3

It was used for error reporting only. --- ...-Step-7-of-8-Implement-the-driver-methods.patch | 8 +- src/conf/cpu_conf.c | 18 ++-- src/conf/domain_conf.c | 98 ++++++++++---------- src/conf/interface_conf.c | 70 +++++++------- src/conf/network_conf.c | 24 +++--- src/conf/node_device_conf.c | 70 +++++++------- src/conf/secret_conf.c | 15 ++-- src/conf/storage_conf.c | 69 +++++++------- src/conf/storage_encryption_conf.c | 8 +- src/cpu/cpu_map.c | 2 +- src/cpu/cpu_x86.c | 22 ++-- src/esx/esx_vi.c | 7 +- src/qemu/qemu_driver.c | 8 +- src/security/virt-aa-helper.c | 4 +- src/test/test_driver.c | 28 +++--- src/util/xml.c | 73 ++++++--------- src/util/xml.h | 38 +++----- 17 files changed, 267 insertions(+), 295 deletions(-) diff --git a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch index 7586cd4..09ddc65 100644 --- a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch +++ b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch @@ -550,7 +550,7 @@ index 6e04112..5b35b60 100644 +{ + char *s; + -+ s = virXPathString(conn, xpath, ctxt); ++ s = virXPathString(xpath, ctxt); + if (s == NULL) { + virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, + missing_error_fmt, @@ -611,7 +611,7 @@ index 6e04112..5b35b60 100644 goto out; + } + -+ if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) < 0) { ++ if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { + virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("error parsing SCSI host capabilities for '%s'"), + def->name); @@ -713,9 +713,9 @@ index 6e04112..5b35b60 100644 } /* Extract device name */ -- def->name = virXPathString(conn, "string(./name[1])", ctxt); +- def->name = virXPathString("string(./name[1])", ctxt); + if (create == EXISTING_DEVICE) { -+ def->name = virXPathString(conn, "string(./name[1])", ctxt); ++ def->name = virXPathString("string(./name[1])", ctxt); + } else { + def->name = strdup("new device"); + } diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 002fde3..fabbede 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -85,7 +85,7 @@ virCPUDefParseXML(virConnectPtr conn, } if (mode == VIR_CPU_TYPE_AUTO) { - if (virXPathBoolean(conn, "boolean(./arch)", ctxt)) + if (virXPathBoolean("boolean(./arch)", ctxt)) def->type = VIR_CPU_TYPE_HOST; else def->type = VIR_CPU_TYPE_GUEST; @@ -96,7 +96,7 @@ virCPUDefParseXML(virConnectPtr conn, char *match = virXMLPropString(node, "match"); if (!match) { - if (virXPathBoolean(conn, "boolean(./model)", ctxt)) { + if (virXPathBoolean("boolean(./model)", ctxt)) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing match attribute for CPU specification")); goto error; @@ -115,7 +115,7 @@ virCPUDefParseXML(virConnectPtr conn, } if (def->type == VIR_CPU_TYPE_HOST) { - def->arch = virXPathString(conn, "string(./arch[1])", ctxt); + def->arch = virXPathString("string(./arch[1])", ctxt); if (!def->arch) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU architecture")); @@ -123,18 +123,18 @@ virCPUDefParseXML(virConnectPtr conn, } } - if (!(def->model = virXPathString(conn, "string(./model[1])", ctxt)) && + if (!(def->model = virXPathString("string(./model[1])", ctxt)) && def->type == VIR_CPU_TYPE_HOST) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU model name")); goto error; } - if (virXPathNode(conn, "./topology[1]", ctxt)) { + if (virXPathNode("./topology[1]", ctxt)) { int ret; unsigned long ul; - ret = virXPathULong(conn, "string(./topology[1]/@sockets)", + ret = virXPathULong("string(./topology[1]/@sockets)", ctxt, &ul); if (ret < 0) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -143,7 +143,7 @@ virCPUDefParseXML(virConnectPtr conn, } def->sockets = (unsigned int) ul; - ret = virXPathULong(conn, "string(./topology[1]/@cores)", + ret = virXPathULong("string(./topology[1]/@cores)", ctxt, &ul); if (ret < 0) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -152,7 +152,7 @@ virCPUDefParseXML(virConnectPtr conn, } def->cores = (unsigned int) ul; - ret = virXPathULong(conn, "string(./topology[1]/@threads)", + ret = virXPathULong("string(./topology[1]/@threads)", ctxt, &ul); if (ret < 0) { virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -168,7 +168,7 @@ virCPUDefParseXML(virConnectPtr conn, } } - n = virXPathNodeSet(conn, "./feature", ctxt, &nodes); + n = virXPathNodeSet("./feature", ctxt, &nodes); if (n < 0) goto error; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index daa63a9..811cd38 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3029,7 +3029,7 @@ static int virDomainLifecycleParseXML(virConnectPtr conn, int *val, int defaultVal) { - char *tmp = virXPathString(conn, xpath, ctxt); + char *tmp = virXPathString(xpath, ctxt); if (tmp == NULL) { *val = defaultVal; } else { @@ -3053,10 +3053,10 @@ virSecurityLabelDefParseXML(virConnectPtr conn, { char *p; - if (virXPathNode(conn, "./seclabel", ctxt) == NULL) + if (virXPathNode("./seclabel", ctxt) == NULL) return 0; - p = virXPathStringLimit(conn, "string(./seclabel/@type)", + p = virXPathStringLimit("string(./seclabel/@type)", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3076,7 +3076,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, */ if (def->seclabel.type == VIR_DOMAIN_SECLABEL_STATIC || !(flags & VIR_DOMAIN_XML_INACTIVE)) { - p = virXPathStringLimit(conn, "string(./seclabel/@model)", + p = virXPathStringLimit("string(./seclabel/@model)", VIR_SECURITY_MODEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3085,7 +3085,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, } def->seclabel.model = p; - p = virXPathStringLimit(conn, "string(./seclabel/label[1])", + p = virXPathStringLimit("string(./seclabel/label[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3099,7 +3099,7 @@ virSecurityLabelDefParseXML(virConnectPtr conn, /* Only parse imagelabel, if requested live XML for dynamic label */ if (def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC && !(flags & VIR_DOMAIN_XML_INACTIVE)) { - p = virXPathStringLimit(conn, "string(./seclabel/imagelabel[1])", + p = virXPathStringLimit("string(./seclabel/imagelabel[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -3357,12 +3357,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } if (!(flags & VIR_DOMAIN_XML_INACTIVE)) - if ((virXPathLong(conn, "string(./@id)", ctxt, &id)) < 0) + if ((virXPathLong("string(./@id)", ctxt, &id)) < 0) id = -1; def->id = (int)id; /* Find out what type of virtualization to use */ - if (!(tmp = virXPathString(conn, "string(./@type)", ctxt))) { + if (!(tmp = virXPathString("string(./@type)", ctxt))) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain type attribute")); goto error; @@ -3376,13 +3376,13 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(tmp); /* Extract domain name */ - if (!(def->name = virXPathString(conn, "string(./name[1])", ctxt))) { + if (!(def->name = virXPathString("string(./name[1])", ctxt))) { virDomainReportError(conn, VIR_ERR_NO_NAME, NULL); goto error; } /* Extract domain uuid */ - tmp = virXPathString(conn, "string(./uuid[1])", ctxt); + tmp = virXPathString("string(./uuid[1])", ctxt); if (!tmp) { if (virUUIDGenerate(def->uuid)) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -3399,26 +3399,26 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } /* Extract documentation if present */ - def->description = virXPathString(conn, "string(./description[1])", ctxt); + def->description = virXPathString("string(./description[1])", ctxt); /* Extract domain memory */ - if (virXPathULong(conn, "string(./memory[1])", ctxt, &def->maxmem) < 0) { + if (virXPathULong("string(./memory[1])", ctxt, &def->maxmem) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("missing memory element")); goto error; } - if (virXPathULong(conn, "string(./currentMemory[1])", ctxt, &def->memory) < 0) + if (virXPathULong("string(./currentMemory[1])", ctxt, &def->memory) < 0) def->memory = def->maxmem; - node = virXPathNode(conn, "./memoryBacking/hugepages", ctxt); + node = virXPathNode("./memoryBacking/hugepages", ctxt); if (node) def->hugepage_backed = 1; - if (virXPathULong(conn, "string(./vcpu[1])", ctxt, &def->vcpus) < 0) + if (virXPathULong("string(./vcpu[1])", ctxt, &def->vcpus) < 0) def->vcpus = 1; - tmp = virXPathString(conn, "string(./vcpu[1]/@cpuset)", ctxt); + tmp = virXPathString("string(./vcpu[1]/@cpuset)", ctxt); if (tmp) { char *set = tmp; def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN; @@ -3433,7 +3433,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(tmp); } - n = virXPathNodeSet(conn, "./features/*", ctxt, &nodes); + n = virXPathNodeSet("./features/*", ctxt, &nodes); if (n < 0) goto error; if (n) { @@ -3463,15 +3463,15 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; - tmp = virXPathString(conn, "string(./clock/@offset)", ctxt); + tmp = virXPathString("string(./clock/@offset)", ctxt); if (tmp && STREQ(tmp, "localtime")) def->localtime = 1; VIR_FREE(tmp); - def->os.bootloader = virXPathString(conn, "string(./bootloader)", ctxt); - def->os.bootloaderArgs = virXPathString(conn, "string(./bootloader_args)", ctxt); + def->os.bootloader = virXPathString("string(./bootloader)", ctxt); + def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt); - def->os.type = virXPathString(conn, "string(./os/type[1])", ctxt); + def->os.type = virXPathString("string(./os/type[1])", ctxt); if (!def->os.type) { if (def->os.bootloader) { def->os.type = strdup("xen"); @@ -3505,7 +3505,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; } - def->os.arch = virXPathString(conn, "string(./os/type[1]/@arch)", ctxt); + 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, @@ -3527,7 +3527,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } } - def->os.machine = virXPathString(conn, "string(./os/type[1]/@machine)", ctxt); + def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt); if (!def->os.machine) { const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, def->os.type, @@ -3551,22 +3551,22 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, */ if (STREQ(def->os.type, "exe")) { - def->os.init = virXPathString(conn, "string(./os/init[1])", ctxt); + def->os.init = virXPathString("string(./os/init[1])", ctxt); } if (STREQ(def->os.type, "xen") || STREQ(def->os.type, "hvm") || STREQ(def->os.type, "uml")) { - def->os.kernel = virXPathString(conn, "string(./os/kernel[1])", ctxt); - def->os.initrd = virXPathString(conn, "string(./os/initrd[1])", ctxt); - def->os.cmdline = virXPathString(conn, "string(./os/cmdline[1])", ctxt); - def->os.root = virXPathString(conn, "string(./os/root[1])", ctxt); - def->os.loader = virXPathString(conn, "string(./os/loader[1])", ctxt); + def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt); + def->os.initrd = virXPathString("string(./os/initrd[1])", ctxt); + def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt); + def->os.root = virXPathString("string(./os/root[1])", ctxt); + def->os.loader = virXPathString("string(./os/loader[1])", ctxt); } if (STREQ(def->os.type, "hvm")) { /* analysis of the boot devices */ - if ((n = virXPathNodeSet(conn, "./os/boot", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract boot device")); goto error; @@ -3596,7 +3596,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); } - def->emulator = virXPathString(conn, "string(./devices/emulator[1])", ctxt); + def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); if (!def->emulator && virCapabilitiesIsEmulatorRequired(caps)) { def->emulator = virDomainDefDefaultEmulator(conn, def, caps); if (!def->emulator) @@ -3604,7 +3604,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } /* analysis of the disk devices */ - if ((n = virXPathNodeSet(conn, "./devices/disk", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract disk devices")); goto error; @@ -3623,7 +3623,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the controller devices */ - if ((n = virXPathNodeSet(conn, "./devices/controller", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract controller devices")); goto error; @@ -3648,7 +3648,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; /* analysis of the filesystems */ - if ((n = virXPathNodeSet(conn, "./devices/filesystem", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract filesystem devices")); goto error; @@ -3667,7 +3667,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the network devices */ - if ((n = virXPathNodeSet(conn, "./devices/interface", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract network devices")); goto error; @@ -3688,7 +3688,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the character devices */ - if ((n = virXPathNodeSet(conn, "./devices/parallel", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract parallel devices")); goto error; @@ -3708,7 +3708,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } VIR_FREE(nodes); - if ((n = virXPathNodeSet(conn, "./devices/serial", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract serial devices")); goto error; @@ -3728,7 +3728,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } VIR_FREE(nodes); - if ((node = virXPathNode(conn, "./devices/console[1]", ctxt)) != NULL) { + if ((node = virXPathNode("./devices/console[1]", ctxt)) != NULL) { virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, node, flags); @@ -3757,7 +3757,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } } - if ((n = virXPathNodeSet(conn, "./devices/channel", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract channel devices")); goto error; @@ -3778,7 +3778,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the input devices */ - if ((n = virXPathNodeSet(conn, "./devices/input", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract input devices")); goto error; @@ -3813,7 +3813,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the graphics devices */ - if ((n = virXPathNodeSet(conn, "./devices/graphics", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract graphics devices")); goto error; @@ -3857,7 +3857,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the sound devices */ - if ((n = virXPathNodeSet(conn, "./devices/sound", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract sound devices")); goto error; @@ -3876,7 +3876,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, VIR_FREE(nodes); /* analysis of the video devices */ - if ((n = virXPathNodeSet(conn, "./devices/video", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract video devices")); goto error; @@ -3917,7 +3917,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } /* analysis of the host devices */ - if ((n = virXPathNodeSet(conn, "./devices/hostdev", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract host devices")); goto error; @@ -3937,7 +3937,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, /* analysis of the watchdog devices */ def->watchdog = NULL; - if ((n = virXPathNodeSet(conn, "./devices/watchdog", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract watchdog devices")); goto error; @@ -3961,7 +3961,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (virSecurityLabelDefParseXML(conn, def, ctxt, flags) == -1) goto error; - if ((node = virXPathNode(conn, "./cpu[1]", ctxt)) != NULL) { + if ((node = virXPathNode("./cpu[1]", ctxt)) != NULL) { xmlNodePtr oldnode = ctxt->node; ctxt->node = node; def->cpu = virCPUDefParseXML(conn, node, ctxt, VIR_CPU_TYPE_GUEST); @@ -3998,7 +3998,7 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, if (!(obj = virDomainObjNew(conn, caps))) return NULL; - if (!(config = virXPathNode(conn, "./domain", ctxt))) { + if (!(config = virXPathNode("./domain", ctxt))) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("no domain config")); goto error; @@ -4012,7 +4012,7 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, if (!obj->def) goto error; - if (!(tmp = virXPathString(conn, "string(./@state)", ctxt))) { + if (!(tmp = virXPathString("string(./@state)", ctxt))) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain state")); goto error; @@ -4025,7 +4025,7 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn, } VIR_FREE(tmp); - if ((virXPathLong(conn, "string(./@pid)", ctxt, &val)) < 0) { + if ((virXPathLong("string(./@pid)", ctxt, &val)) < 0) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("invalid pid")); goto error; diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index b4d6243..c111385 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -122,7 +122,7 @@ virInterfaceDefParseName(virConnectPtr conn, virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { char *tmp; - tmp = virXPathString(conn, "string(./@name)", ctxt); + tmp = virXPathString("string(./@name)", ctxt); if (tmp == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("interface has no name")); @@ -138,7 +138,7 @@ virInterfaceDefParseMtu(virConnectPtr conn, virInterfaceDefPtr def, unsigned long mtu; int ret; - ret = virXPathULong(conn, "string(./mtu/@size)", ctxt, &mtu); + ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu); if ((ret == -2) || ((ret == 0) && (mtu > 100000))) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("interface mtu value is improper")); @@ -154,7 +154,7 @@ virInterfaceDefParseStartMode(virConnectPtr conn, virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { char *tmp; - tmp = virXPathString(conn, "string(./start/@mode)", ctxt); + tmp = virXPathString("string(./start/@mode)", ctxt); if (tmp == NULL) def->startmode = VIR_INTERFACE_START_UNSPECIFIED; else if (STREQ(tmp, "onboot")) @@ -178,7 +178,7 @@ virInterfaceDefParseBondMode(virConnectPtr conn, xmlXPathContextPtr ctxt) { char *tmp; int ret = 0; - tmp = virXPathString(conn, "string(./@mode)", ctxt); + tmp = virXPathString("string(./@mode)", ctxt); if (tmp == NULL) return(VIR_INTERFACE_BOND_NONE); if (STREQ(tmp, "balance-rr")) @@ -209,7 +209,7 @@ virInterfaceDefParseBondMiiCarrier(virConnectPtr conn, xmlXPathContextPtr ctxt) char *tmp; int ret = 0; - tmp = virXPathString(conn, "string(./miimon/@carrier)", ctxt); + tmp = virXPathString("string(./miimon/@carrier)", ctxt); if (tmp == NULL) return(VIR_INTERFACE_BOND_MII_NONE); if (STREQ(tmp, "ioctl")) @@ -230,7 +230,7 @@ virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) { char *tmp; int ret = 0; - tmp = virXPathString(conn, "string(./arpmon/@validate)", ctxt); + tmp = virXPathString("string(./arpmon/@validate)", ctxt); if (tmp == NULL) return(VIR_INTERFACE_BOND_ARP_NONE); if (STREQ(tmp, "active")) @@ -259,7 +259,7 @@ virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceProtocolDefPtr def, save = ctxt->node; ctxt->node = dhcp; /* Not much to do in the current version */ - tmp = virXPathString(conn, "string(./@peerdns)", ctxt); + tmp = virXPathString("string(./@peerdns)", ctxt); if (tmp) { if (STREQ(tmp, "yes")) def->peerdns = 1; @@ -285,10 +285,10 @@ virInterfaceDefParseIp(virConnectPtr conn, virInterfaceIpDefPtr def, char *tmp; long l; - tmp = virXPathString(conn, "string(./@address)", ctxt); + tmp = virXPathString("string(./@address)", ctxt); def->address = tmp; if (tmp != NULL) { - ret = virXPathLong(conn, "string(./@prefix)", ctxt, &l); + ret = virXPathLong("string(./@prefix)", ctxt, &l); if (ret == 0) def->prefix = (int) l; else if (ret == -2) { @@ -309,17 +309,17 @@ virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def int nIpNodes, ii, ret = -1; char *tmp; - tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt); + tmp = virXPathString("string(./route[1]/@gateway)", ctxt); def->gateway = tmp; - dhcp = virXPathNode(conn, "./dhcp", ctxt); + dhcp = virXPathNode("./dhcp", ctxt); if (dhcp != NULL) { ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt); if (ret != 0) return(ret); } - nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes); + nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes); if (nIpNodes < 0) return -1; if (ipNodes == NULL) @@ -364,21 +364,21 @@ virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def int nIpNodes, ii, ret = -1; char *tmp; - tmp = virXPathString(conn, "string(./route[1]/@gateway)", ctxt); + tmp = virXPathString("string(./route[1]/@gateway)", ctxt); def->gateway = tmp; - autoconf = virXPathNode(conn, "./autoconf", ctxt); + autoconf = virXPathNode("./autoconf", ctxt); if (autoconf != NULL) def->autoconf = 1; - dhcp = virXPathNode(conn, "./dhcp", ctxt); + dhcp = virXPathNode("./dhcp", ctxt); if (dhcp != NULL) { ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt); if (ret != 0) return(ret); } - nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes); + nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes); if (nIpNodes < 0) return -1; if (ipNodes == NULL) @@ -425,7 +425,7 @@ virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def, save = ctxt->node; - nProtoNodes = virXPathNodeSet(conn, "./protocol", ctxt, &protoNodes); + nProtoNodes = virXPathNodeSet("./protocol", ctxt, &protoNodes); if (nProtoNodes <= 0) { /* no protocols is an acceptable outcome */ return 0; @@ -447,7 +447,7 @@ virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def, } ctxt->node = protoNodes[pp]; - tmp = virXPathString(conn, "string(./@family)", ctxt); + tmp = virXPathString("string(./@family)", ctxt); if (tmp == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("protocol misses the family attribute")); @@ -495,7 +495,7 @@ virInterfaceDefParseBridge(virConnectPtr conn, virInterfaceDefPtr def, int ret = 0; bridge = ctxt->node; - nbItf = virXPathNodeSet(conn, "./interface", ctxt, &interfaces); + nbItf = virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf < 0) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bridge interfaces")); @@ -537,7 +537,7 @@ virInterfaceDefParseBondItfs(virConnectPtr conn, virInterfaceDefPtr def, int nbItf, i; int ret = 0; - nbItf = virXPathNodeSet(conn, "./interface", ctxt, &interfaces); + nbItf = virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf <= 0) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond has no interfaces")); @@ -583,11 +583,11 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, if (ret != 0) goto error; - node = virXPathNode(conn, "./miimon[1]", ctxt); + node = virXPathNode("./miimon[1]", ctxt); if (node != NULL) { def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_MII; - ret = virXPathULong(conn, "string(./miimon/@freq)", ctxt, &tmp); + ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp); if ((ret == -2) || (ret == -1)) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface miimon freq missing or invalid")); @@ -595,7 +595,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, } def->data.bond.frequency = (int) tmp; - ret = virXPathULong(conn, "string(./miimon/@downdelay)", ctxt, &tmp); + ret = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp); if (ret == -2) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface miimon downdelay invalid")); @@ -604,7 +604,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, def->data.bond.downdelay = (int) tmp; } - ret = virXPathULong(conn, "string(./miimon/@updelay)", ctxt, &tmp); + ret = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp); if (ret == -2) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface miimon updelay invalid")); @@ -619,11 +619,11 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, goto error; } - } else if ((node = virXPathNode(conn, "./arpmon[1]", ctxt)) != NULL) { + } else if ((node = virXPathNode("./arpmon[1]", ctxt)) != NULL) { def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_ARP; - ret = virXPathULong(conn, "string(./arpmon/@interval)", ctxt, &tmp); + ret = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp); if ((ret == -2) || (ret == -1)) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface arpmon interval missing or invalid")); @@ -632,7 +632,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, def->data.bond.interval = (int) tmp; def->data.bond.target = - virXPathString(conn, "string(./arpmon/@target)", ctxt); + virXPathString("string(./arpmon/@target)", ctxt); if (def->data.bond.target == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface arpmon target missing")); @@ -653,7 +653,7 @@ error: static int virInterfaceDefParseVlan(virConnectPtr conn, virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { - def->data.vlan.tag = virXPathString(conn, "string(./@tag)", ctxt); + def->data.vlan.tag = virXPathString("string(./@tag)", ctxt); if (def->data.vlan.tag == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("vlan interface misses the tag attribute")); @@ -661,7 +661,7 @@ virInterfaceDefParseVlan(virConnectPtr conn, virInterfaceDefPtr def, } def->data.vlan.devname = - virXPathString(conn, "string(./interface/@name)", ctxt); + virXPathString("string(./interface/@name)", ctxt); if (def->data.vlan.devname == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("vlan interface misses name attribute")); @@ -679,7 +679,7 @@ virInterfaceDefParseXML(virConnectPtr conn, xmlNodePtr cur = ctxt->node; /* check @type */ - tmp = virXPathString(conn, "string(./@type)", ctxt); + tmp = virXPathString("string(./@type)", ctxt); if (tmp == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("interface misses the type attribute")); @@ -718,7 +718,7 @@ virInterfaceDefParseXML(virConnectPtr conn, case VIR_INTERFACE_TYPE_ETHERNET: if (virInterfaceDefParseName(conn, def, ctxt) < 0) goto error; - tmp = virXPathString(conn, "string(./mac/@address)", ctxt); + tmp = virXPathString("string(./mac/@address)", ctxt); if (tmp != NULL) def->mac = tmp; if (parentIfType == VIR_INTERFACE_TYPE_LAST) { @@ -743,7 +743,7 @@ virInterfaceDefParseXML(virConnectPtr conn, if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0) goto error; - bridge = virXPathNode(conn, "./bridge[1]", ctxt); + bridge = virXPathNode("./bridge[1]", ctxt); if (bridge == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bridge interface misses the bridge element")); @@ -785,7 +785,7 @@ virInterfaceDefParseXML(virConnectPtr conn, goto error; } - bond = virXPathNode(conn, "./bond[1]", ctxt); + bond = virXPathNode("./bond[1]", ctxt); if (bond == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("bond interface misses the bond element")); @@ -799,14 +799,14 @@ virInterfaceDefParseXML(virConnectPtr conn, case VIR_INTERFACE_TYPE_VLAN: { xmlNodePtr vlan; - tmp = virXPathString(conn, "string(./@name)", ctxt); + tmp = virXPathString("string(./@name)", ctxt); if (tmp != NULL) def->name = tmp; if (virInterfaceDefParseStartMode(conn, def, ctxt) < 0) goto error; if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0) goto error; - vlan = virXPathNode(conn, "./vlan[1]", ctxt); + vlan = virXPathNode("./vlan[1]", ctxt); if (vlan == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, "%s", _("vlan interface misses the vlan element")); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 4e4a58c..6e857f9 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -401,14 +401,14 @@ virNetworkDefParseXML(virConnectPtr conn, } /* Extract network name */ - def->name = virXPathString(conn, "string(./name[1])", ctxt); + def->name = virXPathString("string(./name[1])", ctxt); if (!def->name) { virNetworkReportError(conn, VIR_ERR_NO_NAME, NULL); goto error; } /* Extract network uuid */ - tmp = virXPathString(conn, "string(./uuid[1])", ctxt); + tmp = virXPathString("string(./uuid[1])", ctxt); if (!tmp) { if (virUUIDGenerate(def->uuid)) { virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -426,19 +426,19 @@ virNetworkDefParseXML(virConnectPtr conn, } /* Parse network domain information */ - def->domain = virXPathString(conn, "string(./domain[1]/@name)", ctxt); + def->domain = virXPathString("string(./domain[1]/@name)", ctxt); /* Parse bridge information */ - def->bridge = virXPathString(conn, "string(./bridge[1]/@name)", ctxt); - tmp = virXPathString(conn, "string(./bridge[1]/@stp)", ctxt); + def->bridge = virXPathString("string(./bridge[1]/@name)", ctxt); + tmp = virXPathString("string(./bridge[1]/@stp)", ctxt); def->stp = (tmp && STREQ(tmp, "off")) ? 0 : 1; VIR_FREE(tmp); - if (virXPathULong(conn, "string(./bridge[1]/@delay)", ctxt, &def->delay) < 0) + if (virXPathULong("string(./bridge[1]/@delay)", ctxt, &def->delay) < 0) def->delay = 0; - def->ipAddress = virXPathString(conn, "string(./ip[1]/@address)", ctxt); - def->netmask = virXPathString(conn, "string(./ip[1]/@netmask)", ctxt); + def->ipAddress = virXPathString("string(./ip[1]/@address)", ctxt); + def->netmask = virXPathString("string(./ip[1]/@netmask)", ctxt); if (def->ipAddress && def->netmask) { /* XXX someday we want IPv6 too, so inet_aton won't work there */ @@ -467,14 +467,14 @@ virNetworkDefParseXML(virConnectPtr conn, goto error; } - if ((ip = virXPathNode(conn, "./ip[1]", ctxt)) && + if ((ip = virXPathNode("./ip[1]", ctxt)) && virNetworkIPParseXML(conn, def, ip) < 0) goto error; } /* IPv4 forwarding setup */ - if (virXPathBoolean(conn, "count(./forward) > 0", ctxt)) { + if (virXPathBoolean("count(./forward) > 0", ctxt)) { if (!def->ipAddress || !def->netmask) { virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -482,7 +482,7 @@ virNetworkDefParseXML(virConnectPtr conn, goto error; } - tmp = virXPathString(conn, "string(./forward[1]/@mode)", ctxt); + tmp = virXPathString("string(./forward[1]/@mode)", ctxt); if (tmp) { if ((def->forwardType = virNetworkForwardTypeFromString(tmp)) < 0) { virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -496,7 +496,7 @@ virNetworkDefParseXML(virConnectPtr conn, } - def->forwardDev = virXPathString(conn, "string(./forward[1]/@dev)", ctxt); + def->forwardDev = virXPathString("string(./forward[1]/@dev)", ctxt); } else { def->forwardType = VIR_NETWORK_FORWARD_NONE; } diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 2924ff0..3ca639c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -69,7 +69,7 @@ virNodeDevCapsDefParseString(virConnectPtr conn, { char *s; - s = virXPathString(conn, xpath, ctxt); + s = virXPathString(xpath, ctxt); if (s == NULL) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, missing_error_fmt, @@ -509,7 +509,7 @@ virNodeDevCapsDefParseULong(virConnectPtr conn, int ret; unsigned long val; - ret = virXPathULong(conn, xpath, ctxt, &val); + ret = virXPathULong(xpath, ctxt, &val); if (ret < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, ret == -1 ? missing_error_fmt : invalid_error_fmt, @@ -533,7 +533,7 @@ virNodeDevCapsDefParseULongLong(virConnectPtr conn, int ret; unsigned long long val; - ret = virXPathULongLong(conn, xpath, ctxt, &val); + ret = virXPathULongLong(xpath, ctxt, &val); if (ret < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, ret == -1 ? missing_error_fmt : invalid_error_fmt, @@ -559,7 +559,7 @@ virNodeDevCapStorageParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->storage.block = virXPathString(conn, "string(./block[1])", ctxt); + data->storage.block = virXPathString("string(./block[1])", ctxt); if (!data->storage.block) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no block device path supplied for '%s'"), @@ -567,13 +567,13 @@ virNodeDevCapStorageParseXML(virConnectPtr conn, goto out; } - data->storage.bus = virXPathString(conn, "string(./bus[1])", ctxt); - data->storage.drive_type = virXPathString(conn, "string(./drive_type[1])", ctxt); - data->storage.model = virXPathString(conn, "string(./model[1])", ctxt); - data->storage.vendor = virXPathString(conn, "string(./vendor[1])", ctxt); - data->storage.serial = virXPathString(conn, "string(./serial[1])", ctxt); + data->storage.bus = virXPathString("string(./bus[1])", ctxt); + data->storage.drive_type = virXPathString("string(./drive_type[1])", ctxt); + data->storage.model = virXPathString("string(./model[1])", ctxt); + data->storage.vendor = virXPathString("string(./vendor[1])", ctxt); + data->storage.serial = virXPathString("string(./serial[1])", ctxt); - if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("error parsing storage capabilities for '%s'"), def->name); @@ -600,10 +600,10 @@ virNodeDevCapStorageParseXML(virConnectPtr conn, orignode2 = ctxt->node; ctxt->node = nodes[i]; - if (virXPathBoolean(conn, "count(./media_available[. = '1']) > 0", ctxt)) + if (virXPathBoolean("count(./media_available[. = '1']) > 0", ctxt)) data->storage.flags |= VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; - data->storage.media_label = virXPathString(conn, "string(./media_label[1])", ctxt); + data->storage.media_label = virXPathString("string(./media_label[1])", ctxt); val = 0; if (virNodeDevCapsDefParseULongLong(conn, "number(./media_size[1])", ctxt, &val, def, @@ -680,7 +680,7 @@ virNodeDevCapScsiParseXML(virConnectPtr conn, _("invalid SCSI LUN ID supplied for '%s'")) < 0) goto out; - data->scsi.type = virXPathString(conn, "string(./type[1])", ctxt); + data->scsi.type = virXPathString("string(./type[1])", ctxt); ret = 0; out: @@ -702,7 +702,7 @@ virNodeDevCapScsiTargetParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->scsi_target.name = virXPathString(conn, "string(./name[1])", ctxt); + data->scsi_target.name = virXPathString("string(./name[1])", ctxt); if (!data->scsi_target.name) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no target name supplied for '%s'"), @@ -741,7 +741,7 @@ virNodeDevCapScsiHostParseXML(virConnectPtr conn, goto out; } - if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("error parsing SCSI host capabilities for '%s'"), def->name); @@ -822,7 +822,7 @@ virNodeDevCapNetParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->net.ifname = virXPathString(conn, "string(./interface[1])", ctxt); + data->net.ifname = virXPathString("string(./interface[1])", ctxt); if (!data->net.ifname) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no network interface supplied for '%s'"), @@ -830,11 +830,11 @@ virNodeDevCapNetParseXML(virConnectPtr conn, goto out; } - data->net.address = virXPathString(conn, "string(./address[1])", ctxt); + data->net.address = virXPathString("string(./address[1])", ctxt); data->net.subtype = VIR_NODE_DEV_CAP_NET_LAST; - tmp = virXPathString(conn, "string(./capability/@type)", ctxt); + tmp = virXPathString("string(./capability/@type)", ctxt); if (tmp) { int val = virNodeDevNetCapTypeFromString(tmp); VIR_FREE(tmp); @@ -890,7 +890,7 @@ virNodeDevCapUsbInterfaceParseXML(virConnectPtr conn, _("invalid USB interface protocol supplied for '%s'")) < 0) goto out; - data->usb_if.description = virXPathString(conn, "string(./description[1])", ctxt); + data->usb_if.description = virXPathString("string(./description[1])", ctxt); ret = 0; out: @@ -910,7 +910,7 @@ virNodeDevCapsDefParseHexId(virConnectPtr conn, int ret; unsigned long val; - ret = virXPathULongHex(conn, xpath, ctxt, &val); + ret = virXPathULongHex(xpath, ctxt, &val); if (ret < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, ret == -1 ? missing_error_fmt : invalid_error_fmt, @@ -959,8 +959,8 @@ virNodeDevCapUsbDevParseXML(virConnectPtr conn, _("invalid USB product ID supplied for '%s'")) < 0) goto out; - data->usb_dev.vendor_name = virXPathString(conn, "string(./vendor[1])", ctxt); - data->usb_dev.product_name = virXPathString(conn, "string(./product[1])", ctxt); + data->usb_dev.vendor_name = virXPathString("string(./vendor[1])", ctxt); + data->usb_dev.product_name = virXPathString("string(./product[1])", ctxt); ret = 0; out: @@ -1017,8 +1017,8 @@ virNodeDevCapPciDevParseXML(virConnectPtr conn, _("invalid PCI product ID supplied for '%s'")) < 0) goto out; - data->pci_dev.vendor_name = virXPathString(conn, "string(./vendor[1])", ctxt); - data->pci_dev.product_name = virXPathString(conn, "string(./product[1])", ctxt); + data->pci_dev.vendor_name = virXPathString("string(./vendor[1])", ctxt); + data->pci_dev.product_name = virXPathString("string(./product[1])", ctxt); ret = 0; out: @@ -1040,13 +1040,13 @@ virNodeDevCapSystemParseXML(virConnectPtr conn, orignode = ctxt->node; ctxt->node = node; - data->system.product_name = virXPathString(conn, "string(./product[1])", ctxt); + data->system.product_name = virXPathString("string(./product[1])", ctxt); - data->system.hardware.vendor_name = virXPathString(conn, "string(./hardware/vendor[1])", ctxt); - data->system.hardware.version = virXPathString(conn, "string(./hardware/version[1])", ctxt); - data->system.hardware.serial = virXPathString(conn, "string(./hardware/serial[1])", ctxt); + data->system.hardware.vendor_name = virXPathString("string(./hardware/vendor[1])", ctxt); + data->system.hardware.version = virXPathString("string(./hardware/version[1])", ctxt); + data->system.hardware.serial = virXPathString("string(./hardware/serial[1])", ctxt); - tmp = virXPathString(conn, "string(./hardware/uuid[1])", ctxt); + tmp = virXPathString("string(./hardware/uuid[1])", ctxt); if (!tmp) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no system UUID supplied for '%s'"), def->name); @@ -1061,9 +1061,9 @@ virNodeDevCapSystemParseXML(virConnectPtr conn, } VIR_FREE(tmp); - data->system.firmware.vendor_name = virXPathString(conn, "string(./firmware/vendor[1])", ctxt); - data->system.firmware.version = virXPathString(conn, "string(./firmware/version[1])", ctxt); - data->system.firmware.release_date = virXPathString(conn, "string(./firmware/release_date[1])", ctxt); + data->system.firmware.vendor_name = virXPathString("string(./firmware/vendor[1])", ctxt); + data->system.firmware.version = virXPathString("string(./firmware/version[1])", ctxt); + data->system.firmware.release_date = virXPathString("string(./firmware/release_date[1])", ctxt); ret = 0; out: @@ -1163,7 +1163,7 @@ virNodeDeviceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt, int create /* Extract device name */ if (create == EXISTING_DEVICE) { - def->name = virXPathString(conn, "string(./name[1])", ctxt); + def->name = virXPathString("string(./name[1])", ctxt); if (!def->name) { virNodeDeviceReportError(conn, VIR_ERR_NO_NAME, NULL); @@ -1179,11 +1179,11 @@ virNodeDeviceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt, int create } /* Extract device parent, if any */ - def->parent = virXPathString(conn, "string(./parent[1])", ctxt); + def->parent = virXPathString("string(./parent[1])", ctxt); /* Parse device capabilities */ nodes = NULL; - if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) <= 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) <= 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no device capabilities for '%s'"), def->name); diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 4b0068e..c002a5d 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -66,7 +66,7 @@ virSecretDefParseUsage(virConnectPtr conn, xmlXPathContextPtr ctxt, char *type_str; int type; - type_str = virXPathString(conn, "string(./usage/@type)", ctxt); + type_str = virXPathString("string(./usage/@type)", ctxt); if (type_str == NULL) { virSecretReportError(conn, VIR_ERR_XML_ERROR, "%s", _("unknown secret usage type")); @@ -86,8 +86,7 @@ virSecretDefParseUsage(virConnectPtr conn, xmlXPathContextPtr ctxt, break; case VIR_SECRET_USAGE_TYPE_VOLUME: - def->usage.volume = virXPathString(conn, "string(./usage/volume)", - ctxt); + def->usage.volume = virXPathString("string(./usage/volume)", ctxt); if (!def->usage.volume) { virSecretReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("volume usage specified, but volume path is missing")); @@ -130,7 +129,7 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) goto cleanup; } - prop = virXPathString(conn, "string(./@ephemeral)", ctxt); + prop = virXPathString("string(./@ephemeral)", ctxt); if (prop != NULL) { if (STREQ(prop, "yes")) def->ephemeral = 1; @@ -144,7 +143,7 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) VIR_FREE(prop); } - prop = virXPathString(conn, "string(./@private)", ctxt); + prop = virXPathString("string(./@private)", ctxt); if (prop != NULL) { if (STREQ(prop, "yes")) def->private = 1; @@ -158,7 +157,7 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) VIR_FREE(prop); } - uuidstr = virXPathString(conn, "string(./uuid)", ctxt); + uuidstr = virXPathString("string(./uuid)", ctxt); if (!uuidstr) { if (virUUIDGenerate(def->uuid)) { virSecretReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -174,8 +173,8 @@ secretXMLParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root) VIR_FREE(uuidstr); } - def->description = virXPathString(conn, "string(./description)", ctxt); - if (virXPathNode(conn, "./usage", ctxt) != NULL + def->description = virXPathString("string(./description)", ctxt); + if (virXPathNode("./usage", ctxt) != NULL && virSecretDefParseUsage(conn, ctxt, def) < 0) goto cleanup; ret = def; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 9c0981d..b80fef0 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -369,14 +369,14 @@ static int virStoragePoolDefParseAuthChap(virConnectPtr conn, xmlXPathContextPtr ctxt, virStoragePoolAuthChapPtr auth) { - auth->login = virXPathString(conn, "string(./auth/@login)", ctxt); + auth->login = virXPathString("string(./auth/@login)", ctxt); if (auth->login == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing auth host attribute")); return -1; } - auth->passwd = virXPathString(conn, "string(./auth/@passwd)", ctxt); + auth->passwd = virXPathString("string(./auth/@passwd)", ctxt); if (auth->passwd == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing auth passwd attribute")); @@ -405,10 +405,10 @@ virStoragePoolDefParseSource(virConnectPtr conn, goto cleanup; } - source->name = virXPathString(conn, "string(./name)", ctxt); + source->name = virXPathString("string(./name)", ctxt); if (options->formatFromString) { - char *format = virXPathString(conn, "string(./format/@type)", ctxt); + char *format = virXPathString("string(./format/@type)", ctxt); if (format == NULL) source->format = options->defaultFormat; else @@ -423,11 +423,10 @@ virStoragePoolDefParseSource(virConnectPtr conn, VIR_FREE(format); } - source->host.name = virXPathString(conn, "string(./host/@name)", ctxt); - source->initiator.iqn = virXPathString(conn, - "string(./initiator/iqn/@name)", ctxt); + source->host.name = virXPathString("string(./host/@name)", ctxt); + source->initiator.iqn = virXPathString("string(./initiator/iqn/@name)", ctxt); - nsource = virXPathNodeSet(conn, "./device", ctxt, &nodeset); + nsource = virXPathNodeSet("./device", ctxt, &nodeset); if (nsource > 0) { if (VIR_ALLOC_N(source->devices, nsource) < 0) { VIR_FREE(nodeset); @@ -448,10 +447,10 @@ virStoragePoolDefParseSource(virConnectPtr conn, source->ndevice = nsource; } - source->dir = virXPathString(conn, "string(./dir/@path)", ctxt); - source->adapter = virXPathString(conn, "string(./adapter/@name)", ctxt); + source->dir = virXPathString("string(./dir/@path)", ctxt); + source->adapter = virXPathString("string(./adapter/@name)", ctxt); - authType = virXPathString(conn, "string(./auth/@type)", ctxt); + authType = virXPathString("string(./auth/@type)", ctxt); if (authType == NULL) { source->authType = VIR_STORAGE_POOL_AUTH_NONE; } else { @@ -510,7 +509,7 @@ virStoragePoolDefParseSourceString(virConnectPtr conn, goto cleanup; } - node = virXPathNode(conn, "/source", xpath_ctxt); + node = virXPathNode("/source", xpath_ctxt); if (!node) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("root element was not source")); @@ -543,7 +542,7 @@ virStorageDefParsePerms(virConnectPtr conn, xmlNodePtr relnode; xmlNodePtr node; - node = virXPathNode(conn, permxpath, ctxt); + node = virXPathNode(permxpath, ctxt); if (node == NULL) { /* Set default values if there is not <permissions> element */ perms->mode = defaultmode; @@ -556,7 +555,7 @@ virStorageDefParsePerms(virConnectPtr conn, relnode = ctxt->node; ctxt->node = node; - mode = virXPathString(conn, "string(./mode)", ctxt); + mode = virXPathString("string(./mode)", ctxt); if (!mode) { perms->mode = defaultmode; } else { @@ -571,10 +570,10 @@ virStorageDefParsePerms(virConnectPtr conn, VIR_FREE(mode); } - if (virXPathNode(conn, "./owner", ctxt) == NULL) { + if (virXPathNode("./owner", ctxt) == NULL) { perms->uid = getuid(); } else { - if (virXPathLong(conn, "number(./owner)", ctxt, &v) < 0) { + if (virXPathLong("number(./owner)", ctxt, &v) < 0) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("malformed owner element")); goto error; @@ -582,10 +581,10 @@ virStorageDefParsePerms(virConnectPtr conn, perms->uid = (int)v; } - if (virXPathNode(conn, "./group", ctxt) == NULL) { + if (virXPathNode("./group", ctxt) == NULL) { perms->gid = getgid(); } else { - if (virXPathLong(conn, "number(./group)", ctxt, &v) < 0) { + if (virXPathLong("number(./group)", ctxt, &v) < 0) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("malformed group element")); goto error; @@ -594,7 +593,7 @@ virStorageDefParsePerms(virConnectPtr conn, } /* NB, we're ignoring missing labels here - they'll simply inherit */ - perms->label = virXPathString(conn, "string(./label)", ctxt); + perms->label = virXPathString("string(./label)", ctxt); ret = 0; error: @@ -616,7 +615,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, return NULL; } - type = virXPathString(conn, "string(./@type)", ctxt); + type = virXPathString("string(./@type)", ctxt); if ((ret->type = virStoragePoolTypeFromString((const char *)type)) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("unknown storage pool type %s"), (const char*)type); @@ -630,14 +629,14 @@ virStoragePoolDefParseXML(virConnectPtr conn, goto cleanup; } - source_node = virXPathNode(conn, "./source", ctxt); + source_node = virXPathNode("./source", ctxt); if (source_node) { if (virStoragePoolDefParseSource(conn, ctxt, &ret->source, ret->type, source_node) < 0) goto cleanup; } - ret->name = virXPathString(conn, "string(./name)", ctxt); + ret->name = virXPathString("string(./name)", ctxt); if (ret->name == NULL && options->flags & VIR_STORAGE_POOL_SOURCE_NAME) ret->name = ret->source.name; @@ -647,7 +646,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, goto cleanup; } - uuid = virXPathString(conn, "string(./uuid)", ctxt); + uuid = virXPathString("string(./uuid)", ctxt); if (uuid == NULL) { if (virUUIDGenerate(ret->uuid) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -698,7 +697,7 @@ virStoragePoolDefParseXML(virConnectPtr conn, } } - if ((ret->target.path = virXPathString(conn, "string(./target/path)", ctxt)) == NULL) { + if ((ret->target.path = virXPathString("string(./target/path)", ctxt)) == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing storage pool target path")); goto cleanup; @@ -1050,7 +1049,7 @@ virStorageVolDefParseXML(virConnectPtr conn, return NULL; } - ret->name = virXPathString(conn, "string(./name)", ctxt); + ret->name = virXPathString("string(./name)", ctxt); if (ret->name == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing volume name element")); @@ -1058,10 +1057,10 @@ virStorageVolDefParseXML(virConnectPtr conn, } /* Auto-generated so deliberately ignore */ - /*ret->key = virXPathString(conn, "string(./key)", ctxt);*/ + /*ret->key = virXPathString("string(./key)", ctxt);*/ - capacity = virXPathString(conn, "string(./capacity)", ctxt); - unit = virXPathString(conn, "string(./capacity/@unit)", ctxt); + capacity = virXPathString("string(./capacity)", ctxt); + unit = virXPathString("string(./capacity/@unit)", ctxt); if (capacity == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("missing capacity element")); @@ -1072,9 +1071,9 @@ virStorageVolDefParseXML(virConnectPtr conn, VIR_FREE(capacity); VIR_FREE(unit); - allocation = virXPathString(conn, "string(./allocation)", ctxt); + allocation = virXPathString("string(./allocation)", ctxt); if (allocation) { - unit = virXPathString(conn, "string(./allocation/@unit)", ctxt); + unit = virXPathString("string(./allocation/@unit)", ctxt); if (virStorageSize(conn, unit, allocation, &ret->allocation) < 0) goto cleanup; VIR_FREE(allocation); @@ -1083,9 +1082,9 @@ virStorageVolDefParseXML(virConnectPtr conn, ret->allocation = ret->capacity; } - ret->target.path = virXPathString(conn, "string(./target/path)", ctxt); + ret->target.path = virXPathString("string(./target/path)", ctxt); if (options->formatFromString) { - char *format = virXPathString(conn, "string(./target/format/@type)", ctxt); + char *format = virXPathString("string(./target/format/@type)", ctxt); if (format == NULL) ret->target.format = options->defaultFormat; else @@ -1104,7 +1103,7 @@ virStorageVolDefParseXML(virConnectPtr conn, "./target/permissions", 0600) < 0) goto cleanup; - node = virXPathNode(conn, "./target/encryption", ctxt); + node = virXPathNode("./target/encryption", ctxt); if (node != NULL) { ret->target.encryption = virStorageEncryptionParseNode(conn, ctxt->doc, node); @@ -1114,9 +1113,9 @@ virStorageVolDefParseXML(virConnectPtr conn, - ret->backingStore.path = virXPathString(conn, "string(./backingStore/path)", ctxt); + ret->backingStore.path = virXPathString("string(./backingStore/path)", ctxt); if (options->formatFromString) { - char *format = virXPathString(conn, "string(./backingStore/format/@type)", ctxt); + char *format = virXPathString("string(./backingStore/format/@type)", ctxt); if (format == NULL) ret->backingStore.format = options->defaultFormat; else diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index eba1f12..f19af88 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -87,7 +87,7 @@ virStorageEncryptionSecretParse(virConnectPtr conn, xmlXPathContextPtr ctxt, old_node = ctxt->node; ctxt->node = node; - type_str = virXPathString(conn, "string(./@type)", ctxt); + type_str = virXPathString("string(./@type)", ctxt); if (type_str == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("unknown volume encryption secret type")); @@ -104,7 +104,7 @@ virStorageEncryptionSecretParse(virConnectPtr conn, xmlXPathContextPtr ctxt, VIR_FREE(type_str); ret->type = type; - uuidstr = virXPathString(conn, "string(./@uuid)", ctxt); + uuidstr = virXPathString("string(./@uuid)", ctxt); if (uuidstr) { if (virUUIDParse(uuidstr, ret->uuid) < 0) { virStorageReportError(conn, VIR_ERR_XML_ERROR, @@ -141,7 +141,7 @@ virStorageEncryptionParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) return NULL; } - format_str = virXPathString(conn, "string(./@format)", ctxt); + format_str = virXPathString("string(./@format)", ctxt); if (format_str == NULL) { virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s", _("unknown volume encryption format")); @@ -158,7 +158,7 @@ virStorageEncryptionParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt) VIR_FREE(format_str); ret->format = format; - n = virXPathNodeSet(conn, "./secret", ctxt, &nodes); + n = virXPathNodeSet("./secret", ctxt, &nodes); if (n < 0){ virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract volume encryption secrets")); diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index 9a80c90..b63e2eb 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -101,7 +101,7 @@ int cpuMapLoad(const char *arch, ctxt->node = xmlDocGetRootElement(xml); - if ((ctxt->node = virXPathNode(NULL, xpath, ctxt)) == NULL) { + if ((ctxt->node = virXPathNode(xpath, ctxt)) == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, _("cannot find CPU map for %s architecture"), arch); goto cleanup; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 33ce776..93bd675 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -332,7 +332,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, if (VIR_ALLOC(feature) < 0) goto no_memory; - feature->name = virXPathString(NULL, "string(@name)", ctxt); + feature->name = virXPathString("string(@name)", ctxt); if (feature->name == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU feature name")); @@ -345,7 +345,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, goto ignore; } - n = virXPathNodeSet(NULL, "./cpuid", ctxt, &nodes); + n = virXPathNodeSet("./cpuid", ctxt, &nodes); if (n < 0) goto ignore; @@ -362,11 +362,11 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, ctxt->node = nodes[i]; fun = eax = ebx = ecx = edx = 0; - ret_fun = virXPathULongHex(NULL, "string(@function)", ctxt, &fun); - ret_eax = virXPathULongHex(NULL, "string(@eax)", ctxt, &eax); - ret_ebx = virXPathULongHex(NULL, "string(@ebx)", ctxt, &ebx); - ret_ecx = virXPathULongHex(NULL, "string(@ecx)", ctxt, &ecx); - ret_edx = virXPathULongHex(NULL, "string(@edx)", ctxt, &edx); + ret_fun = virXPathULongHex("string(@function)", ctxt, &fun); + ret_eax = virXPathULongHex("string(@eax)", ctxt, &eax); + ret_ebx = virXPathULongHex("string(@ebx)", ctxt, &ebx); + ret_ecx = virXPathULongHex("string(@ecx)", ctxt, &ecx); + ret_edx = virXPathULongHex("string(@edx)", ctxt, &edx); if (ret_fun < 0 || ret_eax == -2 || ret_ebx == -2 || ret_ecx == -2 || ret_edx == -2) { @@ -645,18 +645,18 @@ x86ModelLoad(xmlXPathContextPtr ctxt, if (VIR_ALLOC(model) < 0) goto no_memory; - model->name = virXPathString(NULL, "string(@name)", ctxt); + model->name = virXPathString("string(@name)", ctxt); if (model->name == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("Missing CPU model name")); goto ignore; } - if (virXPathNode(NULL, "./model", ctxt) != NULL) { + if (virXPathNode("./model", ctxt) != NULL) { const struct x86_model *ancestor; char *name; - name = virXPathString(NULL, "string(./model/@name)", ctxt); + name = virXPathString("string(./model/@name)", ctxt); if (name == NULL) { virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, _("Missing ancestor's name in CPU model %s"), @@ -682,7 +682,7 @@ x86ModelLoad(xmlXPathContextPtr ctxt, sizeof(*model->cpuid) * model->ncpuid); } - n = virXPathNodeSet(NULL, "./feature", ctxt, &nodes); + n = virXPathNodeSet("./feature", ctxt, &nodes); if (n < 0) goto ignore; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 65c2b09..9edfcb4 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -667,7 +667,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, if ((*response)->responseCode == 500) { (*response)->node = - virXPathNode(NULL, "/soapenv:Envelope/soapenv:Body/soapenv:Fault", + virXPathNode("/soapenv:Envelope/soapenv:Body/soapenv:Fault", xpathContext); if ((*response)->node == NULL) { @@ -705,7 +705,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, goto failure; } - responseNode = virXPathNode(NULL, xpathExpression, xpathContext); + responseNode = virXPathNode(xpathExpression, xpathContext); if (responseNode == NULL) { ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, @@ -715,8 +715,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, } xpathContext->node = responseNode; - (*response)->node = virXPathNode(NULL, "./vim:returnval", - xpathContext); + (*response)->node = virXPathNode("./vim:returnval", xpathContext); switch (occurrence) { case esxVI_Occurrence_RequiredItem: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 98086f5..149fad3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -217,20 +217,20 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) } if (!(monitorpath = - virXPathString(NULL, "string(./monitor[1]/@path)", ctxt))) { + virXPathString("string(./monitor[1]/@path)", ctxt))) { qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("no monitor path")); goto error; } - tmp = virXPathString(NULL, "string(./monitor[1]/@type)", ctxt); + tmp = virXPathString("string(./monitor[1]/@type)", ctxt); if (tmp) priv->monConfig->type = virDomainChrTypeFromString(tmp); else priv->monConfig->type = VIR_DOMAIN_CHR_TYPE_PTY; VIR_FREE(tmp); - if (virXPathBoolean(NULL, "count(./monitor[@json = '1']) > 0", ctxt)) { + if (virXPathBoolean("count(./monitor[@json = '1']) > 0", ctxt)) { priv->monJSON = 1; } else { priv->monJSON = 0; @@ -251,7 +251,7 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) goto error; } - n = virXPathNodeSet(NULL, "./vcpus/vcpu", ctxt, &nodes); + n = virXPathNodeSet("./vcpus/vcpu", ctxt, &nodes); if (n < 0) goto error; if (n) { diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 1b0b2cd..3e7481d 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -626,12 +626,12 @@ caps_mockup(vahControl * ctl, const char *xmlStr) } ctxt->node = root; - ctl->hvm = virXPathString(NULL, "string(./os/type[1])", ctxt); + ctl->hvm = virXPathString("string(./os/type[1])", ctxt); if (!ctl->hvm || STRNEQ(ctl->hvm, "hvm")) { vah_error(ctl, 0, "os.type is not 'hvm'"); goto cleanup; } - ctl->arch = virXPathString(NULL, "string(./os/type[1]/@arch)", ctxt); + ctl->arch = virXPathString("string(./os/type[1]/@arch)", ctxt); if (!ctl->arch) { /* The XML we are given should have an arch, but in case it doesn't, * just use the host's arch. diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 14b467b..9df32e8 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -665,7 +665,7 @@ static int testOpenVolumesForPool(virConnectPtr conn, goto error; } - ret = virXPathNodeSet(conn, vol_xpath, ctxt, &vols); + ret = virXPathNodeSet(vol_xpath, ctxt, &vols); VIR_FREE(vol_xpath); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, @@ -805,7 +805,7 @@ static int testOpenFromFile(virConnectPtr conn, memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo)); nodeInfo = &privconn->nodeInfo; - ret = virXPathLong(conn, "string(/node/cpu/nodes[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/nodes[1])", ctxt, &l); if (ret == 0) { nodeInfo->nodes = l; } else if (ret == -2) { @@ -813,7 +813,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathLong(conn, "string(/node/cpu/sockets[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/sockets[1])", ctxt, &l); if (ret == 0) { nodeInfo->sockets = l; } else if (ret == -2) { @@ -821,7 +821,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathLong(conn, "string(/node/cpu/cores[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/cores[1])", ctxt, &l); if (ret == 0) { nodeInfo->cores = l; } else if (ret == -2) { @@ -829,7 +829,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathLong(conn, "string(/node/cpu/threads[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/threads[1])", ctxt, &l); if (ret == 0) { nodeInfo->threads = l; } else if (ret == -2) { @@ -838,7 +838,7 @@ static int testOpenFromFile(virConnectPtr conn, } nodeInfo->cpus = nodeInfo->cores * nodeInfo->threads * nodeInfo->sockets * nodeInfo->nodes; - ret = virXPathLong(conn, "string(/node/cpu/active[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/active[1])", ctxt, &l); if (ret == 0) { if (l < nodeInfo->cpus) { nodeInfo->cpus = l; @@ -847,7 +847,7 @@ static int testOpenFromFile(virConnectPtr conn, testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node active cpu")); goto error; } - ret = virXPathLong(conn, "string(/node/cpu/mhz[1])", ctxt, &l); + ret = virXPathLong("string(/node/cpu/mhz[1])", ctxt, &l); if (ret == 0) { nodeInfo->mhz = l; } else if (ret == -2) { @@ -855,7 +855,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - str = virXPathString(conn, "string(/node/cpu/model[1])", ctxt); + str = virXPathString("string(/node/cpu/model[1])", ctxt); if (str != NULL) { if (virStrcpyStatic(nodeInfo->model, str) == NULL) { testError(NULL, VIR_ERR_INTERNAL_ERROR, @@ -866,7 +866,7 @@ static int testOpenFromFile(virConnectPtr conn, VIR_FREE(str); } - ret = virXPathLong(conn, "string(/node/memory[1])", ctxt, &l); + ret = virXPathLong("string(/node/memory[1])", ctxt, &l); if (ret == 0) { nodeInfo->memory = l; } else if (ret == -2) { @@ -874,7 +874,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } - ret = virXPathNodeSet(conn, "/node/domain", ctxt, &domains); + ret = virXPathNodeSet("/node/domain", ctxt, &domains); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node domain list")); goto error; @@ -918,7 +918,7 @@ static int testOpenFromFile(virConnectPtr conn, } VIR_FREE(domains); - ret = virXPathNodeSet(conn, "/node/network", ctxt, &networks); + ret = virXPathNodeSet("/node/network", ctxt, &networks); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node network list")); goto error; @@ -954,7 +954,7 @@ static int testOpenFromFile(virConnectPtr conn, VIR_FREE(networks); /* Parse interface definitions */ - ret = virXPathNodeSet(conn, "/node/interface", ctxt, &ifaces); + ret = virXPathNodeSet("/node/interface", ctxt, &ifaces); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node interface list")); goto error; @@ -990,7 +990,7 @@ static int testOpenFromFile(virConnectPtr conn, VIR_FREE(ifaces); /* Parse Storage Pool list */ - ret = virXPathNodeSet(conn, "/node/pool", ctxt, &pools); + ret = virXPathNodeSet("/node/pool", ctxt, &pools); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node pool list")); goto error; @@ -1041,7 +1041,7 @@ static int testOpenFromFile(virConnectPtr conn, } VIR_FREE(pools); - ret = virXPathNodeSet(conn, "/node/device", ctxt, &devs); + ret = virXPathNodeSet("/node/device", ctxt, &devs); if (ret < 0) { testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node device list")); goto error; diff --git a/src/util/xml.c b/src/util/xml.c index 0338373..46ea9aa 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -25,9 +25,9 @@ #define VIR_FROM_THIS VIR_FROM_XML -#define virXMLError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define virXMLError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_XML, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) /************************************************************************ @@ -47,8 +47,7 @@ * if the evaluation failed. */ char * -virXPathString(virConnectPtr conn, - const char *xpath, +virXPathString(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; @@ -56,7 +55,7 @@ virXPathString(virConnectPtr conn, char *ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathString()")); return (NULL); } @@ -89,15 +88,14 @@ virXPathString(virConnectPtr conn, * the evaluation failed. */ char * -virXPathStringLimit(virConnectPtr conn, - const char *xpath, +virXPathStringLimit(const char *xpath, size_t maxlen, xmlXPathContextPtr ctxt) { - char *tmp = virXPathString(conn, xpath, ctxt); + char *tmp = virXPathString(xpath, ctxt); if (tmp != NULL && strlen(tmp) >= maxlen) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, _("\'%s\' value longer than %Zd bytes in virXPathStringLimit()"), xpath, maxlen); return NULL; @@ -118,8 +116,7 @@ virXPathStringLimit(virConnectPtr conn, * or -1 if the evaluation failed. */ int -virXPathNumber(virConnectPtr conn, - const char *xpath, +virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value) { @@ -127,7 +124,7 @@ virXPathNumber(virConnectPtr conn, xmlNodePtr relnode; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathNumber()")); return (-1); } @@ -146,8 +143,7 @@ virXPathNumber(virConnectPtr conn, } static int -virXPathLongBase(virConnectPtr conn, - const char *xpath, +virXPathLongBase(const char *xpath, xmlXPathContextPtr ctxt, int base, long *value) @@ -157,7 +153,7 @@ virXPathLongBase(virConnectPtr conn, int ret = 0; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathLong()")); return (-1); } @@ -202,12 +198,11 @@ virXPathLongBase(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathLong(virConnectPtr conn, - const char *xpath, +virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value) { - return virXPathLongBase(conn, xpath, ctxt, 10, value); + return virXPathLongBase(xpath, ctxt, 10, value); } /** @@ -224,17 +219,15 @@ virXPathLong(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathLongHex(virConnectPtr conn, - const char *xpath, +virXPathLongHex(const char *xpath, xmlXPathContextPtr ctxt, long *value) { - return virXPathLongBase(conn, xpath, ctxt, 16, value); + return virXPathLongBase(xpath, ctxt, 16, value); } static int -virXPathULongBase(virConnectPtr conn, - const char *xpath, +virXPathULongBase(const char *xpath, xmlXPathContextPtr ctxt, int base, unsigned long *value) @@ -244,7 +237,7 @@ virXPathULongBase(virConnectPtr conn, int ret = 0; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathULong()")); return (-1); } @@ -289,12 +282,11 @@ virXPathULongBase(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathULong(virConnectPtr conn, - const char *xpath, +virXPathULong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value) { - return virXPathULongBase(conn, xpath, ctxt, 10, value); + return virXPathULongBase(xpath, ctxt, 10, value); } /** @@ -311,12 +303,11 @@ virXPathULong(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathULongHex(virConnectPtr conn, - const char *xpath, +virXPathULongHex(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value) { - return virXPathULongBase(conn, xpath, ctxt, 16, value); + return virXPathULongBase(xpath, ctxt, 16, value); } /** @@ -332,8 +323,7 @@ virXPathULongHex(virConnectPtr conn, * value doesn't have a long format. */ int -virXPathULongLong(virConnectPtr conn, - const char *xpath, +virXPathULongLong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long long *value) { @@ -342,7 +332,7 @@ virXPathULongLong(virConnectPtr conn, int ret = 0; if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathULong()")); return (-1); } @@ -391,8 +381,7 @@ virXMLPropString(xmlNodePtr node, * Returns 0 if false, 1 if true, or -1 if the evaluation failed. */ int -virXPathBoolean(virConnectPtr conn, - const char *xpath, +virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; @@ -400,7 +389,7 @@ virXPathBoolean(virConnectPtr conn, int ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathBoolean()")); return (-1); } @@ -429,8 +418,7 @@ virXPathBoolean(virConnectPtr conn, * Returns a pointer to the node or NULL if the evaluation failed. */ xmlNodePtr -virXPathNode(virConnectPtr conn, - const char *xpath, +virXPathNode(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; @@ -438,7 +426,7 @@ virXPathNode(virConnectPtr conn, xmlNodePtr ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathNode()")); return (NULL); } @@ -469,8 +457,7 @@ virXPathNode(virConnectPtr conn, * must be freed) or -1 if the evaluation failed. */ int -virXPathNodeSet(virConnectPtr conn, - const char *xpath, +virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list) { @@ -479,7 +466,7 @@ virXPathNodeSet(virConnectPtr conn, int ret; if ((ctxt == NULL) || (xpath == NULL)) { - virXMLError(conn, VIR_ERR_INTERNAL_ERROR, + virXMLError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathNodeSet()")); return (-1); } diff --git a/src/util/xml.h b/src/util/xml.h index cddd42b..246672d 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -11,48 +11,36 @@ #include <libxml/tree.h> #include <libxml/xpath.h> -int virXPathBoolean (virConnectPtr conn, - const char *xpath, +int virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt); -char * virXPathString (virConnectPtr conn, - const char *xpath, +char * virXPathString(const char *xpath, xmlXPathContextPtr ctxt); -char * virXPathStringLimit(virConnectPtr conn, - const char *xpath, - size_t maxlen, - xmlXPathContextPtr ctxt); -int virXPathNumber (virConnectPtr conn, - const char *xpath, +char * virXPathStringLimit(const char *xpath, + size_t maxlen, + xmlXPathContextPtr ctxt); +int virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value); -int virXPathLong (virConnectPtr conn, - const char *xpath, +int virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value); -int virXPathULong (virConnectPtr conn, - const char *xpath, +int virXPathULong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); -int virXPathULongLong(virConnectPtr conn, - const char *xpath, +int virXPathULongLong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long long *value); -int virXPathLongHex (virConnectPtr conn, - const char *xpath, +int virXPathLongHex(const char *xpath, xmlXPathContextPtr ctxt, long *value); -int virXPathULongHex(virConnectPtr conn, - const char *xpath, +int virXPathULongHex(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); -xmlNodePtr virXPathNode (virConnectPtr conn, - const char *xpath, +xmlNodePtr virXPathNode(const char *xpath, xmlXPathContextPtr ctxt); -int virXPathNodeSet (virConnectPtr conn, - const char *xpath, +int virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list); - char * virXMLPropString(xmlNodePtr node, const char *name); -- 1.6.3.3

It was used for error reporting only. --- daemon/libvirtd.c | 2 +- daemon/remote.c | 2 +- ...-Step-7-of-8-Implement-the-driver-methods.patch | 4 +- src/lxc/lxc_driver.c | 4 +- src/lxc/veth.c | 12 +- src/network/bridge_driver.c | 4 +- src/node_device/node_device_driver.c | 2 +- src/openvz/openvz_conf.c | 2 +- src/openvz/openvz_driver.c | 24 ++-- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_conf.c | 10 +- src/qemu/qemu_driver.c | 6 +- src/remote/remote_driver.c | 6 +- src/secret/secret_driver.c | 2 +- src/security/security_apparmor.c | 8 +- src/security/virt-aa-helper.c | 2 +- src/storage/storage_backend.c | 15 ++-- src/storage/storage_backend_disk.c | 12 +- src/storage/storage_backend_fs.c | 4 +- src/storage/storage_backend_iscsi.c | 20 ++-- src/storage/storage_backend_logical.c | 35 +++--- src/storage/storage_backend_mpath.c | 2 +- src/storage/storage_backend_scsi.c | 7 +- src/storage/storage_backend_scsi.h | 3 +- src/storage/storage_driver.c | 2 +- src/uml/uml_driver.c | 4 +- src/util/bridge.c | 4 +- src/util/cgroup.c | 2 +- src/util/ebtables.c | 2 +- src/util/iptables.c | 2 +- src/util/pci.c | 10 +- src/util/util.c | 111 ++++++++----------- src/util/util.h | 27 ++--- src/xen/proxy_internal.c | 2 +- tools/virsh.c | 4 +- 35 files changed, 166 insertions(+), 194 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 1c7e791..fefa7aa 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -755,7 +755,7 @@ static int qemudInitPaths(struct qemud_server *server, goto snprintf_error; } else { uid_t uid = geteuid(); - dir_prefix = virGetUserDirectory(NULL, uid); + dir_prefix = virGetUserDirectory(uid); if (dir_prefix == NULL) { /* Do not diagnose here; virGetUserDirectory does that. */ goto snprintf_error; diff --git a/daemon/remote.c b/daemon/remote.c index 09a51b7..07c4c5f 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3370,7 +3370,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server, goto authfail; } - if (virRun(NULL, pkcheck, &status) < 0) { + if (virRun(pkcheck, &status) < 0) { VIR_ERROR(_("Cannot invoke %s"), PKCHECK_PATH); goto authfail; } diff --git a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch index 09ddc65..807ed78 100644 --- a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch +++ b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch @@ -478,7 +478,7 @@ index b84729f..4f73baf 100644 + * If this fails for any reason, we still have the backup of polling for + * 5 seconds for device nodes. + */ -+ virRun(conn, settleprog, &exitstatus); ++ virRun(settleprog, &exitstatus); +} +#else +void virNodeDeviceWaitForDevices(virConnectPtr conn ATTRIBUTE_UNUSED) {} @@ -1131,7 +1131,7 @@ index b154140..74759cf 100644 - * If this fails for any reason, we still have the backup of polling for - * 5 seconds for device nodes. - */ -- virRun(conn, settleprog, &exitstatus); +- virRun(settleprog, &exitstatus); + virNodeDeviceWaitForDevices(conn); + return; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a4143f5..80a4935 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1120,7 +1120,7 @@ static int lxcControllerStart(virConnectPtr conn, FD_SET(appPty, &keepfd); - if (virExec(conn, largv, lenv, &keepfd, &child, + if (virExec(largv, lenv, &keepfd, &child, -1, &logfd, &logfd, VIR_EXEC_NONE) < 0) goto cleanup; @@ -1575,7 +1575,7 @@ static int lxcCheckNetNsSupport(void) const char *argv[] = {"ip", "link", "set", "lo", "netns", "-1", NULL}; int ip_rc; - if (virRun(NULL, argv, &ip_rc) < 0 || + if (virRun(argv, &ip_rc) < 0 || !(WIFEXITED(ip_rc) && (WEXITSTATUS(ip_rc) != 255))) return 0; diff --git a/src/lxc/veth.c b/src/lxc/veth.c index ede85ce..34f7faa 100644 --- a/src/lxc/veth.c +++ b/src/lxc/veth.c @@ -102,7 +102,7 @@ int vethCreate(char* veth1, int veth1MaxLen, } DEBUG("veth1: %s veth2: %s", veth1, veth2); - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) { rc = cmdResult; @@ -135,7 +135,7 @@ int vethDelete(const char *veth) DEBUG("veth: %s", veth); - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) { rc = cmdResult; @@ -170,7 +170,7 @@ int vethInterfaceUpOrDown(const char* veth, int upOrDown) else argv[2] = "up"; - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) { rc = cmdResult; @@ -208,7 +208,7 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs) goto error_out; argv[5] = pid; - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) rc = cmdResult; @@ -240,7 +240,7 @@ int setMacAddr(const char* iface, const char* macaddr) goto error_out; } - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) rc = cmdResult; @@ -271,7 +271,7 @@ int setInterfaceName(const char* iface, const char* new) goto error_out; } - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) rc = cmdResult; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 63cd53e..a3c6b9c 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -211,7 +211,7 @@ networkStartup(int privileged) { if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL) goto out_of_memory; } else { - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; @@ -562,7 +562,7 @@ dhcpStartDhcpDaemon(virConnectPtr conn, return -1; } - if (virRun(conn, argv, NULL) < 0) + if (virRun(argv, NULL) < 0) goto cleanup; /* diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index fd96874..ad5503b 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -510,7 +510,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn) while ((now - start) < LINUX_NEW_DEVICE_WAIT_TIME) { - virFileWaitForDevices(conn); + virFileWaitForDevices(); dev = nodeDeviceLookupByWWN(conn, wwnn, wwpn); diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 6baaea2..f4b8199 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -84,7 +84,7 @@ openvzExtractVersionInfo(const char *cmd, int *retversion) if (retversion) *retversion = 0; - if (virExec(NULL, vzarg, vzenv, NULL, + if (virExec(vzarg, vzenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_NONE) < 0) return -1; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 49a7bd2..8535f18 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -256,7 +256,7 @@ static int openvzSetInitialConfig(virConnectPtr conn, goto cleanup; } - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -530,7 +530,7 @@ static int openvzDomainShutdown(virDomainPtr dom) { goto cleanup; } - if (virRun(dom->conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) goto cleanup; vm->def->id = -1; @@ -567,7 +567,7 @@ static int openvzDomainReboot(virDomainPtr dom, goto cleanup; } - if (virRun(dom->conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) goto cleanup; ret = 0; @@ -727,7 +727,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid, if (prog[0] != NULL){ ADD_ARG_LIT("--save"); - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); rc = -1; @@ -929,7 +929,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, openvzSetProgramSentinal(progstart, vm->def->name); - if (virRun(conn, progstart, NULL) < 0) { + if (virRun(progstart, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -984,7 +984,7 @@ openvzDomainCreate(virDomainPtr dom) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(dom->conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -1022,7 +1022,7 @@ openvzDomainUndefine(virDomainPtr dom) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(dom->conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -1059,7 +1059,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(dom->conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; } @@ -1136,7 +1136,7 @@ static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm, str_vcpus[31] = '\0'; openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); return -1; @@ -1301,7 +1301,7 @@ static int openvzListDomains(virConnectPtr conn, int *ids, int nids) { char *endptr; const char *cmd[] = {VZLIST, "-ovpsid", "-H" , NULL}; - ret = virExec(conn, cmd, NULL, NULL, + ret = virExec(cmd, NULL, NULL, &pid, -1, &outfd, &errfd, VIR_EXEC_NONE); if(ret == -1) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, @@ -1347,7 +1347,7 @@ static int openvzListDefinedDomains(virConnectPtr conn, const char *cmd[] = {VZLIST, "-ovpsid", "-H", "-S", NULL}; /* the -S options lists only stopped domains */ - ret = virExec(conn, cmd, NULL, NULL, + ret = virExec(cmd, NULL, NULL, &pid, -1, &outfd, &errfd, VIR_EXEC_NONE); if(ret == -1) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, @@ -1447,7 +1447,7 @@ openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm, snprintf(str_mem, sizeof(str_mem), "%lu", mem * 1024); openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 80ed4b9..f5de9b0 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -253,7 +253,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, int ret; char *pubkey = NULL; char *pvtkey = NULL; - char *userhome = virGetUserDirectory(NULL, geteuid()); + char *userhome = virGetUserDirectory(geteuid()); struct stat pvt_stat, pub_stat; if (userhome == NULL) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3d16ed9..257b4a4 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -217,7 +217,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, virConfFree(conf); return -1; } - if (virGetUserID(NULL, user, &driver->user) < 0) { + if (virGetUserID(user, &driver->user) < 0) { VIR_FREE(user); virConfFree(conf); return -1; @@ -232,7 +232,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, virConfFree(conf); return -1; } - if (virGetGroupID(NULL, group, &driver->group) < 0) { + if (virGetGroupID(group, &driver->group) < 0) { VIR_FREE(group); virConfFree(conf); return -1; @@ -485,7 +485,7 @@ qemudProbeMachineTypes(const char *binary, int newstdout = -1, len; int ret = -1, status; - if (virExec(NULL, qemuarg, qemuenv, NULL, + if (virExec(qemuarg, qemuenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0) return -1; @@ -719,7 +719,7 @@ qemudProbeCPUModels(const char *qemu, return 0; } - if (virExec(NULL, qemuarg, qemuenv, NULL, + if (virExec(qemuarg, qemuenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0) return -1; @@ -1330,7 +1330,7 @@ int qemudExtractVersionInfo(const char *qemu, if (retversion) *retversion = 0; - if (virExec(NULL, qemuarg, qemuenv, NULL, + if (virExec(qemuarg, qemuenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 149fad3..8d121a7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1033,7 +1033,7 @@ qemudStartup(int privileged) { goto out_of_memory; } else { uid_t uid = geteuid(); - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; @@ -2691,7 +2691,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, for (i = 0 ; i < ntapfds ; i++) FD_SET(tapfds[i], &keepfd); - ret = virExecDaemonize(conn, argv, progenv, &keepfd, &child, + ret = virExecDaemonize(argv, progenv, &keepfd, &child, stdin_fd, &logfile, &logfile, VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS, qemudSecurityHook, &hookData, @@ -4556,7 +4556,7 @@ static int qemudDomainRestore(virConnectPtr conn, intermediate_argv[0] = prog; intermediatefd = fd; fd = -1; - if (virExec(conn, intermediate_argv, NULL, NULL, + 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"), diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index c5ed859..17f1fcc 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -330,7 +330,7 @@ remoteForkDaemon(virConnectPtr conn) return -1; } - if (virExecDaemonize(NULL, daemonargs, NULL, NULL, + if (virExecDaemonize(daemonargs, NULL, NULL, &pid, -1, NULL, NULL, VIR_EXEC_CLEAR_CAPS, NULL, NULL, NULL) < 0) @@ -656,7 +656,7 @@ doRemoteOpen (virConnectPtr conn, case trans_unix: { if (!sockname) { if (flags & VIR_DRV_OPEN_REMOTE_USER) { - char *userdir = virGetUserDirectory(conn, getuid()); + char *userdir = virGetUserDirectory(getuid()); if (!userdir) goto failed; @@ -793,7 +793,7 @@ doRemoteOpen (virConnectPtr conn, goto failed; } - if (virExec(conn, (const char**)cmd_argv, NULL, NULL, + if (virExec((const char**)cmd_argv, NULL, NULL, &pid, sv[1], &(sv[1]), NULL, VIR_EXEC_CLEAR_CAPS) < 0) goto failed; diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index f4c8aef..85c7e7c 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -1003,7 +1003,7 @@ secretDriverStartup(int privileged) goto out_of_memory; } else { uid_t uid = geteuid(); - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index b67df3f..2d5f944 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -173,19 +173,19 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, const char *const argv[] = { VIRT_AA_HELPER, "-c", "-u", profile, NULL }; - ret = virExec(conn, argv, NULL, NULL, &child, + ret = virExec(argv, NULL, NULL, &child, pipefd[0], NULL, NULL, VIR_EXEC_CLEAR_CAPS); } else if (disk && disk->src) { const char *const argv[] = { VIRT_AA_HELPER, "-r", "-u", profile, "-f", disk->src, NULL }; - ret = virExec(conn, argv, NULL, NULL, &child, + ret = virExec(argv, NULL, NULL, &child, pipefd[0], NULL, NULL, VIR_EXEC_CLEAR_CAPS); } else { const char *const argv[] = { VIRT_AA_HELPER, "-r", "-u", profile, NULL }; - ret = virExec(conn, argv, NULL, NULL, &child, + ret = virExec(argv, NULL, NULL, &child, pipefd[0], NULL, NULL, VIR_EXEC_CLEAR_CAPS); } if (ret < 0) @@ -230,7 +230,7 @@ remove_profile(const char *profile) VIRT_AA_HELPER, "-R", "-u", profile, NULL }; - if (virRun(NULL, argv, NULL) == 0) + if (virRun(argv, NULL) == 0) rc = 0; return rc; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 3e7481d..81ba1ae 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -203,7 +203,7 @@ parserCommand(const char *profile_name, const char cmd) const char * const argv[] = { "/sbin/apparmor_parser", flag, profile, NULL }; - if (virRun(NULL, argv, NULL) != 0) { + if (virRun(argv, NULL) != 0) { vah_error(NULL, 0, "failed to run apparmor_parser"); return -1; } diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 2e78168..8d85de8 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -509,8 +509,7 @@ static int virStorageBuildSetUIDHook(void *data) { return 0; } -static int virStorageBackendCreateExecCommand(virConnectPtr conn, - virStoragePoolObjPtr pool, +static int virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, const char **cmdargv) { struct stat st; @@ -521,7 +520,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn, if ((pool->def->type == VIR_STORAGE_POOL_NETFS) && (getuid() == 0) && ((vol->target.perms.uid != 0) || (vol->target.perms.gid != 0))) { - if (virRunWithHook(conn, cmdargv, + if (virRunWithHook(cmdargv, virStorageBuildSetUIDHook, vol, NULL) == 0) { /* command was successfully run, check if the file was created */ if (stat(vol->target.path, &st) >=0) @@ -529,7 +528,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn, } } if (!filecreated) { - if (virRun(conn, cmdargv, NULL) < 0) { + if (virRun(cmdargv, NULL) < 0) { virReportSystemError(errno, _("Cannot run %s to create %s"), cmdargv[0], vol->target.path); @@ -727,7 +726,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, /* Size in KB */ snprintf(size, sizeof(size), "%lluK", vol->capacity/1024); - ret = virStorageBackendCreateExecCommand(conn, pool, vol, imgargv); + ret = virStorageBackendCreateExecCommand(pool, vol, imgargv); VIR_FREE(imgargv[0]); return ret; @@ -781,7 +780,7 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn, imgargv[2] = vol->target.path; imgargv[3] = NULL; - ret = virStorageBackendCreateExecCommand(conn, pool, vol, imgargv); + ret = virStorageBackendCreateExecCommand(pool, vol, imgargv); VIR_FREE(imgargv[0]); return ret; @@ -1250,7 +1249,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn, /* Run the program and capture its output */ - if (virExec(conn, prog, NULL, NULL, + if (virExec(prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { goto cleanup; } @@ -1386,7 +1385,7 @@ virStorageBackendRunProgNul(virConnectPtr conn, v[i] = NULL; /* Run the program and capture its output */ - if (virExec(conn, prog, NULL, NULL, + if (virExec(prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { goto cleanup; } diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index a86c193..2082841 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -323,7 +323,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn, VIR_FREE(pool->def->source.devices[0].freeExtents); pool->def->source.devices[0].nfreeExtent = 0; - virFileWaitForDevices(conn); + virFileWaitForDevices(); if (virStorageBackendDiskReadGeometry(conn, pool) != 0) { return -1; @@ -337,7 +337,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn, * Write a new partition table header */ static int -virStorageBackendDiskBuildPool(virConnectPtr conn, +virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { @@ -352,7 +352,7 @@ virStorageBackendDiskBuildPool(virConnectPtr conn, NULL, }; - if (virRun(conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) return -1; return 0; @@ -577,11 +577,11 @@ virStorageBackendDiskCreateVol(virConnectPtr conn, snprintf(end, sizeof(end)-1, "%lluB", endOffset); end[sizeof(end)-1] = '\0'; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; /* wait for device node to show up */ - virFileWaitForDevices(conn); + virFileWaitForDevices(); /* Blow away free extent info, as we're about to re-populate it */ VIR_FREE(pool->def->source.devices[0].freeExtents); @@ -662,7 +662,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn, NULL, }; - if (virRun(conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) goto cleanup; rc = 0; diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index f1e1371..dcc5bf9 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -403,7 +403,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn, mntargv[option_index] = options; } - if (virRun(conn, mntargv, NULL) < 0) { + if (virRun(mntargv, NULL) < 0) { VIR_FREE(src); return -1; } @@ -457,7 +457,7 @@ virStorageBackendFileSystemUnmount(virConnectPtr conn, mntargv[1] = pool->def->target.path; mntargv[2] = NULL; - if (virRun(conn, mntargv, NULL) < 0) { + if (virRun(mntargv, NULL) < 0) { return -1; } return 0; diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 8a93edc..4e2a75e 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -182,7 +182,7 @@ virStorageBackendIQNFound(virConnectPtr conn, memset(line, 0, LINE_SIZE); - if (virExec(conn, prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { + if (virExec(prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run '%s' when looking for existing interface with IQN '%s'"), prog[0], pool->def->source.initiator.iqn); @@ -279,7 +279,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn, * tools returned an exit status of > 0, even if they succeeded. * We will just rely on whether the interface got created * properly. */ - if (virRun(conn, cmdargv1, &exitstatus) < 0) { + if (virRun(cmdargv1, &exitstatus) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run command '%s' to create new iscsi interface"), cmdargv1[0]); @@ -295,7 +295,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn, /* Note that we ignore the exitstatus. Older versions of iscsiadm tools * returned an exit status of > 0, even if they succeeded. We will just * rely on whether iface file got updated properly. */ - if (virRun(conn, cmdargv2, &exitstatus) < 0) { + if (virRun(cmdargv2, &exitstatus) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run command '%s' to update iscsi interface with IQN '%s'"), cmdargv1[0], pool->def->source.initiator.iqn); @@ -348,7 +348,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn, const char *const sendtargets[] = { ISCSIADM, "--mode", "discovery", "--type", "sendtargets", "--portal", portal, NULL }; - if (virRun(conn, sendtargets, NULL) < 0) { + if (virRun(sendtargets, NULL) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run %s to get target list"), sendtargets[0]); @@ -361,7 +361,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn, ifacename, action, NULL }; - if (virRun(conn, cmdargv, NULL) < 0) { + if (virRun(cmdargv, NULL) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run command '%s' with action '%s'"), cmdargv[0], action); @@ -395,7 +395,7 @@ virStorageBackendISCSIConnection(virConnectPtr conn, "--targetname", pool->def->source.devices[0].path, action, NULL }; - if (virRun(conn, cmdargv, NULL) < 0) { + if (virRun(cmdargv, NULL) < 0) { ret = -1; } @@ -417,7 +417,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn, snprintf(sysfs_path, PATH_MAX, "/sys/class/iscsi_session/session%s/device", session); - if (virStorageBackendSCSIGetHostNumber(conn, sysfs_path, &host) < 0) { + if (virStorageBackendSCSIGetHostNumber(sysfs_path, &host) < 0) { virReportSystemError(errno, _("Failed to get host number for iSCSI session " "with path '%s'"), @@ -435,7 +435,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn, } static int -virStorageBackendISCSIRescanLUNs(virConnectPtr conn, +virStorageBackendISCSIRescanLUNs(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, const char *session) { @@ -443,7 +443,7 @@ virStorageBackendISCSIRescanLUNs(virConnectPtr conn, ISCSIADM, "--mode", "session", "-r", session, "-R", NULL, }; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; return 0; @@ -460,7 +460,7 @@ virStorageBackendISCSILogin(virConnectPtr conn, "--portal", portal, NULL }; - if (virRun(conn, cmdsendtarget, NULL) < 0) + if (virRun(cmdsendtarget, NULL) < 0) return -1; return virStorageBackendISCSIConnection(conn, pool, portal, "--login"); diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 06ae865..35bedc0 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -44,8 +44,7 @@ static int -virStorageBackendLogicalSetActive(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool, int on) { const char *cmdargv[4]; @@ -55,7 +54,7 @@ virStorageBackendLogicalSetActive(virConnectPtr conn, cmdargv[2] = pool->def->source.name; cmdargv[3] = NULL; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; return 0; @@ -337,7 +336,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn, * that might be hanging around, so if this fails for some reason, the * worst that happens is that scanning doesn't pick everything up */ - if (virRun(conn, scanprog, &exitstatus) < 0) { + if (virRun(scanprog, &exitstatus) < 0) { VIR_WARN0("Failure when running vgscan to refresh physical volumes"); } @@ -367,10 +366,10 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn, static int -virStorageBackendLogicalStartPool(virConnectPtr conn, +virStorageBackendLogicalStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { - if (virStorageBackendLogicalSetActive(conn, pool, 1) < 0) + if (virStorageBackendLogicalSetActive(pool, 1) < 0) return -1; return 0; @@ -378,7 +377,7 @@ virStorageBackendLogicalStartPool(virConnectPtr conn, static int -virStorageBackendLogicalBuildPool(virConnectPtr conn, +virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { @@ -431,14 +430,14 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn, */ vgargv[n++] = pool->def->source.devices[i].path; pvargv[1] = pool->def->source.devices[i].path; - if (virRun(conn, pvargv, NULL) < 0) + if (virRun(pvargv, NULL) < 0) goto cleanup; } vgargv[n] = NULL; /* Now create the volume group itself */ - if (virRun(conn, vgargv, NULL) < 0) + if (virRun(vgargv, NULL) < 0) goto cleanup; VIR_FREE(vgargv); @@ -476,7 +475,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn, }; int exitstatus; - virFileWaitForDevices(conn); + virFileWaitForDevices(); /* Get list of all logical volumes */ if (virStorageBackendLogicalFindLVs(conn, pool, NULL) < 0) { @@ -512,17 +511,17 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn, * "Can't deactivate volume group "VolGroup00" with 3 open logical volume(s)" */ static int -virStorageBackendLogicalStopPool(virConnectPtr conn, +virStorageBackendLogicalStopPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { - if (virStorageBackendLogicalSetActive(conn, pool, 0) < 0) + if (virStorageBackendLogicalSetActive(pool, 0) < 0) return -1; return 0; } static int -virStorageBackendLogicalDeletePool(virConnectPtr conn, +virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { @@ -533,7 +532,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn, int i, error; /* first remove the volume group */ - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; /* now remove the pv devices and clear them out */ @@ -542,7 +541,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn, pvargv[2] = NULL; for (i = 0 ; i < pool->def->source.ndevice ; i++) { pvargv[1] = pool->def->source.devices[i].path; - if (virRun(conn, pvargv, NULL) < 0) { + if (virRun(pvargv, NULL) < 0) { error = -1; virReportSystemError(errno, _("cannot remove PV device '%s'"), @@ -607,7 +606,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, return -1; } - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; if ((fd = open(vol->target.path, O_RDONLY)) < 0) { @@ -675,7 +674,7 @@ virStorageBackendLogicalBuildVolFrom(virConnectPtr conn, } static int -virStorageBackendLogicalDeleteVol(virConnectPtr conn, +virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned int flags ATTRIBUTE_UNUSED) @@ -684,7 +683,7 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn, LVREMOVE, "-f", vol->target.path, NULL }; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; return 0; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index 87e0fc8..8b8fba5 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -329,7 +329,7 @@ virStorageBackendMpathRefreshPool(virConnectPtr conn, pool->def->allocation = pool->def->capacity = pool->def->available = 0; - virFileWaitForDevices(conn); + virFileWaitForDevices(); virStorageBackendGetMaps(conn, pool); diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 505175d..9c13dee 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -505,7 +505,7 @@ virStorageBackendSCSIFindLUs(virConnectPtr conn, VIR_DEBUG(_("Discovering LUs on host %u"), scanhost); - virFileWaitForDevices(conn); + virFileWaitForDevices(); if (virAsprintf(&device_path, "/sys/bus/scsi/devices") < 0) { virReportOOMError(); @@ -543,8 +543,7 @@ out: int -virStorageBackendSCSIGetHostNumber(virConnectPtr conn, - const char *sysfs_path, +virStorageBackendSCSIGetHostNumber(const char *sysfs_path, uint32_t *host) { int retval = 0; @@ -553,7 +552,7 @@ virStorageBackendSCSIGetHostNumber(virConnectPtr conn, VIR_DEBUG(_("Finding host number from '%s'"), sysfs_path); - virFileWaitForDevices(conn); + virFileWaitForDevices(); sysdir = opendir(sysfs_path); diff --git a/src/storage/storage_backend_scsi.h b/src/storage/storage_backend_scsi.h index d130086..8467993 100644 --- a/src/storage/storage_backend_scsi.h +++ b/src/storage/storage_backend_scsi.h @@ -33,8 +33,7 @@ extern virStorageBackend virStorageBackendSCSI; int -virStorageBackendSCSIGetHostNumber(virConnectPtr conn, - const char *sysfs_path, +virStorageBackendSCSIGetHostNumber(const char *sysfs_path, uint32_t *host); int virStorageBackendSCSIFindLUs(virConnectPtr conn, diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 09153a2..fd5e51d 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -124,7 +124,7 @@ storageDriverStartup(int privileged) { goto out_of_memory; } else { uid_t uid = geteuid(); - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 732c3d4..a1e09ba 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -365,7 +365,7 @@ umlStartup(int privileged) { if (virDomainObjListInit(¨_driver->domains) < 0) goto error; - userdir = virGetUserDirectory(NULL, uid); + userdir = virGetUserDirectory(uid); if (!userdir) goto error; @@ -899,7 +899,7 @@ static int umlStartVMDaemon(virConnectPtr conn, priv->monitor = -1; - ret = virExecDaemonize(conn, argv, progenv, &keepfd, &pid, + ret = virExecDaemonize(argv, progenv, &keepfd, &pid, -1, &logfd, &logfd, VIR_EXEC_CLEAR_CAPS, NULL, NULL, NULL); diff --git a/src/util/bridge.c b/src/util/bridge.c index f9a7668..4a5ab4b 100644 --- a/src/util/bridge.c +++ b/src/util/bridge.c @@ -792,7 +792,7 @@ brSetForwardDelay(brControl *ctl ATTRIBUTE_UNUSED, snprintf(delayStr, sizeof(delayStr), "%d", delay); - if (virRun(NULL, progargv, NULL) < 0) + if (virRun(progargv, NULL) < 0) return -1; return 0; @@ -819,7 +819,7 @@ brSetEnableSTP(brControl *ctl ATTRIBUTE_UNUSED, BRCTL, "stp", bridge, setting, NULL }; - if (virRun(NULL, progargv, NULL) < 0) + if (virRun(progargv, NULL) < 0) return -1; return 0; diff --git a/src/util/cgroup.c b/src/util/cgroup.c index c80cf50..5d62d38 100644 --- a/src/util/cgroup.c +++ b/src/util/cgroup.c @@ -531,7 +531,7 @@ static int virCgroupAppRoot(int privileged, } else { char *rootname; char *username; - username = virGetUserName(NULL, getuid()); + username = virGetUserName(getuid()); if (!username) { rc = -ENOMEM; goto cleanup; diff --git a/src/util/ebtables.c b/src/util/ebtables.c index 4244adc..dba9f82 100644 --- a/src/util/ebtables.c +++ b/src/util/ebtables.c @@ -228,7 +228,7 @@ ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...) goto error; } - if (virRun(NULL, argv, NULL) < 0) { + if (virRun(argv, NULL) < 0) { retval = errno; goto error; } diff --git a/src/util/iptables.c b/src/util/iptables.c index 3c02ea6..b579173 100644 --- a/src/util/iptables.c +++ b/src/util/iptables.c @@ -146,7 +146,7 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...) va_end(args); - if (virRun(NULL, argv, NULL) < 0) { + if (virRun(argv, NULL) < 0) { retval = errno; goto error; } diff --git a/src/util/pci.c b/src/util/pci.c index bbaf235..88d163f 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -699,7 +699,7 @@ pciDeviceFile(char *buf, size_t buflen, const char *device, const char *file) static const char * -pciFindStubDriver(virConnectPtr conn) +pciFindStubDriver(void) { char drvpath[PATH_MAX]; int probed = 0; @@ -723,8 +723,8 @@ recheck: * On Xen though, we want to prefer pciback, so probe * for that first, because that will only work on Xen */ - if (virRun(conn, backprobe, NULL) < 0 && - virRun(conn, stubprobe, NULL) < 0) { + if (virRun(backprobe, NULL) < 0 && + virRun(stubprobe, NULL) < 0) { char ebuf[1024]; VIR_WARN(_("failed to load pci-stub or pciback drivers: %s"), virStrerror(errno, ebuf, sizeof ebuf)); @@ -812,7 +812,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) int pciDettachDevice(virConnectPtr conn, pciDevice *dev) { - const char *driver = pciFindStubDriver(conn); + const char *driver = pciFindStubDriver(); if (!driver) { pciReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot find any PCI stub module")); @@ -873,7 +873,7 @@ pciUnBindDeviceFromStub(pciDevice *dev, const char *driver) int pciReAttachDevice(virConnectPtr conn, pciDevice *dev) { - const char *driver = pciFindStubDriver(conn); + const char *driver = pciFindStubDriver(); if (!driver) { pciReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot find any PCI stub module")); diff --git a/src/util/util.c b/src/util/util.c index 92b2958..f1550e0 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -84,9 +84,9 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define ReportError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define virUtilError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) /* Like read(), but restarts after EINTR */ int saferead(int fd, void *buf, size_t count) @@ -297,7 +297,6 @@ static int virClearCapabilities(void) #endif /* - * @conn Connection to report errors against * @argv argv to exec * @envp optional environment to use for exec * @keepfd options fd_ret to keep open for child process @@ -318,8 +317,7 @@ static int virClearCapabilities(void) * @pidfile path to use as pidfile for daemonized process (needs DAEMON flag) */ static int -__virExec(virConnectPtr conn, - const char *const*argv, +__virExec(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -454,9 +452,6 @@ __virExec(virConnectPtr conn, /* child */ - /* Don't want to report errors against this accidentally, so - just discard it */ - conn = NULL; /* Remove any error callback too, so errors in child now get sent to stderr where they stand a fighting chance of being seen / logged */ @@ -593,7 +588,7 @@ __virExec(virConnectPtr conn, /* This is cleanup of parent process only - child should never jump here on error */ - /* NB we don't ReportError() on any failures here + /* NB we don't virUtilError() on any failures here because the code which jumped hre already raised an error condition which we must not overwrite */ if (pipeerr[0] > 0) @@ -610,8 +605,7 @@ __virExec(virConnectPtr conn, } int -virExecWithHook(virConnectPtr conn, - const char *const*argv, +virExecWithHook(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -641,7 +635,7 @@ virExecWithHook(virConnectPtr conn, } VIR_FREE(argv_str); - return __virExec(conn, argv, envp, keepfd, retpid, infd, outfd, errfd, + return __virExec(argv, envp, keepfd, retpid, infd, outfd, errfd, flags, hook, data, pidfile); } @@ -653,15 +647,14 @@ virExecWithHook(virConnectPtr conn, * list. */ int -virExec(virConnectPtr conn, - const char *const*argv, +virExec(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, int infd, int *outfd, int *errfd, int flags) { - return virExecWithHook(conn, argv, envp, keepfd, retpid, + return virExecWithHook(argv, envp, keepfd, retpid, infd, outfd, errfd, flags, NULL, NULL, NULL); } @@ -680,8 +673,7 @@ virExec(virConnectPtr conn, * occured and when in the process occured, the error output * could have gone to stderr or the passed errfd). */ -int virExecDaemonize(virConnectPtr conn, - const char *const*argv, +int virExecDaemonize(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -693,7 +685,7 @@ int virExecDaemonize(virConnectPtr conn, int ret; int childstat = 0; - ret = virExecWithHook(conn, argv, envp, keepfd, retpid, + ret = virExecWithHook(argv, envp, keepfd, retpid, infd, outfd, errfd, flags | VIR_EXEC_DAEMON, hook, data, pidfile); @@ -707,9 +699,9 @@ int virExecDaemonize(virConnectPtr conn, errno == EINTR); if (childstat != 0) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("Intermediate daemon process exited with status %d."), - WEXITSTATUS(childstat)); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("Intermediate daemon process exited with status %d."), + WEXITSTATUS(childstat)); ret = -2; } @@ -717,7 +709,7 @@ int virExecDaemonize(virConnectPtr conn, } static int -virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd, +virPipeReadUntilEOF(int outfd, int errfd, char **outbuf, char **errbuf) { struct pollfd fds[2]; @@ -752,8 +744,8 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd, if (fds[i].revents & POLLHUP) continue; - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("Unknown poll response.")); + virUtilError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Unknown poll response.")); goto error; } @@ -797,7 +789,6 @@ error: } /** - * @conn connection to report errors against * @argv NULL terminated argv to run * @status optional variable to return exit status in * @@ -812,8 +803,7 @@ error: * only if the command could not be run. */ int -virRunWithHook(virConnectPtr conn, - const char *const*argv, +virRunWithHook(const char *const*argv, virExecHook hook, void *data, int *status) { @@ -831,14 +821,14 @@ virRunWithHook(virConnectPtr conn, } DEBUG0(argv_str); - if ((execret = __virExec(conn, argv, NULL, NULL, + if ((execret = __virExec(argv, NULL, NULL, &childpid, -1, &outfd, &errfd, VIR_EXEC_NONE, hook, data, NULL)) < 0) { ret = execret; goto error; } - if (virPipeReadUntilEOF(conn, outfd, errfd, &outbuf, &errbuf) < 0) { + if (virPipeReadUntilEOF(outfd, errfd, &outbuf, &errbuf) < 0) { while (waitpid(childpid, &exitstatus, 0) == -1 && errno == EINTR) ; goto error; @@ -861,12 +851,12 @@ virRunWithHook(virConnectPtr conn, if (status == NULL) { errno = EINVAL; if (WIFEXITED(exitstatus) && WEXITSTATUS(exitstatus) != 0) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("'%s' exited with non-zero status %d and " - "signal %d: %s"), argv_str, - WIFEXITED(exitstatus) ? WEXITSTATUS(exitstatus) : 0, - WIFSIGNALED(exitstatus) ? WTERMSIG(exitstatus) : 0, - (errbuf ? errbuf : "")); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("'%s' exited with non-zero status %d and " + "signal %d: %s"), argv_str, + WIFEXITED(exitstatus) ? WEXITSTATUS(exitstatus) : 0, + WIFSIGNALED(exitstatus) ? WTERMSIG(exitstatus) : 0, + (errbuf ? errbuf : "")); goto error; } } else { @@ -889,8 +879,7 @@ virRunWithHook(virConnectPtr conn, #else /* __MINGW32__ */ int -virRunWithHook(virConnectPtr conn, - const char *const *argv ATTRIBUTE_UNUSED, +virRunWithHook(const char *const *argv ATTRIBUTE_UNUSED, virExecHook hook ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED, int *status) @@ -898,13 +887,12 @@ virRunWithHook(virConnectPtr conn, if (status) *status = ENOTSUP; else - ReportError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__); + virUtilError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__); return -1; } int -virExec(virConnectPtr conn, - const char *const*argv ATTRIBUTE_UNUSED, +virExec(const char *const*argv ATTRIBUTE_UNUSED, const char *const*envp ATTRIBUTE_UNUSED, const fd_set *keepfd ATTRIBUTE_UNUSED, int *retpid ATTRIBUTE_UNUSED, @@ -913,17 +901,16 @@ virExec(virConnectPtr conn, int *errfd ATTRIBUTE_UNUSED, int flags ATTRIBUTE_UNUSED) { - ReportError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__); + virUtilError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__); return -1; } #endif /* __MINGW32__ */ int -virRun(virConnectPtr conn, - const char *const*argv, +virRun(const char *const*argv, int *status) { - return virRunWithHook(conn, argv, NULL, NULL, status); + return virRunWithHook(argv, NULL, NULL, status); } /* Like gnulib's fread_file, but read no more than the specified maximum @@ -2177,8 +2164,8 @@ char *virIndexToDiskName(int idx, const char *prefix) int i, k, offset; if (idx < 0) { - ReportError(NULL, VIR_ERR_INTERNAL_ERROR, - _("Disk index %d is negative"), idx); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("Disk index %d is negative"), idx); return NULL; } @@ -2205,7 +2192,7 @@ char *virIndexToDiskName(int idx, const char *prefix) #define AI_CANONIDN 0 #endif -char *virGetHostname(virConnectPtr conn) +char *virGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED) { int r; char hostname[HOST_NAME_MAX+1], *result; @@ -2224,14 +2211,14 @@ char *virGetHostname(virConnectPtr conn) hints.ai_family = AF_UNSPEC; r = getaddrinfo(hostname, NULL, &hints, &info); if (r != 0) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("getaddrinfo failed for '%s': %s"), - hostname, gai_strerror(r)); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("getaddrinfo failed for '%s': %s"), + hostname, gai_strerror(r)); return NULL; } if (info->ai_canonname == NULL) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("could not determine canonical host name")); + virUtilError(VIR_ERR_INTERNAL_ERROR, + "%s", _("could not determine canonical host name")); freeaddrinfo(info); return NULL; } @@ -2385,21 +2372,18 @@ static char *virGetUserEnt(uid_t uid, return ret; } -char *virGetUserDirectory(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - uid_t uid) +char *virGetUserDirectory(uid_t uid) { return virGetUserEnt(uid, VIR_USER_ENT_DIRECTORY); } -char *virGetUserName(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - uid_t uid) +char *virGetUserName(uid_t uid) { return virGetUserEnt(uid, VIR_USER_ENT_NAME); } -int virGetUserID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - const char *name, +int virGetUserID(const char *name, uid_t *uid) { char *strbuf; @@ -2441,8 +2425,7 @@ int virGetUserID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, } -int virGetGroupID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - const char *name, +int virGetGroupID(const char *name, gid_t *gid) { char *strbuf; @@ -2520,7 +2503,7 @@ cleanup: #ifndef PROXY #if defined(UDEVADM) || defined(UDEVSETTLE) -void virFileWaitForDevices(virConnectPtr conn) +void virFileWaitForDevices(void) { #ifdef UDEVADM const char *const settleprog[] = { UDEVADM, "settle", NULL }; @@ -2538,11 +2521,11 @@ void virFileWaitForDevices(virConnectPtr conn) * If this fails for any reason, we still have the backup of polling for * 5 seconds for device nodes. */ - if (virRun(conn, settleprog, &exitstatus) < 0) + if (virRun(settleprog, &exitstatus) < 0) {} } #else -void virFileWaitForDevices(virConnectPtr conn ATTRIBUTE_UNUSED) {} +void virFileWaitForDevices(void) {} #endif #endif diff --git a/src/util/util.h b/src/util/util.h index b0219cc..bb545ac 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -49,8 +49,7 @@ int virSetCloseExec(int fd) ATTRIBUTE_RETURN_CHECK; * after fork() but before execve() */ typedef int (*virExecHook)(void *data); -int virExecDaemonize(virConnectPtr conn, - const char *const*argv, +int virExecDaemonize(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -59,8 +58,7 @@ int virExecDaemonize(virConnectPtr conn, virExecHook hook, void *data, char *pidfile) ATTRIBUTE_RETURN_CHECK; -int virExecWithHook(virConnectPtr conn, - const char *const*argv, +int virExecWithHook(const char *const*argv, const char *const*envp, const fd_set *keepfd, int *retpid, @@ -71,8 +69,7 @@ int virExecWithHook(virConnectPtr conn, virExecHook hook, void *data, char *pidfile) ATTRIBUTE_RETURN_CHECK; -int virExec(virConnectPtr conn, - const char *const*argv, +int virExec(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -80,8 +77,8 @@ int virExec(virConnectPtr conn, int *outfd, int *errfd, int flags) ATTRIBUTE_RETURN_CHECK; -int virRun(virConnectPtr conn, const char *const*argv, int *status) ATTRIBUTE_RETURN_CHECK; -int virRunWithHook(virConnectPtr conn, const char *const*argv, +int virRun(const char *const*argv, int *status) ATTRIBUTE_RETURN_CHECK; +int virRunWithHook(const char *const*argv, virExecHook hook, void *data, int *status) ATTRIBUTE_RETURN_CHECK; @@ -241,15 +238,11 @@ char *virGetHostname(virConnectPtr conn); int virKillProcess(pid_t pid, int sig); #ifdef HAVE_GETPWUID_R -char *virGetUserDirectory(virConnectPtr conn, - uid_t uid); -char *virGetUserName(virConnectPtr conn, - uid_t uid); -int virGetUserID(virConnectPtr conn, - const char *name, +char *virGetUserDirectory(uid_t uid); +char *virGetUserName(uid_t uid); +int virGetUserID(const char *name, uid_t *uid) ATTRIBUTE_RETURN_CHECK; -int virGetGroupID(virConnectPtr conn, - const char *name, +int virGetGroupID(const char *name, gid_t *gid) ATTRIBUTE_RETURN_CHECK; #endif @@ -260,7 +253,7 @@ int virRandom(int max); char *virFileFindMountPoint(const char *type); #endif -void virFileWaitForDevices(virConnectPtr conn); +void virFileWaitForDevices(void); #define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL) int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL; diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c index 300618b..63df442 100644 --- a/src/xen/proxy_internal.c +++ b/src/xen/proxy_internal.c @@ -155,7 +155,7 @@ virProxyForkServer(void) proxyarg[0] = proxyPath; proxyarg[1] = NULL; - if (virExecDaemonize(NULL, proxyarg, NULL, NULL, + if (virExecDaemonize(proxyarg, NULL, NULL, &pid, -1, NULL, NULL, 0, NULL, NULL, NULL) < 0) VIR_ERROR0("Failed to fork libvirt_proxy"); diff --git a/tools/virsh.c b/tools/virsh.c index 01d2038..761d145 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -7105,7 +7105,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) dir = vshCommandOptString(cmd, "dir", &found); if (!found) { uid_t uid = geteuid(); - dir = virGetUserDirectory(NULL, uid); + dir = virGetUserDirectory(uid); } if (!dir) dir = "/"; @@ -8706,7 +8706,7 @@ vshReadlineInit(vshControl *ctl) stifle_history(500); /* Prepare to read/write history from/to the ~/.virsh/history file */ - userdir = virGetUserDirectory(NULL, getuid()); + userdir = virGetUserDirectory(getuid()); if (userdir == NULL) return -1; -- 1.6.3.3

It was used for error reporting only. --- src/qemu/qemu_security_dac.c | 4 ++-- src/security/security_selinux.c | 4 ++-- src/storage/storage_backend_fs.c | 13 +++++-------- src/util/storage_file.c | 31 +++++++++++-------------------- src/util/storage_file.h | 6 ++---- 5 files changed, 22 insertions(+), 36 deletions(-) diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c index e6ada9a..c532368 100644 --- a/src/qemu/qemu_security_dac.c +++ b/src/qemu/qemu_security_dac.c @@ -105,7 +105,7 @@ err: static int -qemuSecurityDACSetSecurityImageLabel(virConnectPtr conn, +qemuSecurityDACSetSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm ATTRIBUTE_UNUSED, virDomainDiskDefPtr disk) @@ -125,7 +125,7 @@ qemuSecurityDACSetSecurityImageLabel(virConnectPtr conn, memset(&meta, 0, sizeof(meta)); - ret = virStorageFileGetMetadata(conn, path, &meta); + ret = virStorageFileGetMetadata(path, &meta); if (path != disk->src) VIR_FREE(path); diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 1b7f995..3c9ab62 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -407,7 +407,7 @@ SELinuxRestoreSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, } static int -SELinuxSetSecurityImageLabel(virConnectPtr conn, +SELinuxSetSecurityImageLabel(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjPtr vm, virDomainDiskDefPtr disk) @@ -428,7 +428,7 @@ SELinuxSetSecurityImageLabel(virConnectPtr conn, memset(&meta, 0, sizeof(meta)); - ret = virStorageFileGetMetadata(conn, path, &meta); + ret = virStorageFileGetMetadata(path, &meta); if (path != disk->src) VIR_FREE(path); diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index dcc5bf9..a431ac1 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -49,8 +49,7 @@ #define VIR_FROM_THIS VIR_FROM_STORAGE static int -virStorageBackendProbeTarget(virConnectPtr conn, - virStorageVolTargetPtr target, +virStorageBackendProbeTarget(virStorageVolTargetPtr target, char **backingStore, unsigned long long *allocation, unsigned long long *capacity, @@ -78,7 +77,7 @@ virStorageBackendProbeTarget(virConnectPtr conn, memset(&meta, 0, sizeof(meta)); - if (virStorageFileGetMetadataFromFD(conn, target->path, fd, &meta) < 0) { + if (virStorageFileGetMetadataFromFD(target->path, fd, &meta) < 0) { close(fd); return -1; } @@ -556,7 +555,7 @@ error: * within it. This is non-recursive. */ static int -virStorageBackendFileSystemRefresh(virConnectPtr conn, +virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { DIR *dir; @@ -591,8 +590,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn, if ((vol->key = strdup(vol->target.path)) == NULL) goto no_memory; - if ((ret = virStorageBackendProbeTarget(conn, - &vol->target, + if ((ret = virStorageBackendProbeTarget(&vol->target, &backingStore, &vol->allocation, &vol->capacity, @@ -633,8 +631,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn, } else { vol->backingStore.path = backingStore; - if ((ret = virStorageBackendProbeTarget(conn, - &vol->backingStore, + if ((ret = virStorageBackendProbeTarget(&vol->backingStore, NULL, NULL, NULL, NULL)) < 0) { if (ret == -1) diff --git a/src/util/storage_file.c b/src/util/storage_file.c index d78e236..0414085 100644 --- a/src/util/storage_file.c +++ b/src/util/storage_file.c @@ -70,16 +70,12 @@ struct FileTypeInfo { int qcowCryptOffset; /* Byte offset from start of file * where to find encryption mode, * -1 if encryption is not used */ - int (*getBackingStore)(virConnectPtr conn, char **res, - const unsigned char *buf, size_t buf_size); + int (*getBackingStore)(char **res, const unsigned char *buf, size_t buf_size); }; -static int cowGetBackingStore(virConnectPtr, char **, - const unsigned char *, size_t); -static int qcowXGetBackingStore(virConnectPtr, char **, - const unsigned char *, size_t); -static int vmdk4GetBackingStore(virConnectPtr, char **, - const unsigned char *, size_t); +static int cowGetBackingStore(char **, const unsigned char *, size_t); +static int qcowXGetBackingStore(char **, const unsigned char *, size_t); +static int vmdk4GetBackingStore(char **, const unsigned char *, size_t); static struct FileTypeInfo const fileTypeInfo[] = { @@ -139,8 +135,7 @@ static struct FileTypeInfo const fileTypeInfo[] = { }; static int -cowGetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - char **res, +cowGetBackingStore(char **res, const unsigned char *buf, size_t buf_size) { @@ -160,8 +155,7 @@ cowGetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, } static int -qcowXGetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - char **res, +qcowXGetBackingStore(char **res, const unsigned char *buf, size_t buf_size) { @@ -202,8 +196,7 @@ qcowXGetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, static int -vmdk4GetBackingStore(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - char **res, +vmdk4GetBackingStore(char **res, const unsigned char *buf, size_t buf_size) { @@ -274,8 +267,7 @@ absolutePathFromBaseFile(const char *base_file, const char *path) * it is, and info about its capacity if available. */ int -virStorageFileGetMetadataFromFD(virConnectPtr conn, - const char *path, +virStorageFileGetMetadataFromFD(const char *path, int fd, virStorageFileMetadata *meta) { @@ -367,7 +359,7 @@ virStorageFileGetMetadataFromFD(virConnectPtr conn, if (fileTypeInfo[i].getBackingStore != NULL) { char *base; - switch (fileTypeInfo[i].getBackingStore(conn, &base, head, len)) { + switch (fileTypeInfo[i].getBackingStore(&base, head, len)) { case BACKING_STORE_OK: break; @@ -405,8 +397,7 @@ virStorageFileGetMetadataFromFD(virConnectPtr conn, } int -virStorageFileGetMetadata(virConnectPtr conn, - const char *path, +virStorageFileGetMetadata(const char *path, virStorageFileMetadata *meta) { int fd, ret; @@ -416,7 +407,7 @@ virStorageFileGetMetadata(virConnectPtr conn, return -1; } - ret = virStorageFileGetMetadataFromFD(conn, path, fd, meta); + ret = virStorageFileGetMetadataFromFD(path, fd, meta); close(fd); diff --git a/src/util/storage_file.h b/src/util/storage_file.h index b0abcaf..ca69a1b 100644 --- a/src/util/storage_file.h +++ b/src/util/storage_file.h @@ -51,11 +51,9 @@ typedef struct _virStorageFileMetadata { bool encrypted; } virStorageFileMetadata; -int virStorageFileGetMetadata(virConnectPtr conn, - const char *path, +int virStorageFileGetMetadata(const char *path, virStorageFileMetadata *meta); -int virStorageFileGetMetadataFromFD(virConnectPtr conn, - const char *path, +int virStorageFileGetMetadataFromFD(const char *path, int fd, virStorageFileMetadata *meta); -- 1.6.3.3

It was used for error reporting only. --- po/POTFILES.in | 1 + src/lxc/lxc_driver.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/util/stats_linux.c | 44 +++++++++----------------------------------- src/util/stats_linux.h | 4 ++-- src/xen/xen_hypervisor.c | 2 +- 6 files changed, 15 insertions(+), 40 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 18f5243..3e6440e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -61,6 +61,7 @@ src/util/json.c src/util/logging.c src/util/pci.c src/util/processinfo.c +src/util/stats_linux.c src/util/storage_file.c src/util/util.c src/util/uuid.c diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 80a4935..42e411f 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2048,7 +2048,7 @@ lxcDomainInterfaceStats(virDomainPtr dom, } if (ret == 0) - ret = linuxDomainInterfaceStats(dom->conn, path, stats); + ret = linuxDomainInterfaceStats(path, stats); else lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG, _("Invalid path, '%s' is not a known interface"), path); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8d121a7..3a80603 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6821,7 +6821,7 @@ qemudDomainInterfaceStats (virDomainPtr dom, } if (ret == 0) - ret = linuxDomainInterfaceStats (dom->conn, path, stats); + ret = linuxDomainInterfaceStats(path, stats); else qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG, _("invalid path, '%s' is not a known interface"), path); diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c index 7d8a5f9..25f8d08 100644 --- a/src/util/stats_linux.c +++ b/src/util/stats_linux.c @@ -28,35 +28,9 @@ #define VIR_FROM_THIS VIR_FROM_STATS_LINUX -/** - * statsErrorFunc: - * @conn: the connection - * @error: the error number - * @func: the function failing - * @info: extra information string - * @value: extra information number - * - * Handle a stats error. - */ -static void -statsErrorFunc (virConnectPtr conn, - virErrorNumber error, const char *func, const char *info, - int value) -{ - char fullinfo[1000]; - const char *errmsg; - - errmsg = virErrorMsg(error, info); - if (func != NULL) { - snprintf(fullinfo, sizeof (fullinfo) - 1, "%s: %s", func, info); - fullinfo[sizeof (fullinfo) - 1] = 0; - info = fullinfo; - } - virRaiseError(conn, NULL, NULL, VIR_FROM_STATS_LINUX, error, - VIR_ERR_ERROR, - errmsg, info, NULL, value, 0, errmsg, info, - value); -} +#define virStatsError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) /*-------------------- interface stats --------------------*/ @@ -66,8 +40,8 @@ statsErrorFunc (virConnectPtr conn, */ int -linuxDomainInterfaceStats (virConnectPtr conn, const char *path, - struct _virDomainInterfaceStats *stats) +linuxDomainInterfaceStats(const char *path, + struct _virDomainInterfaceStats *stats) { int path_len; FILE *fp; @@ -75,8 +49,8 @@ linuxDomainInterfaceStats (virConnectPtr conn, const char *path, fp = fopen ("/proc/net/dev", "r"); if (!fp) { - statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "/proc/net/dev", errno); + virReportSystemError(errno, "%s", + _("Could not open /proc/net/dev")); return -1; } @@ -131,8 +105,8 @@ linuxDomainInterfaceStats (virConnectPtr conn, const char *path, } fclose (fp); - statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "/proc/net/dev: Interface not found", 0); + virStatsError(VIR_ERR_INTERNAL_ERROR, + "/proc/net/dev: Interface not found"); return -1; } diff --git a/src/util/stats_linux.h b/src/util/stats_linux.h index 033a50b..3b00620 100644 --- a/src/util/stats_linux.h +++ b/src/util/stats_linux.h @@ -15,8 +15,8 @@ #include "internal.h" -extern int linuxDomainInterfaceStats (virConnectPtr conn, const char *path, - struct _virDomainInterfaceStats *stats); +extern int linuxDomainInterfaceStats(const char *path, + struct _virDomainInterfaceStats *stats); #endif /* __linux__ */ diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index bdb0c3c..aabe546 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -1477,7 +1477,7 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom, return -1; } - return linuxDomainInterfaceStats (dom->conn, path, stats); + return linuxDomainInterfaceStats(path, stats); #else virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__, "/proc/net/dev: Interface not found", 0); -- 1.6.3.3

It was used for error reporting only. --- src/qemu/qemu_driver.c | 123 +++++++++++++++++--------------------- src/qemu/qemu_security_dac.c | 10 +-- src/security/security_selinux.c | 10 +-- src/util/pci.c | 113 ++++++++++++++++-------------------- src/util/pci.h | 32 ++++------- src/xen/xen_driver.c | 18 +++--- 6 files changed, 134 insertions(+), 172 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a80603..71f0364 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1105,7 +1105,7 @@ qemudStartup(int privileged) { qemu_driver->securityDriver)) == NULL) goto error; - if ((qemu_driver->activePciHostdevs = pciDeviceListNew(NULL)) == NULL) + if ((qemu_driver->activePciHostdevs = pciDeviceListNew()) == NULL) goto error; if (qemudLoadDriverConfig(qemu_driver, driverConf) < 0) { @@ -1268,7 +1268,7 @@ qemudShutdown(void) { return -1; qemuDriverLock(qemu_driver); - pciDeviceListFree(NULL, qemu_driver->activePciHostdevs); + pciDeviceListFree(qemu_driver->activePciHostdevs); virCapabilitiesFree(qemu_driver->caps); virDomainObjListDeinit(&qemu_driver->domains); @@ -2111,13 +2111,12 @@ static int qemudNextFreeVNCPort(struct qemud_driver *driver ATTRIBUTE_UNUSED) { } static pciDeviceList * -qemuGetPciHostDeviceList(virConnectPtr conn, - virDomainDefPtr def) +qemuGetPciHostDeviceList(virDomainDefPtr def) { pciDeviceList *list; int i; - if (!(list = pciDeviceListNew(conn))) + if (!(list = pciDeviceListNew())) return NULL; for (i = 0 ; i < def->nhostdevs ; i++) { @@ -2129,19 +2128,18 @@ qemuGetPciHostDeviceList(virConnectPtr conn, if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) continue; - dev = pciGetDevice(conn, - hostdev->source.subsys.u.pci.domain, + dev = pciGetDevice(hostdev->source.subsys.u.pci.domain, hostdev->source.subsys.u.pci.bus, hostdev->source.subsys.u.pci.slot, hostdev->source.subsys.u.pci.function); if (!dev) { - pciDeviceListFree(conn, list); + pciDeviceListFree(list); return NULL; } - if (pciDeviceListAdd(conn, list, dev) < 0) { - pciFreeDevice(conn, dev); - pciDeviceListFree(conn, list); + if (pciDeviceListAdd(list, dev) < 0) { + pciFreeDevice(dev); + pciDeviceListFree(list); return NULL; } @@ -2162,16 +2160,14 @@ qemuUpdateActivePciHostdevs(struct qemud_driver *driver, if (!def->nhostdevs) return 0; - if (!(pcidevs = qemuGetPciHostDeviceList(NULL, def))) + if (!(pcidevs = qemuGetPciHostDeviceList(def))) return -1; for (i = 0; i < pciDeviceListCount(pcidevs); i++) { pciDevice *dev = pciDeviceListGet(pcidevs, i); - pciDeviceListSteal(NULL, pcidevs, dev); - if (pciDeviceListAdd(NULL, - driver->activePciHostdevs, - dev) < 0) { - pciFreeDevice(NULL, dev); + pciDeviceListSteal(pcidevs, dev); + if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) { + pciFreeDevice(dev); goto cleanup; } } @@ -2179,13 +2175,12 @@ qemuUpdateActivePciHostdevs(struct qemud_driver *driver, ret = 0; cleanup: - pciDeviceListFree(NULL, pcidevs); + pciDeviceListFree(pcidevs); return ret; } static int -qemuPrepareHostDevices(virConnectPtr conn, - struct qemud_driver *driver, +qemuPrepareHostDevices(struct qemud_driver *driver, virDomainDefPtr def) { pciDeviceList *pcidevs; @@ -2195,7 +2190,7 @@ qemuPrepareHostDevices(virConnectPtr conn, if (!def->nhostdevs) return 0; - if (!(pcidevs = qemuGetPciHostDeviceList(conn, def))) + if (!(pcidevs = qemuGetPciHostDeviceList(def))) return -1; /* We have to use 3 loops here. *All* devices must @@ -2212,11 +2207,11 @@ qemuPrepareHostDevices(virConnectPtr conn, for (i = 0; i < pciDeviceListCount(pcidevs); i++) { pciDevice *dev = pciDeviceListGet(pcidevs, i); - if (!pciDeviceIsAssignable(conn, dev, !driver->relaxedACS)) + if (!pciDeviceIsAssignable(dev, !driver->relaxedACS)) goto cleanup; if (pciDeviceGetManaged(dev) && - pciDettachDevice(conn, dev) < 0) + pciDettachDevice(dev) < 0) goto cleanup; } @@ -2224,19 +2219,16 @@ qemuPrepareHostDevices(virConnectPtr conn, * reset them */ for (i = 0; i < pciDeviceListCount(pcidevs); i++) { pciDevice *dev = pciDeviceListGet(pcidevs, i); - if (pciResetDevice(conn, dev, - driver->activePciHostdevs) < 0) + if (pciResetDevice(dev, driver->activePciHostdevs) < 0) goto cleanup; } /* Now mark all the devices as active */ for (i = 0; i < pciDeviceListCount(pcidevs); i++) { pciDevice *dev = pciDeviceListGet(pcidevs, i); - pciDeviceListSteal(NULL, pcidevs, dev); - if (pciDeviceListAdd(conn, - driver->activePciHostdevs, - dev) < 0) { - pciFreeDevice(NULL, dev); + pciDeviceListSteal(pcidevs, dev); + if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) { + pciFreeDevice(dev); goto cleanup; } } @@ -2244,7 +2236,7 @@ qemuPrepareHostDevices(virConnectPtr conn, ret = 0; cleanup: - pciDeviceListFree(conn, pcidevs); + pciDeviceListFree(pcidevs); return ret; } @@ -2259,7 +2251,7 @@ qemudReattachManagedDevice(pciDevice *dev) usleep(100*1000); retries--; } - if (pciReAttachDevice(NULL, dev) < 0) { + if (pciReAttachDevice(dev) < 0) { virErrorPtr err = virGetLastError(); VIR_ERROR(_("Failed to re-attach PCI device: %s"), err ? err->message : ""); @@ -2269,8 +2261,7 @@ qemudReattachManagedDevice(pciDevice *dev) } static void -qemuDomainReAttachHostDevices(virConnectPtr conn, - struct qemud_driver *driver, +qemuDomainReAttachHostDevices(struct qemud_driver *driver, virDomainDefPtr def) { pciDeviceList *pcidevs; @@ -2279,7 +2270,7 @@ qemuDomainReAttachHostDevices(virConnectPtr conn, if (!def->nhostdevs) return; - if (!(pcidevs = qemuGetPciHostDeviceList(conn, def))) { + if (!(pcidevs = qemuGetPciHostDeviceList(def))) { virErrorPtr err = virGetLastError(); VIR_ERROR(_("Failed to allocate pciDeviceList: %s"), err ? err->message : ""); @@ -2292,13 +2283,12 @@ qemuDomainReAttachHostDevices(virConnectPtr conn, for (i = 0; i < pciDeviceListCount(pcidevs); i++) { pciDevice *dev = pciDeviceListGet(pcidevs, i); - pciDeviceListDel(conn, driver->activePciHostdevs, dev); + pciDeviceListDel(driver->activePciHostdevs, dev); } for (i = 0; i < pciDeviceListCount(pcidevs); i++) { pciDevice *dev = pciDeviceListGet(pcidevs, i); - if (pciResetDevice(conn, dev, - driver->activePciHostdevs) < 0) { + if (pciResetDevice(dev, driver->activePciHostdevs) < 0) { virErrorPtr err = virGetLastError(); VIR_ERROR(_("Failed to reset PCI device: %s"), err ? err->message : ""); @@ -2311,7 +2301,7 @@ qemuDomainReAttachHostDevices(virConnectPtr conn, qemudReattachManagedDevice(dev); } - pciDeviceListFree(conn, pcidevs); + pciDeviceListFree(pcidevs); } static const char *const defaultDeviceACL[] = { @@ -2611,7 +2601,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, if (qemuSetupCgroup(driver, vm) < 0) goto cleanup; - if (qemuPrepareHostDevices(conn, driver, vm->def) < 0) + if (qemuPrepareHostDevices(driver, vm->def) < 0) goto cleanup; if (VIR_ALLOC(priv->monConfig) < 0) { @@ -2784,7 +2774,7 @@ cleanup: /* We jump here if we failed to start the VM for any reason * XXX investigate if we can kill this block and safely call * qemudShutdownVMDaemon even though no PID is running */ - qemuDomainReAttachHostDevices(conn, driver, vm->def); + qemuDomainReAttachHostDevices(driver, vm->def); if (driver->securityDriver && driver->securityDriver->domainRestoreSecurityAllLabel) @@ -2889,7 +2879,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, qemuDomainPCIAddressSetFree(priv->pciaddrs); priv->pciaddrs = NULL; - qemuDomainReAttachHostDevices(conn, driver, vm->def); + qemuDomainReAttachHostDevices(driver, vm->def); retry: if ((ret = qemuRemoveCgroup(conn, driver, vm, 0)) < 0) { @@ -5739,8 +5729,7 @@ no_memory: } -static int qemudDomainAttachHostPciDevice(virConnectPtr conn, - struct qemud_driver *driver, +static int qemudDomainAttachHostPciDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, int qemuCmdFlags) @@ -5756,23 +5745,22 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn, return -1; } - pci = pciGetDevice(conn, - hostdev->source.subsys.u.pci.domain, + pci = pciGetDevice(hostdev->source.subsys.u.pci.domain, hostdev->source.subsys.u.pci.bus, hostdev->source.subsys.u.pci.slot, hostdev->source.subsys.u.pci.function); if (!pci) return -1; - if (!pciDeviceIsAssignable(conn, pci, !driver->relaxedACS) || - (hostdev->managed && pciDettachDevice(conn, pci) < 0) || - pciResetDevice(conn, pci, driver->activePciHostdevs) < 0) { - pciFreeDevice(conn, pci); + if (!pciDeviceIsAssignable(pci, !driver->relaxedACS) || + (hostdev->managed && pciDettachDevice(pci) < 0) || + pciResetDevice(pci, driver->activePciHostdevs) < 0) { + pciFreeDevice(pci); return -1; } - if (pciDeviceListAdd(conn, driver->activePciHostdevs, pci) < 0) { - pciFreeDevice(conn, pci); + if (pciDeviceListAdd(driver->activePciHostdevs, pci) < 0) { + pciFreeDevice(pci); return -1; } @@ -5810,7 +5798,7 @@ error: VIR_WARN0("Unable to release PCI address on host device"); VIR_FREE(devstr); - pciDeviceListDel(conn, driver->activePciHostdevs, pci); + pciDeviceListDel(driver->activePciHostdevs, pci); return -1; } @@ -5877,7 +5865,7 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn, switch (hostdev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - if (qemudDomainAttachHostPciDevice(conn, driver, vm, + if (qemudDomainAttachHostPciDevice(driver, vm, hostdev, qemuCmdFlags) < 0) goto error; break; @@ -6321,8 +6309,7 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn, ret = 0; - pci = pciGetDevice(conn, - detach->source.subsys.u.pci.domain, + pci = pciGetDevice(detach->source.subsys.u.pci.domain, detach->source.subsys.u.pci.bus, detach->source.subsys.u.pci.slot, detach->source.subsys.u.pci.function); @@ -6330,11 +6317,11 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn, ret = -1; else { pciDeviceSetManaged(pci, detach->managed); - pciDeviceListDel(conn, driver->activePciHostdevs, pci); - if (pciResetDevice(conn, pci, driver->activePciHostdevs) < 0) + pciDeviceListDel(driver->activePciHostdevs, pci); + if (pciResetDevice(pci, driver->activePciHostdevs) < 0) ret = -1; qemudReattachManagedDevice(pci); - pciFreeDevice(conn, pci); + pciFreeDevice(pci); } if (vm->def->nhostdevs > 1) { @@ -8439,16 +8426,16 @@ qemudNodeDeviceDettach (virNodeDevicePtr dev) if (qemudNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0) return -1; - pci = pciGetDevice(dev->conn, domain, bus, slot, function); + pci = pciGetDevice(domain, bus, slot, function); if (!pci) return -1; - if (pciDettachDevice(dev->conn, pci) < 0) + if (pciDettachDevice(pci) < 0) goto out; ret = 0; out: - pciFreeDevice(dev->conn, pci); + pciFreeDevice(pci); return ret; } @@ -8462,16 +8449,16 @@ qemudNodeDeviceReAttach (virNodeDevicePtr dev) if (qemudNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0) return -1; - pci = pciGetDevice(dev->conn, domain, bus, slot, function); + pci = pciGetDevice(domain, bus, slot, function); if (!pci) return -1; - if (pciReAttachDevice(dev->conn, pci) < 0) + if (pciReAttachDevice(pci) < 0) goto out; ret = 0; out: - pciFreeDevice(dev->conn, pci); + pciFreeDevice(pci); return ret; } @@ -8486,19 +8473,19 @@ qemudNodeDeviceReset (virNodeDevicePtr dev) if (qemudNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0) return -1; - pci = pciGetDevice(dev->conn, domain, bus, slot, function); + pci = pciGetDevice(domain, bus, slot, function); if (!pci) return -1; qemuDriverLock(driver); - if (pciResetDevice(dev->conn, pci, driver->activePciHostdevs) < 0) + if (pciResetDevice(pci, driver->activePciHostdevs) < 0) goto out; ret = 0; out: qemuDriverUnlock(driver); - pciFreeDevice(dev->conn, pci); + pciFreeDevice(pci); return ret; } diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c index c532368..f06a8bc 100644 --- a/src/qemu/qemu_security_dac.c +++ b/src/qemu/qemu_security_dac.c @@ -225,8 +225,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn, } case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { - pciDevice *pci = pciGetDevice(conn, - dev->source.subsys.u.pci.domain, + pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain, dev->source.subsys.u.pci.bus, dev->source.subsys.u.pci.slot, dev->source.subsys.u.pci.function); @@ -235,7 +234,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn, goto done; ret = pciDeviceFileIterate(conn, pci, qemuSecurityDACSetSecurityPCILabel, vm); - pciFreeDevice(conn, pci); + pciFreeDevice(pci); break; } @@ -302,8 +301,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn, } case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { - pciDevice *pci = pciGetDevice(conn, - dev->source.subsys.u.pci.domain, + pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain, dev->source.subsys.u.pci.bus, dev->source.subsys.u.pci.slot, dev->source.subsys.u.pci.function); @@ -312,7 +310,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn, goto done; ret = pciDeviceFileIterate(conn, pci, qemuSecurityDACRestoreSecurityPCILabel, NULL); - pciFreeDevice(conn, pci); + pciFreeDevice(pci); break; } diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 3c9ab62..902ace0 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -513,8 +513,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn, } case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { - pciDevice *pci = pciGetDevice(conn, - dev->source.subsys.u.pci.domain, + pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain, dev->source.subsys.u.pci.bus, dev->source.subsys.u.pci.slot, dev->source.subsys.u.pci.function); @@ -523,7 +522,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn, goto done; ret = pciDeviceFileIterate(conn, pci, SELinuxSetSecurityPCILabel, vm); - pciFreeDevice(conn, pci); + pciFreeDevice(pci); break; } @@ -589,8 +588,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn, } case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { - pciDevice *pci = pciGetDevice(conn, - dev->source.subsys.u.pci.domain, + pciDevice *pci = pciGetDevice(dev->source.subsys.u.pci.domain, dev->source.subsys.u.pci.bus, dev->source.subsys.u.pci.slot, dev->source.subsys.u.pci.function); @@ -599,7 +597,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn, goto done; ret = pciDeviceFileIterate(conn, pci, SELinuxRestoreSecurityPCILabel, NULL); - pciFreeDevice(conn, pci); + pciFreeDevice(pci); break; } diff --git a/src/util/pci.c b/src/util/pci.c index 88d163f..e639910 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -75,8 +75,8 @@ struct _pciDeviceList { /* For virReportOOMError() and virReportSystemError() */ #define VIR_FROM_THIS VIR_FROM_NONE -#define pciReportError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ +#define pciReportError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) /* Specifications referenced in comments: @@ -262,8 +262,7 @@ typedef int (*pciIterPredicate)(pciDevice *, pciDevice *, void *); * safe to reset if there is an error. */ static int -pciIterDevices(virConnectPtr conn, - pciIterPredicate predicate, +pciIterDevices(pciIterPredicate predicate, pciDevice *dev, pciDevice **matched, void *data) @@ -296,7 +295,7 @@ pciIterDevices(virConnectPtr conn, continue; } - check = pciGetDevice(conn, domain, bus, slot, function); + check = pciGetDevice(domain, bus, slot, function); if (!check) { ret = -1; break; @@ -307,7 +306,7 @@ pciIterDevices(virConnectPtr conn, *matched = check; break; } - pciFreeDevice(conn, check); + pciFreeDevice(check); } closedir(dir); return ret; @@ -452,12 +451,11 @@ pciSharesBusWithActive(pciDevice *dev, pciDevice *check, void *data) } static pciDevice * -pciBusContainsActiveDevices(virConnectPtr conn, - pciDevice *dev, +pciBusContainsActiveDevices(pciDevice *dev, pciDeviceList *activeDevs) { pciDevice *active = NULL; - if (pciIterDevices(conn, pciSharesBusWithActive, + if (pciIterDevices(pciSharesBusWithActive, dev, &active, activeDevs) < 0) return NULL; return active; @@ -493,10 +491,10 @@ pciIsParent(pciDevice *dev, pciDevice *check, void *data ATTRIBUTE_UNUSED) } static pciDevice * -pciGetParentDevice(virConnectPtr conn, pciDevice *dev) +pciGetParentDevice(pciDevice *dev) { pciDevice *parent = NULL; - pciIterDevices(conn, pciIsParent, dev, &parent, NULL); + pciIterDevices(pciIsParent, dev, &parent, NULL); return parent; } @@ -504,8 +502,7 @@ pciGetParentDevice(virConnectPtr conn, pciDevice *dev) * devices behind a bus. */ static int -pciTrySecondaryBusReset(virConnectPtr conn, - pciDevice *dev, +pciTrySecondaryBusReset(pciDevice *dev, pciDeviceList *activeDevs) { pciDevice *parent, *conflict; @@ -518,17 +515,17 @@ pciTrySecondaryBusReset(virConnectPtr conn, * In future, we could allow it so long as those devices * are not in use by the host or other guests. */ - if ((conflict = pciBusContainsActiveDevices(conn, dev, activeDevs))) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + if ((conflict = pciBusContainsActiveDevices(dev, activeDevs))) { + pciReportError(VIR_ERR_NO_SUPPORT, _("Active %s devices on bus with %s, not doing bus reset"), conflict->name, dev->name); return -1; } /* Find the parent bus */ - parent = pciGetParentDevice(conn, dev); + parent = pciGetParentDevice(dev); if (!parent) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Failed to find parent device for %s"), dev->name); return -1; @@ -541,7 +538,7 @@ pciTrySecondaryBusReset(virConnectPtr conn, * are multiple devices/functions */ if (pciRead(dev, 0, config_space, PCI_CONF_LEN) < 0) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Failed to save PCI config space for %s"), dev->name); goto out; @@ -561,14 +558,14 @@ pciTrySecondaryBusReset(virConnectPtr conn, usleep(200 * 1000); /* sleep 200ms */ if (pciWrite(dev, 0, config_space, PCI_CONF_LEN) < 0) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Failed to restore PCI config space for %s"), dev->name); goto out; } ret = 0; out: - pciFreeDevice(conn, parent); + pciFreeDevice(parent); return ret; } @@ -577,7 +574,7 @@ out: * above we require the device supports a full internal reset. */ static int -pciTryPowerManagementReset(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev) +pciTryPowerManagementReset(pciDevice *dev) { uint8_t config_space[PCI_CONF_LEN]; uint32_t ctl; @@ -587,7 +584,7 @@ pciTryPowerManagementReset(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev) /* Save and restore the device's config space. */ if (pciRead(dev, 0, &config_space[0], PCI_CONF_LEN) < 0) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Failed to save PCI config space for %s"), dev->name); return -1; @@ -607,7 +604,7 @@ pciTryPowerManagementReset(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev) usleep(10 * 1000); /* sleep 10ms */ if (pciWrite(dev, 0, &config_space[0], PCI_CONF_LEN) < 0) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Failed to restore PCI config space for %s"), dev->name); return -1; @@ -635,14 +632,13 @@ pciInitDevice(pciDevice *dev) } int -pciResetDevice(virConnectPtr conn, - pciDevice *dev, +pciResetDevice(pciDevice *dev, pciDeviceList *activeDevs) { int ret = -1; if (activeDevs && pciDeviceListFind(activeDevs, dev)) { - pciReportError(conn, VIR_ERR_INTERNAL_ERROR, + pciReportError(VIR_ERR_INTERNAL_ERROR, _("Not resetting active device %s"), dev->name); return -1; } @@ -661,15 +657,15 @@ pciResetDevice(virConnectPtr conn, * the function, not the whole device. */ if (dev->has_pm_reset) - ret = pciTryPowerManagementReset(conn, dev); + ret = pciTryPowerManagementReset(dev); /* Bus reset is not an option with the root bus */ if (ret < 0 && dev->bus != 0) - ret = pciTrySecondaryBusReset(conn, dev, activeDevs); + ret = pciTrySecondaryBusReset(dev, activeDevs); if (ret < 0) { virErrorPtr err = virGetLastError(); - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Unable to reset PCI device %s: %s"), dev->name, err ? err->message : _("no FLR, PM reset or bus reset available")); @@ -810,11 +806,11 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) } int -pciDettachDevice(virConnectPtr conn, pciDevice *dev) +pciDettachDevice(pciDevice *dev) { const char *driver = pciFindStubDriver(); if (!driver) { - pciReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot find any PCI stub module")); return -1; } @@ -871,11 +867,11 @@ pciUnBindDeviceFromStub(pciDevice *dev, const char *driver) } int -pciReAttachDevice(virConnectPtr conn, pciDevice *dev) +pciReAttachDevice(pciDevice *dev) { const char *driver = pciFindStubDriver(); if (!driver) { - pciReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", + pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot find any PCI stub module")); return -1; } @@ -1006,8 +1002,7 @@ pciReadDeviceID(pciDevice *dev, const char *id_name) } pciDevice * -pciGetDevice(virConnectPtr conn, - unsigned domain, +pciGetDevice(unsigned domain, unsigned bus, unsigned slot, unsigned function) @@ -1035,12 +1030,12 @@ pciGetDevice(virConnectPtr conn, product = pciReadDeviceID(dev, "device"); if (!vendor || !product) { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Failed to read product/vendor ID for %s"), dev->name); VIR_FREE(product); VIR_FREE(vendor); - pciFreeDevice(conn, dev); + pciFreeDevice(dev); return NULL; } @@ -1056,7 +1051,7 @@ pciGetDevice(virConnectPtr conn, } void -pciFreeDevice(virConnectPtr conn ATTRIBUTE_UNUSED, pciDevice *dev) +pciFreeDevice(pciDevice *dev) { if (!dev) return; @@ -1077,7 +1072,7 @@ unsigned pciDeviceGetManaged(pciDevice *dev) } pciDeviceList * -pciDeviceListNew(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/) +pciDeviceListNew(void) { pciDeviceList *list; @@ -1090,8 +1085,7 @@ pciDeviceListNew(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/) } void -pciDeviceListFree(virConnectPtr conn, - pciDeviceList *list) +pciDeviceListFree(pciDeviceList *list) { int i; @@ -1099,7 +1093,7 @@ pciDeviceListFree(virConnectPtr conn, return; for (i = 0; i < list->count; i++) { - pciFreeDevice(conn, list->devs[i]); + pciFreeDevice(list->devs[i]); list->devs[i] = NULL; } @@ -1109,12 +1103,11 @@ pciDeviceListFree(virConnectPtr conn, } int -pciDeviceListAdd(virConnectPtr conn, - pciDeviceList *list, +pciDeviceListAdd(pciDeviceList *list, pciDevice *dev) { if (pciDeviceListFind(list, dev)) { - pciReportError(conn, VIR_ERR_INTERNAL_ERROR, + pciReportError(VIR_ERR_INTERNAL_ERROR, _("Device %s is already in use"), dev->name); return -1; } @@ -1148,8 +1141,7 @@ pciDeviceListCount(pciDeviceList *list) } pciDevice * -pciDeviceListSteal(virConnectPtr conn ATTRIBUTE_UNUSED, - pciDeviceList *list, +pciDeviceListSteal(pciDeviceList *list, pciDevice *dev) { pciDevice *ret = NULL; @@ -1179,13 +1171,12 @@ pciDeviceListSteal(virConnectPtr conn ATTRIBUTE_UNUSED, } void -pciDeviceListDel(virConnectPtr conn, - pciDeviceList *list, +pciDeviceListDel(pciDeviceList *list, pciDevice *dev) { - pciDevice *ret = pciDeviceListSteal(conn, list, dev); + pciDevice *ret = pciDeviceListSteal(list, dev); if (ret) - pciFreeDevice(conn, ret); + pciFreeDevice(ret); } pciDevice * @@ -1289,12 +1280,11 @@ pciDeviceDownstreamLacksACS(pciDevice *dev) } static int -pciDeviceIsBehindSwitchLackingACS(virConnectPtr conn, - pciDevice *dev) +pciDeviceIsBehindSwitchLackingACS(pciDevice *dev) { pciDevice *parent; - parent = pciGetParentDevice(conn, dev); + parent = pciGetParentDevice(dev); if (!parent) { /* if we have no parent, and this is the root bus, ACS doesn't come * into play since devices on the root bus can't P2P without going @@ -1303,7 +1293,7 @@ pciDeviceIsBehindSwitchLackingACS(virConnectPtr conn, if (dev->bus == 0) return 0; else { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Failed to find parent device for %s"), dev->name); return -1; @@ -1321,7 +1311,7 @@ pciDeviceIsBehindSwitchLackingACS(virConnectPtr conn, acs = pciDeviceDownstreamLacksACS(parent); if (acs) { - pciFreeDevice(conn, parent); + pciFreeDevice(parent); if (acs < 0) return -1; else @@ -1329,15 +1319,14 @@ pciDeviceIsBehindSwitchLackingACS(virConnectPtr conn, } tmp = parent; - parent = pciGetParentDevice(conn, parent); - pciFreeDevice(conn, tmp); + parent = pciGetParentDevice(parent); + pciFreeDevice(tmp); } while (parent); return 0; } -int pciDeviceIsAssignable(virConnectPtr conn, - pciDevice *dev, +int pciDeviceIsAssignable(pciDevice *dev, int strict_acs_check) { int ret; @@ -1347,7 +1336,7 @@ int pciDeviceIsAssignable(virConnectPtr conn, * or bound to a stub driver. */ - ret = pciDeviceIsBehindSwitchLackingACS(conn, dev); + ret = pciDeviceIsBehindSwitchLackingACS(dev); if (ret < 0) return 0; @@ -1356,7 +1345,7 @@ int pciDeviceIsAssignable(virConnectPtr conn, VIR_DEBUG("%s %s: strict ACS check disabled; device assignment allowed", dev->id, dev->name); } else { - pciReportError(conn, VIR_ERR_NO_SUPPORT, + pciReportError(VIR_ERR_NO_SUPPORT, _("Device %s is behind a switch lacking ACS and " "cannot be assigned"), dev->name); diff --git a/src/util/pci.h b/src/util/pci.h index e6ab137..ad518a5 100644 --- a/src/util/pci.h +++ b/src/util/pci.h @@ -27,38 +27,29 @@ typedef struct _pciDevice pciDevice; typedef struct _pciDeviceList pciDeviceList; -pciDevice *pciGetDevice (virConnectPtr conn, - unsigned domain, +pciDevice *pciGetDevice (unsigned domain, unsigned bus, unsigned slot, unsigned function); -void pciFreeDevice (virConnectPtr conn, - pciDevice *dev); -int pciDettachDevice (virConnectPtr conn, - pciDevice *dev); -int pciReAttachDevice (virConnectPtr conn, - pciDevice *dev); -int pciResetDevice (virConnectPtr conn, - pciDevice *dev, +void pciFreeDevice (pciDevice *dev); +int pciDettachDevice (pciDevice *dev); +int pciReAttachDevice (pciDevice *dev); +int pciResetDevice (pciDevice *dev, pciDeviceList *activeDevs); void pciDeviceSetManaged(pciDevice *dev, unsigned managed); unsigned pciDeviceGetManaged(pciDevice *dev); -pciDeviceList *pciDeviceListNew (virConnectPtr conn); -void pciDeviceListFree (virConnectPtr conn, - pciDeviceList *list); -int pciDeviceListAdd (virConnectPtr conn, - pciDeviceList *list, +pciDeviceList *pciDeviceListNew (void); +void pciDeviceListFree (pciDeviceList *list); +int pciDeviceListAdd (pciDeviceList *list, pciDevice *dev); pciDevice * pciDeviceListGet (pciDeviceList *list, int idx); int pciDeviceListCount (pciDeviceList *list); -pciDevice * pciDeviceListSteal (virConnectPtr conn, - pciDeviceList *list, +pciDevice * pciDeviceListSteal (pciDeviceList *list, pciDevice *dev); -void pciDeviceListDel (virConnectPtr conn, - pciDeviceList *list, +void pciDeviceListDel (pciDeviceList *list, pciDevice *dev); pciDevice * pciDeviceListFind (pciDeviceList *list, pciDevice *dev); @@ -78,8 +69,7 @@ int pciDeviceFileIterate(virConnectPtr conn, pciDeviceFileActor actor, void *opaque); -int pciDeviceIsAssignable(virConnectPtr conn, - pciDevice *dev, +int pciDeviceIsAssignable(pciDevice *dev, int strict_acs_check); int pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher); diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index c5da026..cee4cea 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1725,16 +1725,16 @@ xenUnifiedNodeDeviceDettach (virNodeDevicePtr dev) if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0) return -1; - pci = pciGetDevice(dev->conn, domain, bus, slot, function); + pci = pciGetDevice(domain, bus, slot, function); if (!pci) return -1; - if (pciDettachDevice(dev->conn, pci) < 0) + if (pciDettachDevice(pci) < 0) goto out; ret = 0; out: - pciFreeDevice(dev->conn, pci); + pciFreeDevice(pci); return ret; } @@ -1748,16 +1748,16 @@ xenUnifiedNodeDeviceReAttach (virNodeDevicePtr dev) if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0) return -1; - pci = pciGetDevice(dev->conn, domain, bus, slot, function); + pci = pciGetDevice(domain, bus, slot, function); if (!pci) return -1; - if (pciReAttachDevice(dev->conn, pci) < 0) + if (pciReAttachDevice(pci) < 0) goto out; ret = 0; out: - pciFreeDevice(dev->conn, pci); + pciFreeDevice(pci); return ret; } @@ -1771,16 +1771,16 @@ xenUnifiedNodeDeviceReset (virNodeDevicePtr dev) if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0) return -1; - pci = pciGetDevice(dev->conn, domain, bus, slot, function); + pci = pciGetDevice(domain, bus, slot, function); if (!pci) return -1; - if (pciResetDevice(dev->conn, pci, NULL) < 0) + if (pciResetDevice(pci, NULL) < 0) goto out; ret = 0; out: - pciFreeDevice(dev->conn, pci); + pciFreeDevice(pci); return ret; } -- 1.6.3.3

--- src/util/json.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/util/json.c b/src/util/json.c index 62bf8e2..3abff58 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -36,8 +36,8 @@ /* XXX fixme */ #define VIR_FROM_THIS VIR_FROM_NONE -#define ReportError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ +#define virJSONError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) @@ -909,9 +909,9 @@ virJSONValuePtr virJSONValueFromString(const char *jsonstring) (const unsigned char*)jsonstring, strlen(jsonstring)); - ReportError(NULL, VIR_ERR_INTERNAL_ERROR, - _("cannot parse json %s: %s"), - jsonstring, (const char*) errstr); + virJSONError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse json %s: %s"), + jsonstring, (const char*) errstr); VIR_FREE(errstr); virJSONValueFree(parser.head); goto cleanup; @@ -1034,14 +1034,14 @@ cleanup: #else virJSONValuePtr virJSONValueFromString(const char *jsonstring ATTRIBUTE_UNUSED) { - ReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("No JSON parser implementation is available")); + virJSONError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No JSON parser implementation is available")); return NULL; } char *virJSONValueToString(virJSONValuePtr object ATTRIBUTE_UNUSED) { - ReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", - _("No JSON parser implementation is available")); + virJSONError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No JSON parser implementation is available")); return NULL; } #endif -- 1.6.3.3

It was used for error reporting only. --- src/qemu/qemu_security_dac.c | 10 ++++------ src/security/security_selinux.c | 10 ++++------ src/security/virt-aa-helper.c | 15 +++++++-------- src/util/hostusb.c | 29 +++++++++++++---------------- src/util/hostusb.h | 6 ++---- 5 files changed, 30 insertions(+), 40 deletions(-) diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c index f06a8bc..e753490 100644 --- a/src/qemu/qemu_security_dac.c +++ b/src/qemu/qemu_security_dac.c @@ -210,8 +210,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn, switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: { - usbDevice *usb = usbGetDevice(conn, - dev->source.subsys.u.usb.bus, + usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus, dev->source.subsys.u.usb.device, dev->source.subsys.u.usb.vendor, dev->source.subsys.u.usb.product); @@ -220,7 +219,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn, goto done; ret = usbDeviceFileIterate(conn, usb, qemuSecurityDACSetSecurityUSBLabel, vm); - usbFreeDevice(conn, usb); + usbFreeDevice(usb); break; } @@ -285,8 +284,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn, switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: { - usbDevice *usb = usbGetDevice(conn, - dev->source.subsys.u.usb.bus, + usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus, dev->source.subsys.u.usb.device, dev->source.subsys.u.usb.vendor, dev->source.subsys.u.usb.product); @@ -295,7 +293,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn, goto done; ret = usbDeviceFileIterate(conn, usb, qemuSecurityDACRestoreSecurityUSBLabel, NULL); - usbFreeDevice(conn, usb); + usbFreeDevice(usb); break; } diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 902ace0..a97d3de 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -498,8 +498,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn, switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: { - usbDevice *usb = usbGetDevice(conn, - dev->source.subsys.u.usb.bus, + usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus, dev->source.subsys.u.usb.device, dev->source.subsys.u.usb.vendor, dev->source.subsys.u.usb.product); @@ -508,7 +507,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn, goto done; ret = usbDeviceFileIterate(conn, usb, SELinuxSetSecurityUSBLabel, vm); - usbFreeDevice(conn, usb); + usbFreeDevice(usb); break; } @@ -572,8 +571,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn, switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: { - usbDevice *usb = usbGetDevice(conn, - dev->source.subsys.u.usb.bus, + usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus, dev->source.subsys.u.usb.device, dev->source.subsys.u.usb.vendor, dev->source.subsys.u.usb.product); @@ -582,7 +580,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn, goto done; ret = usbDeviceFileIterate(conn, usb, SELinuxRestoreSecurityUSBLabel, NULL); - usbFreeDevice(conn, usb); + usbFreeDevice(usb); break; } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 81ba1ae..619c8c3 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -836,25 +836,24 @@ get_files(vahControl * ctl) virDomainHostdevDefPtr dev = ctl->def->hostdevs[i]; switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: { - usbDevice *usb = usbGetDevice(NULL, - dev->source.subsys.u.usb.bus, - dev->source.subsys.u.usb.device, - dev->source.subsys.u.usb.vendor, - dev->source.subsys.u.usb.product); + usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus, + dev->source.subsys.u.usb.device, + dev->source.subsys.u.usb.vendor, + dev->source.subsys.u.usb.product); if (usb == NULL) continue; rc = usbDeviceFileIterate(NULL, usb, file_iterate_cb, &buf); - usbFreeDevice(NULL, usb); + usbFreeDevice(usb); if (rc != 0) goto clean; break; } /* TODO: update so files in /sys are readonly case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: { - pciDevice *pci = pciGetDevice(NULL, + pciDevice *pci = pciGetDevice( dev->source.subsys.u.pci.domain, dev->source.subsys.u.pci.bus, dev->source.subsys.u.pci.slot, @@ -864,7 +863,7 @@ get_files(vahControl * ctl) continue; rc = pciDeviceFileIterate(NULL, pci, file_iterate_cb, &buf); - pciFreeDevice(NULL, pci); + pciFreeDevice(pci); break; } diff --git a/src/util/hostusb.c b/src/util/hostusb.c index 96ece38..7ed262b 100644 --- a/src/util/hostusb.c +++ b/src/util/hostusb.c @@ -54,12 +54,11 @@ struct _usbDevice { /* For virReportOOMError() and virReportSystemError() */ #define VIR_FROM_THIS VIR_FROM_NONE -#define usbReportError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ +#define usbReportError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) -static int usbSysReadFile(virConnectPtr conn, - const char *f_name, const char *d_name, +static int usbSysReadFile(const char *f_name, const char *d_name, int base, unsigned *value) { int ret = -1, tmp; @@ -77,7 +76,7 @@ static int usbSysReadFile(virConnectPtr conn, goto cleanup; if (virStrToLong_ui(buf, &ignore, base, value) < 0) { - usbReportError(conn, VIR_ERR_INTERNAL_ERROR, + usbReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse usb file %s"), filename); goto cleanup; } @@ -89,8 +88,7 @@ cleanup: return ret; } -static int usbFindBusByVendor(virConnectPtr conn, - unsigned vendor, unsigned product, +static int usbFindBusByVendor(unsigned vendor, unsigned product, unsigned *bus, unsigned *devno) { DIR *dir = NULL; @@ -111,10 +109,10 @@ static int usbFindBusByVendor(virConnectPtr conn, if (de->d_name[0] == '.' || strchr(de->d_name, ':')) continue; - if (usbSysReadFile(conn, "idVendor", de->d_name, + if (usbSysReadFile("idVendor", de->d_name, 16, &found_vend) < 0) goto cleanup; - if (usbSysReadFile(conn, "idProduct", de->d_name, + if (usbSysReadFile("idProduct", de->d_name, 16, &found_prod) < 0) goto cleanup; @@ -127,13 +125,13 @@ static int usbFindBusByVendor(virConnectPtr conn, tmpstr += 3; if (virStrToLong_ui(tmpstr, &ignore, 10, &found_bus) < 0) { - usbReportError(conn, VIR_ERR_INTERNAL_ERROR, + usbReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse dir name '%s'"), de->d_name); goto cleanup; } - if (usbSysReadFile(conn, "devnum", de->d_name, + if (usbSysReadFile("devnum", de->d_name, 10, &found_addr) < 0) goto cleanup; @@ -145,7 +143,7 @@ static int usbFindBusByVendor(virConnectPtr conn, } if (!found) - usbReportError(conn, VIR_ERR_INTERNAL_ERROR, + usbReportError(VIR_ERR_INTERNAL_ERROR, _("Did not find USB device %x:%x"), vendor, product); else ret = 0; @@ -160,8 +158,7 @@ cleanup: } usbDevice * -usbGetDevice(virConnectPtr conn, - unsigned bus, +usbGetDevice(unsigned bus, unsigned devno, unsigned vendor, unsigned product) @@ -175,7 +172,7 @@ usbGetDevice(virConnectPtr conn, if (vendor) { /* Look up bus.dev by vendor:product */ - if (usbFindBusByVendor(conn, vendor, product, &bus, &devno) < 0) { + if (usbFindBusByVendor(vendor, product, &bus, &devno) < 0) { VIR_FREE(dev); return NULL; } @@ -198,7 +195,7 @@ usbGetDevice(virConnectPtr conn, } void -usbFreeDevice(virConnectPtr conn ATTRIBUTE_UNUSED, usbDevice *dev) +usbFreeDevice(usbDevice *dev) { VIR_DEBUG("%s %s: freeing", dev->id, dev->name); VIR_FREE(dev); diff --git a/src/util/hostusb.h b/src/util/hostusb.h index 739a4aa..2579bdb 100644 --- a/src/util/hostusb.h +++ b/src/util/hostusb.h @@ -26,13 +26,11 @@ typedef struct _usbDevice usbDevice; -usbDevice *usbGetDevice (virConnectPtr conn, - unsigned bus, +usbDevice *usbGetDevice (unsigned bus, unsigned devno, unsigned vendor, unsigned product); -void usbFreeDevice (virConnectPtr conn, - usbDevice *dev); +void usbFreeDevice (usbDevice *dev); /* * Callback that will be invoked once for each file -- 1.6.3.3

On Fri, Feb 05, 2010 at 01:27:24AM +0100, Matthias Bolte wrote:
This set of patches removes the conn parameter from several internal functions where it was used of error reporting only. Since errors are reported to an error object in thread local storage the conn parameter is not necessary for this anymore.
ACK to the whole series. 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 :|

2010/2/8 Daniel P. Berrange <berrange@redhat.com>:
On Fri, Feb 05, 2010 at 01:27:24AM +0100, Matthias Bolte wrote:
This set of patches removes the conn parameter from several internal functions where it was used of error reporting only. Since errors are reported to an error object in thread local storage the conn parameter is not necessary for this anymore.
ACK to the whole series.
Daniel
Thanks, pushed. Matthias
participants (2)
-
Daniel P. Berrange
-
Matthias Bolte