code: public static List<Domain> getRunningDomains(Connect libvirt) {
          try {
              List<Domain> domains = new ArrayList<>();
              int[] ids = libvirt.listDomains();
              for (int id : ids) {
                  domains.add(libvirt.domainLookupByID(id));
              }
              return domains;
          } catch (LibvirtException e) {
              throw new LibvirtRuntimeException("Unable to list defined domains", e);
          }
      }
docs: Get list of the active domains.