IBM has struck a deal to acquire the cloud software company Red Hat for $34 billion.